Spaces:
Runtime error
Runtime error
Commit
·
710f3d3
1
Parent(s):
bf614ce
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import streamlit as st
|
3 |
import os
|
4 |
import openai
|
|
|
5 |
|
6 |
-
openai.api_key =
|
7 |
|
8 |
prompt = "This is a concept verification of applying GPT-3 model for China AMC"
|
9 |
|
@@ -19,7 +18,10 @@ def openai_create(prompt):
|
|
19 |
)
|
20 |
return response.choices[0].text
|
21 |
|
22 |
-
|
|
|
|
|
|
|
23 |
|
24 |
def openai_chatcreate(prompt):
|
25 |
messages.append({"role":"user","content":prompt})
|
@@ -41,7 +43,7 @@ def chatgpt_chatclone(input, history):
|
|
41 |
return history, history
|
42 |
|
43 |
def chatgpt_clear(input, history):
|
44 |
-
messages =
|
45 |
return "", [], []
|
46 |
|
47 |
blocks = gr.Blocks()
|
@@ -56,4 +58,4 @@ with blocks:
|
|
56 |
submit.click(fn=chatgpt_chatclone, inputs=[message, state], outputs=[chatbot, state])
|
57 |
|
58 |
|
59 |
-
blocks.launch(debug=False)
|
|
|
|
|
|
|
1 |
import os
|
2 |
import openai
|
3 |
+
import gradio as gr
|
4 |
|
5 |
+
openai.api_key = os.environ['OPENAI_API_KEY']
|
6 |
|
7 |
prompt = "This is a concept verification of applying GPT-3 model for China AMC"
|
8 |
|
|
|
18 |
)
|
19 |
return response.choices[0].text
|
20 |
|
21 |
+
SysIns = [{"role": "system", "content": "You are a professional stock analyst."}]
|
22 |
+
SysIns.append({"role": "system", "content": "让我们讲中文吧。"})
|
23 |
+
|
24 |
+
messages = SysIns
|
25 |
|
26 |
def openai_chatcreate(prompt):
|
27 |
messages.append({"role":"user","content":prompt})
|
|
|
43 |
return history, history
|
44 |
|
45 |
def chatgpt_clear(input, history):
|
46 |
+
messages = SysIns
|
47 |
return "", [], []
|
48 |
|
49 |
blocks = gr.Blocks()
|
|
|
58 |
submit.click(fn=chatgpt_chatclone, inputs=[message, state], outputs=[chatbot, state])
|
59 |
|
60 |
|
61 |
+
blocks.launch(share=True, debug=False)
|