Spaces:
Runtime error
Runtime error
MUHAMMEDHAFEEZ
commited on
Commit
•
c7a9d22
1
Parent(s):
fabaaba
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio
|
3 |
+
|
4 |
+
openai.api_key = "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"
|
5 |
+
|
6 |
+
messages = [{"role": "system", "content": "You are an expert Python developer and more programming languages with years of experience writing Python code and teaching Python to other programmers"}]
|
7 |
+
|
8 |
+
def CustomChatGPT(user_input):
|
9 |
+
messages.append({"role": "user", "content": user_input})
|
10 |
+
response = openai.ChatCompletion.create(
|
11 |
+
model = "gpt-3.5-turbo",
|
12 |
+
messages = messages
|
13 |
+
)
|
14 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
15 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
16 |
+
user_input = ''
|
17 |
+
return ChatGPT_reply
|
18 |
+
|
19 |
+
alpha = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "HAFEEZGPT😂")
|
20 |
+
|
21 |
+
alpha.launch(share=True)
|