run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.47k stars 5.01k forks source link

Graphrag cookbook httpx timeout error #15740

Open Swarn22 opened 2 weeks ago

Swarn22 commented 2 weeks ago

Question Validation

Question

While implementing the graphrag cookbook I am getting an httpx timeout error during the extraction of paths for kg triplet. Anyone else facing the same?

dosubot[bot] commented 2 weeks ago

Hey @Swarn22! I'm here to assist you with any issues you're experiencing with the Graphrag cookbook. I can help you with bug fixes, answer your questions, and guide you on becoming a contributor. Let me know how I can help!

Yes, there are known issues related to HTTPX timeout errors in the GraphRAG cookbook. Specifically, a user reported experiencing timeout errors when trying to build indexes, which is taking a long time and eventually timing out. This issue is related to loading a CSV and treating each row as a document [1].

To handle or configure timeouts for HTTPX requests, you can use the request_timeout field to set the timeout for HTTP requests. Here is an example of how to configure it:

request_timeout: float = Field(
    default=DEFAULT_REQUEST_TIMEOUT,
    description="The timeout for making http request to llamafile API server",
)

with httpx.Client(timeout=Timeout(self.request_timeout)) as client:
    response = client.post(
        url=f"{self.base_url}/embedding",
        headers={"Content-Type": "application/json"},
        json=request_body,
    )
    response.encoding = "utf-8"
    response.raise_for_status()
    return response.json()["embedding"]

async with httpx.AsyncClient(timeout=Timeout(self.request_timeout)) as client:
    response = await client.post(
        url=f"{self.base_url}/embedding",
        headers={"Content-Type": "application/json"},
        json=request_body,
    )
    response.encoding = "utf-8"
    response.raise_for_status()
    return response.json()["embedding"]

These snippets show how to configure and handle timeouts for HTTPX requests [2].

To continue talking to Dosu, mention @dosu.