Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RAG API Server to use Async/Await #835

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ishaansehgal99
Copy link
Collaborator

Reason for Change:
Endpoints are currently sequentially blocking synchronous. After review we use async-await pattern correctly.

@zhuangqh
Copy link
Collaborator

=========================== short test summary info ============================
FAILED presets/ragengine/tests/vector_store/test_chromadb_store.py::TestChromaDBVectorStore::test_query_documents - TypeError: 'coroutine' object is not subscriptable
FAILED presets/ragengine/tests/vector_store/test_faiss_store.py::TestFaissVectorStore::test_query_documents - TypeError: 'coroutine' object is not subscriptable
================== 2 failed, 15 passed, 35 warnings in 29.66s ==================
make: *** [Makefile:109: rag-service-test] Error 1

please take a look

Copy link
Collaborator

@Fei-Guo Fei-Guo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async def health_check():

As we discussed, should we remove async here?

"""Common logic for adding a single document."""
if index_name not in self.index_map:
raise ValueError(f"No such index: '{index_name}' exists.")
llama_doc = LlamaDocument(text=document.text, metadata=document.metadata, id_=doc_id)
self.index_map[index_name].insert(llama_doc)
await self.index_map[index_name].insert(llama_doc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in-memory operation, right? Do we need await?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this one is not awaitable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is llamaindex insert - llama_index/core/indices/base.py
yes it is not awaitable

    def insert(self, document: Document, **insert_kwargs: Any) -> None:
        """Insert a document."""
        with self._callback_manager.as_trace("insert"):
            nodes = run_transformations(
                [document],
                self._transformations,
                show_progress=self._show_progress,
                **insert_kwargs,
            )

            self.insert_nodes(nodes, **insert_kwargs)
            self.docstore.set_document_hash(document.get_doc_id(), document.hash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants