@@ -76,7 +76,9 @@ def web_search(query: str, outer_ctx: Dict[str, Any]) -> Dict[str, Any]:
76
76
register_tool (
77
77
ToolSpec (
78
78
name = "web_search" ,
79
- description = "Search the web for information." ,
79
+ description = """
80
+ Search the web for information. This tool provides urls and short snippets,
81
+ but does not fetch the full content of the urls.""" ,
80
82
parameters = {
81
83
"type" : "object" ,
82
84
"properties" : {"query" : {"type" : "string" }},
@@ -110,7 +112,7 @@ def web_fetch(urls: List[str], outer_ctx: Dict[str, Any]) -> Dict[str, Any]:
110
112
register_tool (
111
113
ToolSpec (
112
114
name = "web_fetch" ,
113
- description = "Fetch the contents of a list of URLs." ,
115
+ description = "Fetch the fullcontents of a list of URLs." ,
114
116
parameters = {
115
117
"type" : "object" ,
116
118
"properties" : {"urls" : {"type" : "array" , "items" : {"type" : "string" }}},
@@ -134,24 +136,45 @@ def reasoning(outer_ctx: Dict[str, Any]) -> Dict[str, Any]:
134
136
revised_messages = [
135
137
{"role" : "system" , "content" : PRIVATE_SCRATCHPAD_SYS },
136
138
] + messages [1 :]
137
- results = litellm . completion (
138
- model = llm .config .model_name ,
139
+ results = llm_completion (
140
+ model_name = llm .config .model_name ,
139
141
temperature = llm .config .temperature ,
140
142
messages = revised_messages ,
143
+ tools = [],
144
+ stream = False ,
141
145
)
142
146
return {"results" : results ["choices" ][0 ]["message" ]["content" ]}
143
147
144
148
145
149
register_tool (
146
150
ToolSpec (
147
151
name = "reasoning" ,
148
- description = "Reason about the message history and the goal." ,
152
+ description = """
153
+ Use this tool for reasoning. Powerful for complex questions and
154
+ tasks, or questions that require multiple steps to answer.""" ,
149
155
parameters = {"type" : "object" , "properties" : {}, "required" : []},
150
156
func = reasoning ,
151
157
)
152
158
)
153
159
154
160
161
+ @traced (name = "llm_completion" , type = "llm" )
162
+ def llm_completion (
163
+ model_name : str ,
164
+ temperature : float ,
165
+ messages : List [Dict [str , Any ]],
166
+ tools : List [Dict [str , Any ]],
167
+ stream : bool = False ,
168
+ ) -> Dict [str , Any ]:
169
+ return litellm .completion (
170
+ model = model_name ,
171
+ temperature = temperature ,
172
+ messages = messages ,
173
+ tools = tools ,
174
+ stream = stream ,
175
+ )
176
+
177
+
155
178
def tool_specs_for_openai () -> List [Dict [str , Any ]]:
156
179
return [
157
180
{
@@ -197,12 +220,12 @@ def stream_chat_sync(
197
220
yield {"type" : "delta" , "text" : "\n [Timed out while composing reply]" }
198
221
break
199
222
# Start a streaming completion (sync iterator of deltas)
200
- stream_iter = litellm . completion (
201
- model = llm .config .model_name ,
223
+ stream_iter = llm_completion (
224
+ model_name = llm .config .model_name ,
202
225
temperature = llm .config .temperature ,
203
226
messages = messages ,
204
227
tools = tools_decl ,
205
- stream = True , # iterator of chunks
228
+ stream = True ,
206
229
)
207
230
208
231
# Accumulate assistant text & tool call chunks
0 commit comments