Spaces:
Sleeping
Sleeping
import openai | |
import os | |
from dotenv import load_dotenv | |
load_dotenv() | |
openai.api_key = os.getenv('OPENAI_API_KEY') | |
def chat_completion(prompt): | |
response = openai.Completion.create( | |
engine="text-davinci-003", | |
prompt=prompt, | |
max_tokens=150 | |
) | |
return { | |
'response': response.choices[0].text.strip() | |
} | |