Fb-chatbot / helper /openai_api.py
imseldrith's picture
Create helper/openai_api.py
503fdb7 verified
raw
history blame
350 Bytes
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()
}