Chris STC
commited on
Commit
•
cb01412
1
Parent(s):
c74f9a8
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ generator = pipeline('text-generation', model='gpt2')
|
|
6 |
|
7 |
def generate_text(prompt, temperature, max_length, instruction):
|
8 |
set_seed(42)
|
9 |
-
result = generator(prompt, max_length=max_length, num_return_sequences=1, temperature=temperature)
|
10 |
return result[0]['generated_text']
|
11 |
|
12 |
# Define Gradio interface
|
@@ -15,7 +15,7 @@ iface = gr.Interface(
|
|
15 |
inputs=[gr.inputs.Textbox(lines=3, label="Your Message"),
|
16 |
gr.inputs.Slider(minimum=0.1, maximum=1.0, default=0.5, label="Temperature"),
|
17 |
gr.inputs.Slider(minimum=10, maximum=200, default=100, label="Max Length"),
|
18 |
-
gr.inputs.Textbox(default="This is a chat between the user and
|
19 |
outputs=gr.outputs.Textbox(label="AI Response"),
|
20 |
layout="vertical",
|
21 |
title="Chat with GPT-2",
|
|
|
6 |
|
7 |
def generate_text(prompt, temperature, max_length, instruction):
|
8 |
set_seed(42)
|
9 |
+
result = generator(prompt + "\nAI: ", max_length=max_length, num_return_sequences=1, temperature=temperature)
|
10 |
return result[0]['generated_text']
|
11 |
|
12 |
# Define Gradio interface
|
|
|
15 |
inputs=[gr.inputs.Textbox(lines=3, label="Your Message"),
|
16 |
gr.inputs.Slider(minimum=0.1, maximum=1.0, default=0.5, label="Temperature"),
|
17 |
gr.inputs.Slider(minimum=10, maximum=200, default=100, label="Max Length"),
|
18 |
+
gr.inputs.Textbox(default="This is a chat between the user and a truthful and intelligent AI. AI must answer very truthfully and accurately. The chat begins now.\nUser: hi\nAI: Hello, what do you need assistance with?\nUser: ", lines=2, label="AI Instruction")],
|
19 |
outputs=gr.outputs.Textbox(label="AI Response"),
|
20 |
layout="vertical",
|
21 |
title="Chat with GPT-2",
|