Spaces:
Sleeping
Sleeping
Commit
·
cb597f8
1
Parent(s):
b8edde2
Create thunder_gpt.py
Browse files- thunder_gpt.py +35 -0
thunder_gpt.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
openai.api_key = os.environ.get('openai_key')
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def get_response(question):
|
| 11 |
+
response = openai.chat.completions.create(
|
| 12 |
+
model="gpt-3.5-turbo",
|
| 13 |
+
messages=[
|
| 14 |
+
{
|
| 15 |
+
"role": "system",
|
| 16 |
+
"content": "You name is cranberry pie, A ai assistant created by HARSHA VARDHAN V Aka Thunder-007 as a ml intern task."
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"role": "system",
|
| 20 |
+
"content": "You may be asked questions on this blog " + open('blog.txt').read()
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"role": "user",
|
| 24 |
+
"content": question
|
| 25 |
+
}
|
| 26 |
+
],
|
| 27 |
+
temperature=1,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
return response.choices[0].message.content
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
print(get_response("Hey who are you ?"))
|
| 35 |
+
|