Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1 |
import subprocess
|
2 |
-
subprocess.check_call(["pip", "install", "-q", "openai"])
|
3 |
-
subprocess.check_call(["pip", "install", "-q", "gradio", "transformers", "python-dotenv"])
|
4 |
-
|
5 |
import gradio as gr
|
6 |
from transformers import TFAutoModelForCausalLM, AutoTokenizer
|
7 |
import openai
|
@@ -16,19 +13,19 @@ def openai_chat(prompt):
|
|
16 |
message = completions.choices[0].text
|
17 |
return message.strip()
|
18 |
|
19 |
-
def chatbot(
|
20 |
-
output = openai_chat(
|
21 |
-
history.append((
|
22 |
return history, history
|
23 |
|
24 |
-
title = "
|
25 |
-
description = "This is a chatbot powered by
|
26 |
examples = [
|
27 |
["Hello, how are you?", []],
|
28 |
["What's the meaning of life?", []],
|
29 |
["Tell me a joke.", []]
|
30 |
]
|
31 |
-
inputs = ["
|
32 |
outputs = ["chatbot", "state"]
|
33 |
interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
|
34 |
interface.launch(debug=True)
|
|
|
1 |
import subprocess
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from transformers import TFAutoModelForCausalLM, AutoTokenizer
|
4 |
import openai
|
|
|
13 |
message = completions.choices[0].text
|
14 |
return message.strip()
|
15 |
|
16 |
+
def chatbot(talk_to_chatsherman, history=[]):
|
17 |
+
output = openai_chat(talk_to_chatsherman)
|
18 |
+
history.append((talk_to_chatsherman, output))
|
19 |
return history, history
|
20 |
|
21 |
+
title = "My Chatbot Title"
|
22 |
+
description = "This is a chatbot powered by OpenAI's GPT-3 model."
|
23 |
examples = [
|
24 |
["Hello, how are you?", []],
|
25 |
["What's the meaning of life?", []],
|
26 |
["Tell me a joke.", []]
|
27 |
]
|
28 |
+
inputs = [gr.inputs.Textbox(label="Talk to ChatSherman: "), "state"]
|
29 |
outputs = ["chatbot", "state"]
|
30 |
interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
|
31 |
interface.launch(debug=True)
|