Spaces:
Runtime error
Runtime error
Commit
·
54bc020
1
Parent(s):
a7247a1
Fixed.
Browse files
app.py
CHANGED
@@ -2,16 +2,32 @@
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
output = model.generate(input_ids, max_length=50, do_sample=True, top_k=50, top_p=0.95, num_return_sequences=3)
|
13 |
-
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
14 |
-
return output_text
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Create a text input
|
6 |
+
text_input = gr.inputs.Textbox(lines=2, label="Enter your text:")
|
7 |
|
8 |
+
# Create a ChatGPT object
|
9 |
+
chatgpt = gr.ChatGPT()
|
10 |
|
11 |
+
# Create a text output
|
12 |
+
text_output = gr.outputs.Textbox(label="ChatGPT Output:")
|
|
|
|
|
|
|
13 |
|
14 |
+
# Create a button
|
15 |
+
button = gr.inputs.Button(label="Submit")
|
16 |
+
|
17 |
+
# Create a form
|
18 |
+
form = gr.Interface(
|
19 |
+
text_input,
|
20 |
+
button,
|
21 |
+
text_output,
|
22 |
+
title="ChatGPT",
|
23 |
+
description="Chat with a GPT-3 model"
|
24 |
+
)
|
25 |
+
|
26 |
+
# Define the function that will be called when the button is clicked
|
27 |
+
def process_input(values):
|
28 |
+
text = values["text_input"]
|
29 |
+
response = chatgpt.chat(text)
|
30 |
+
return {"text_output": response}
|
31 |
+
|
32 |
+
# Launch the form
|
33 |
+
form.launch(process_input)
|