@@ -12,7 +12,7 @@ def __init__(self, func: Callable, name: str = None, desc: str = None, args: dic
1212 annotations_func = func if inspect .isfunction (func ) else func .__call__
1313 self .func = func
1414 self .name = name or getattr (func , '__name__' , type (func ).__name__ )
15- self .desc = desc or getattr (func , '__doc__' , None ) or getattr (annotations_func , '__doc__' , "No description " )
15+ self .desc = desc or getattr (func , '__doc__' , None ) or getattr (annotations_func , '__doc__' , "" )
1616 self .args = {
1717 k : v .schema () if isinstance ((origin := get_origin (v ) or v ), type ) and issubclass (origin , BaseModel )
1818 else get_annotation_name (v )
@@ -50,10 +50,10 @@ def __init__(self, signature, tools: list[Callable], max_iters=5):
5050 tools ["finish" ] = Tool (func = lambda ** kwargs : "Completed." , name = "finish" , desc = finish_desc , args = finish_args )
5151
5252 for idx , tool in enumerate (tools .values ()):
53- desc = tool .desc .replace ("\n " , " " )
5453 args = tool .args if hasattr (tool , 'args' ) else str ({tool .input_variable : str })
55- desc = f"whose description is <desc>{ desc } </desc>. It takes arguments { args } in JSON format."
56- instr .append (f"({ idx + 1 } ) { tool .name } , { desc } " )
54+ desc = (f", whose description is <desc>{ tool .desc } </desc>." if tool .desc else "." ).replace ('\n ' , " " )
55+ desc += f" It takes arguments { args } in JSON format."
56+ instr .append (f"({ idx + 1 } ) { tool .name } { desc } " )
5757
5858 signature_ = (
5959 dspy .Signature ({** signature .input_fields }, "\n " .join (instr ))
0 commit comments