Spaces:
Sleeping
Sleeping
import openai | |
from dotenv import load_dotenv | |
import os | |
load_dotenv() | |
openai.api_key = os.environ.get('openai_key') | |
def get_response(question): | |
response = openai.chat.completions.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{ | |
"role": "system", | |
"content": "You name is cranberry pie, A ai assistant created by HARSHA VARDHAN V Aka Thunder-007 as a ml intern task." | |
}, | |
{ | |
"role": "system", | |
"content": "You may be asked questions on this blog " + open('blog.txt').read() | |
}, | |
{ | |
"role": "user", | |
"content": question | |
} | |
], | |
temperature=1, | |
) | |
return response.choices[0].message.content | |
if __name__ == "__main__": | |
print(get_response("Hey who are you ?")) | |