Update
This commit is contained in:
commit
5c5dbc0bf4
3 changed files with 33 additions and 0 deletions
22
main.py
Normal file
22
main.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import os
|
||||
|
||||
import openai
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
openai.api_key = os.getenv("OPEN_AI_KEY")
|
||||
|
||||
|
||||
@app.get("/getAns")
|
||||
async def root(msg: str):
|
||||
return {"ans": get_ans(msg)}
|
||||
|
||||
|
||||
def get_ans(msg):
|
||||
return openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{"role": "user", "content": msg},
|
||||
]
|
||||
).choices[0].message.content
|
||||
Loading…
Add table
Add a link
Reference in a new issue