@@ -260,44 +260,21 @@ async def list_runtime_tools(
260
260
)
261
261
262
262
async def invoke_tool (self , tool_name : str , kwargs : dict [str , Any ]) -> ToolInvocationResult :
263
- if tool_name == "insert_into_memory" :
264
- documents = kwargs .get ("documents" , [])
265
- vector_db_id = kwargs .get ("vector_db_id" )
266
- chunk_size_in_tokens = kwargs .get ("chunk_size_in_tokens" , 512 )
267
-
268
- if not vector_db_id :
269
- raise ValueError ("vector_db_id is required for insert_into_memory" )
270
-
271
- await self .insert (
272
- documents = documents ,
273
- vector_db_id = vector_db_id ,
274
- chunk_size_in_tokens = chunk_size_in_tokens ,
275
- )
276
-
277
- return ToolInvocationResult (
278
- content = [],
279
- metadata = {"inserted_documents" : len (documents )},
280
- )
281
-
282
- elif tool_name == "knowledge_search" :
283
- vector_db_ids = kwargs .get ("vector_db_ids" , [])
284
- query_config = kwargs .get ("query_config" )
285
- if query_config :
286
- query_config = TypeAdapter (RAGQueryConfig ).validate_python (query_config )
287
- else :
288
- query_config = RAGQueryConfig ()
289
-
290
- query = kwargs ["query" ]
291
- result = await self .query (
292
- content = query ,
293
- vector_db_ids = vector_db_ids ,
294
- query_config = query_config ,
295
- )
263
+ vector_db_ids = kwargs .get ("vector_db_ids" , [])
264
+ query_config = kwargs .get ("query_config" )
265
+ if query_config :
266
+ query_config = TypeAdapter (RAGQueryConfig ).validate_python (query_config )
267
+ else :
268
+ query_config = RAGQueryConfig ()
296
269
297
- return ToolInvocationResult (
298
- content = result .content or [],
299
- metadata = result .metadata ,
300
- )
270
+ query = kwargs ["query" ]
271
+ result = await self .query (
272
+ content = query ,
273
+ vector_db_ids = vector_db_ids ,
274
+ query_config = query_config ,
275
+ )
301
276
302
- else :
303
- raise ValueError (f"Unknown tool: { tool_name } " )
277
+ return ToolInvocationResult (
278
+ content = result .content or [],
279
+ metadata = result .metadata ,
280
+ )
0 commit comments