Leon4gr45 commited on
Commit
4af1773
·
verified ·
1 Parent(s): 322bfd8

Fix document_query.py KeyError: 'document'

Browse files
Files changed (1) hide show
  1. python/tools/document_query.py +26 -0
python/tools/document_query.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any
2
+ from python.helpers.tool import Tool, Response
3
+
4
+ class DocumentQuery(Tool):
5
+ """
6
+ Tool for querying documents in the knowledge base.
7
+ Fixed to handle missing 'document' parameter gracefully.
8
+ """
9
+
10
+ async def execute(self, **kwargs) -> Response:
11
+ # Safely get the 'document' parameter with a default of None
12
+ document_uri = kwargs.get("document") or None
13
+
14
+ if not document_uri:
15
+ return Response(
16
+ message="Error: No document URI provided. Please specify a document to query.",
17
+ break_loop=False
18
+ )
19
+
20
+ # Placeholder for actual document query logic
21
+ # This should be implemented based on your knowledge base structure
22
+ return Response(
23
+ message=f"Document query requested for: {document_uri}. "
24
+ f"Note: Document querying functionality needs to be implemented.",
25
+ break_loop=False
26
+ )