Skip to content

Agent Zero AI framework

Merge branch 'pr/772' into development

frdeld78e0cd2afcd
diff --cc python/helpers/document_query.py
index e141d2544,b6bca9b1f..6ba38855c
--- a/python/helpers/document_query.py
+++ b/python/helpers/document_query.py
@@@ -361,14 -361,16 +361,18 @@@ class DocumentQueryHelper
self.progress_callback = progress_callback or (lambda x: None)
async def document_qa(
- self, document_uri: str, questions: Sequence[str]
+ self, document_uris: List[str], questions: Sequence[str]
) -> Tuple[bool, str]:
- self.progress_callback(f"Starting Q&A process")
+ self.progress_callback(
+ f"Starting Q&A process for {len(document_uris)} documents"
+ )
+ await self.agent.handle_intervention()
- # index document
- _ = await self.document_get_content(document_uri, True)
+ # index documents
+ await asyncio.gather(
+ *[self.document_get_content(uri, True) for uri in document_uris]
+ )
+ await self.agent.handle_intervention()
selected_chunks = {}
for question in questions:
self.progress_callback(f"Optimizing query: {question}")
@@@ -384,12 -385,14 +388,15 @@@
)
).strip()
+ await self.agent.handle_intervention()
- self.progress_callback(f"Searching document with query: {optimized_query}")
+ self.progress_callback(f"Searching documents with query: {optimized_query}")
+
+ normalized_uris = [self.store.normalize_uri(uri) for uri in document_uris]
+ doc_filter = " or ".join(
+ [f"document_uri == '{uri}'" for uri in normalized_uris]
+ )
- normalized_uri = self.store.normalize_uri(document_uri)
- chunks = await self.store.search_document(
- document_uri=normalized_uri,
+ chunks = await self.store.search_documents(
query=optimized_query,
limit=100,
threshold=DEFAULT_SEARCH_THRESHOLD,