Skip to content

Requests timing out  #108

@RaulSantanaTrejo

Description

@RaulSantanaTrejo

I am running a Python backend service using fastapi and a docker container and every once in a while all requests start timing out for no apparent reason. The same request can time out and suddenly work an hour later. The service is under development so my team is the only one currently using our keys and service. I have created a simple call with no fancy logic and using the ada model but this still times out (see code below). I get

"error.APIConnectionerror("error communicating with OpenAI")"

coming from

"requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/engines/text-ada-001/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3052475310>: Failed to establish a new connection: [Errno 110] Connection timed out'))"

Code:

def simple_call():
    openai.organization = config('ORGANIZATION')
    openai.api_key = config('API_KEY')
    print("WARNING: performing simple call")
    prompt = "Tell me a fun story to cheer me up"
    completion = openai.Completion.create(**{"engine": "text-ada-001", "max_tokens": 500, "prompt": prompt})
    response = {'generations': [{'prompt': prompt, 'question': "MOCK", 'answer': completion["choices"][0]["text"]}]}
    return response

Any advice is appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions