JeffJing commited on
Commit
26a39bd
·
1 Parent(s): ac2464e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -33
app.py CHANGED
@@ -1,52 +1,45 @@
1
  import os
2
  import gradio as gr
3
- from revChatGPT.V1 import Chatbot
4
 
5
  #if you have OpenAI API key as an environment variable, enable the below
6
  #openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  #if you have OpenAI API key as a string, enable the below
9
- #openai.api_key = "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"
10
 
11
- start_sequence = "\nAI:"
12
- restart_sequence = "\nHuman: "
13
 
14
- prompt = "您好,我是做客ChatBot,基于ChatGPT官网反向工程接口实现的智能对话机器人。\n\n请放心使用,和我对话与在官网直接对ChatGPT对话,得的的回答会完全一样。\n\n您有什么需要?~"
15
 
16
- chatbot1 = Chatbot(config={
17
- "email": "[email protected]",
18
- "password": "Chatgpt!123",
19
- "paid": "True"
20
- })
21
 
22
  def openai_create(prompt):
23
- for data in chatbot1.ask(prompt):
24
- response = data["message"]
25
- return response
26
-
27
 
28
  def chatgpt_clone(input, history):
29
- history = history or []
30
- s = list(sum(history, ()))
31
- s.append(input)
32
- inp = ' '.join(s)
33
- output = openai_create(input)
34
- output = output.replace("\n", "<br>")
35
- history.append((input, output))
36
- return history, history
37
 
38
 
39
  block = gr.Blocks()
40
 
41
-
42
  with block:
43
- gr.Markdown("""<h1><center>做客ChatBot</center></h1>
44
- """)
45
- chatbot = gr.Chatbot()
46
- message = gr.Textbox(placeholder=prompt,label="开聊:")
47
- state = gr.State()
48
- submit = gr.Button("提交")
49
- submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot, state])
50
-
51
- block.launch(debug = False)
52
-
 
1
  import os
2
  import gradio as gr
3
+ from steamship import Steamship
4
 
5
  #if you have OpenAI API key as an environment variable, enable the below
6
  #openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  #if you have OpenAI API key as a string, enable the below
 
9
 
10
+ client = Steamship(workspace="chatgpt-4")
11
+ generator = client.use_plugin('gpt-4')
12
 
13
+ prompt = "你好,我是做客ChatBot,当前运行在OpenAI GPT-4模型,欢迎大家通过我体验GPT-4的强大。"
14
 
 
 
 
 
 
15
 
16
  def openai_create(prompt):
17
+ task = generator.generate(text=prompt)
18
+ task.wait()
19
+ return task.output.blocks[0].text
20
+
21
 
22
  def chatgpt_clone(input, history):
23
+ history = history or []
24
+ s = list(sum(history, ()))
25
+ s.append(input)
26
+ inp = ' '.join(s)
27
+ output = openai_create(input)
28
+ output = output.replace("\n", "<br>")
29
+ history.append((input, output))
30
+ return history, history
31
 
32
 
33
  block = gr.Blocks()
34
 
 
35
  with block:
36
+ gr.Markdown("""<img src="file/ZookChatBot.png">""")
37
+ chatbot = gr.Chatbot()
38
+ message = gr.Textbox(placeholder=prompt, label="开聊:")
39
+ state = gr.State()
40
+ submit = gr.Button("提交")
41
+ submit.click(chatgpt_clone,
42
+ inputs=[message, state],
43
+ outputs=[chatbot, state])
44
+
45
+ block.launch(debug=True, share=True)