Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,21 @@
|
|
| 1 |
-
import
|
| 2 |
import openai
|
|
|
|
|
|
|
| 3 |
|
| 4 |
openai.api_key = "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"
|
| 5 |
|
| 6 |
-
messages = [{"role": "system", "content": "You are a financial
|
| 7 |
|
| 8 |
def CustomChatGPT(user_input):
|
| 9 |
-
if len(messages) > 10:
|
| 10 |
-
messages.pop(0)
|
| 11 |
messages.append({"role": "user", "content": user_input})
|
| 12 |
response = openai.ChatCompletion.create(
|
| 13 |
-
model="gpt-3.5-turbo",
|
| 14 |
-
|
| 15 |
-
temperature=0.7,
|
| 16 |
-
max_tokens=1024,
|
| 17 |
-
n=1,
|
| 18 |
-
stop=None,
|
| 19 |
-
frequency_penalty=0,
|
| 20 |
-
presence_penalty=0,
|
| 21 |
)
|
| 22 |
-
ChatGPT_reply = response
|
| 23 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 24 |
return ChatGPT_reply
|
| 25 |
|
| 26 |
-
iface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="ChatBot")
|
| 27 |
-
iface.launch(debug=True)
|
|
|
|
| 1 |
+
import os
|
| 2 |
import openai
|
| 3 |
+
os.system("pip install gradio==3.19.1")
|
| 4 |
+
import gradio as gr
|
| 5 |
|
| 6 |
openai.api_key = "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"
|
| 7 |
|
| 8 |
+
messages = [{"role": "system", "content": "You are a financial experts that specializes in real estate investment and negotiation"}]
|
| 9 |
|
| 10 |
def CustomChatGPT(user_input):
|
|
|
|
|
|
|
| 11 |
messages.append({"role": "user", "content": user_input})
|
| 12 |
response = openai.ChatCompletion.create(
|
| 13 |
+
model = "gpt-3.5-turbo",
|
| 14 |
+
messages = messages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
)
|
| 16 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 17 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 18 |
return ChatGPT_reply
|
| 19 |
|
| 20 |
+
iface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title = "ChatBot")
|
| 21 |
+
iface.launch(debug = True)
|