INNER CODE UNIT · Python

upload_documents

mfmezger/conversational-agent-langchain · frontend/client.py:30

    async def upload_documents(self, files: list[tuple], collection_name: str = "default", file_ending: str = ".pdf") -> httpx.Response:
        """Upload documents to the backend."""
        params = {"collection_name": collection_name, "file_ending": file_ending}
        # httpx handles files differently than requests
        # files list of tuples (name, (filename, content, content_type))
        async with httpx.AsyncClient(timeout=6000.0) as client:
            return await client.post(f"{self.base_url}/embeddings/documents", params=params, files=files)

    async def search(self, query: str, collection_name: str = "default") -> httpx.Response:
        """Search for documents."""
        params = {"query": query, "collection_name": collection_name}
        async with httpx.AsyncClient(timeout=60.0) as client:
            return await client.get(f"{self.base_url}/semantic/search", params=params)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…