The Custom Server is a dedicated Server for storing custom tool functions (Tools) that cannot be categorized into standard modules such as Retriever, Generation, Evaluation, etc. All logical tools that do not belong to the core Server (e.g., data cleaning, keyword extraction, specific rule logic, etc.) can be included in the Custom Server.
Below is a custom Tool used in the Search-o1 pipeline to extract the search query string between <|begin_search_query|> and <|end_search_query|> from the model-generated answers:
servers/custom/src/custom.py
Copy
@app.tool(output="ans_ls->extract_query_list")def search_o1_query_extract(ans_ls: List[str]) -> Dict[str, List[str]]: def get_query(text): import re pattern = ( re.escape("<|begin_search_query|>") + r"(.*?)" + re.escape("<|end_search_query|>") ) matches = re.findall(pattern, text, flags=re.DOTALL) if matches: query = matches[-1].strip() if not query.endswith("?"): query += "?" return query else: return "There is no query." query = [get_query(answer) for answer in ans_ls] return {"extract_query_list": query}
A typical use of this Tool is to insert the extraction step after generation, for example: