agent / python /tools /document_query.py
Leon4gr45's picture
Fix document_query.py KeyError: 'document'
c9ed5b4 verified
raw
history blame contribute delete
975 Bytes
from typing import Any
from python.helpers.tool import Tool, Response
class DocumentQuery(Tool):
"""
Tool for querying documents in the knowledge base.
Fixed to handle missing 'document' parameter gracefully.
"""
async def execute(self, **kwargs) -> Response:
# Safely get the 'document' parameter with a default of None
document_uri = kwargs.get("document") or None
if not document_uri:
return Response(
message="Error: No document URI provided. Please specify a document to query.",
break_loop=False
)
# Placeholder for actual document query logic
# This should be implemented based on your knowledge base structure
return Response(
message=f"Document query requested for: {document_uri}. "
f"Note: Document querying functionality needs to be implemented.",
break_loop=False
)