I want to integrate opeai api with my chatbot built with Dialogflow(ES) But I Keep getting a timeout error how do I fix it?
from fastapi import FastAPI
from fastapi import Request
from fastapi.responses import JSONResponse
from openai import OpenAI
app = FastAPI()
# openai_api_key = os.environ.get('OPENAI_API_KEY')
client=OpenAI(api_key="########",)
messages = []
@app.post('/')
async def webhook(request: Request)->dict:
payload = await request.json()
intent=payload['queryResult']['intent']['displayName']
question=payload['queryResult']['queryText']
if intent=="StressManagementTips":
messages.append({"role": "user", "content": question})
chat_completion=client.chat.completions.create(messages=messages,model="gpt-3.5-turbo",timeout=2,
max_tokens=75,temperature=0.7,top_p=0.9,frequency_penalty=0,presence_penalty=0.6)
reply = chat_completion["choices"][0]["message"]["content"]
return JSONResponse(content={"fulfillmentText":reply})
is there anything wrong with my code?
I want to identify intents and send the question to the backend and generate an answer. It shouldn't be too long that's why I have some parameters. Can someone help me fix it? Thank you
Webhook call failed. Error: DEADLINE_EXCEEDED, State: URL_TIMEOUT, Reason: TIMEOUT_WEB.