Skip to content

How to adjust timeout for contextual completions? #17

@Just-enki

Description

@Just-enki

Im moving my pgpt requests to a python api but unlike typescript I cannot change the default timeout setting, whereas in Typescript I could simply pass const requestOptions = { timeoutInSeconds: 600, maxRetries: 1 }; with my request. This doesn't seem to be an option here.

This has worked for me when working in typescript

async function getChatResult(chatMessages: ChatMessage[], requestOptions?: ContextualCompletions.RequestOptions): Promise<ChatResult> {
  const pgptResponse = await pgptApiClient.contextualCompletions.chatCompletion(
    {
      messages: chatMessages,
      includeSources: true,
      useContext: true,
    },
    requestOptions
  );
  return pgptResponse;
}

Now ive switched over to Python and seemingly the only way to change the values is to enter the docker container and edit resources/contextual_completions/client.py manually.

So far ive tried:
1.

client = PrivateGPTApi(base_url="http://private-gpt:8001/", timeout=600)
httpx_client = httpx.Client(timeout=httpx.Timeout(600.0, connect=600.0, read=600.0, write=600.0))

client = PrivateGPTApi(
    base_url="http://private-gpt:8001/",
    httpx_client=httpx_client 
client = PrivateGPTApi(
    base_url="http://private-gpt:8001/",
    timeout=httpx.Timeout(600.0, connect=600.0, read=600.0, write=600.0)
@app.post("/gpt/chat")
async def gptChat(chat_request: ChatRequest):
    try: 
        chat_result = client.contextual_completions.chat_completion(
            messages=chat_request.messages, 
            use_context=True,
            include_sources=True,
            timeout=600,
        )
        return chat_result.choices[0].message.content

all with no success. Is there something im missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions