fix chat attempt 1
Browse files
app.py
CHANGED
@@ -119,18 +119,18 @@ with gr.Blocks(title=title) as demo:
|
|
119 |
with gr.Row():
|
120 |
with gr.Column():
|
121 |
instruction = gr.Textbox(lines=2, label="Instruction", value='東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。')
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
with gr.Column():
|
129 |
with gr.Row():
|
130 |
submit = gr.Button("Submit", variant="primary")
|
131 |
clear = gr.Button("Clear", variant="secondary")
|
132 |
output = gr.Textbox(label="Output", lines=5)
|
133 |
-
data = gr.Dataset(components=[instruction,
|
134 |
submit.click(evaluate, [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty], [output])
|
135 |
clear.click(lambda: None, [], [output])
|
136 |
data.click(lambda x: x, [data], [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty])
|
@@ -142,11 +142,11 @@ with gr.Blocks(title=title) as demo:
|
|
142 |
msg = gr.Textbox(scale=4, show_label=False, placeholder="Enter text and press enter", container=False)
|
143 |
clear = gr.Button("Clear")
|
144 |
with gr.Column():
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
151 |
def clear_chat():
|
152 |
return "", []
|
@@ -156,15 +156,16 @@ with gr.Blocks(title=title) as demo:
|
|
156 |
return "", history + [[message, None]]
|
157 |
|
158 |
def chat(history):
|
|
|
159 |
# get the last user message and the additional parameters
|
160 |
message = history[-1][0]
|
161 |
instruction = msg.value
|
162 |
-
token_count =
|
163 |
|
164 |
-
temperature =
|
165 |
-
top_p =
|
166 |
-
presence_penalty =
|
167 |
-
count_penalty =
|
168 |
|
169 |
response = evaluate(instruction, None, token_count, temperature, top_p, presence_penalty, count_penalty, history)
|
170 |
|
|
|
119 |
with gr.Row():
|
120 |
with gr.Column():
|
121 |
instruction = gr.Textbox(lines=2, label="Instruction", value='東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。')
|
122 |
+
input_instruct = gr.Textbox(lines=2, label="Input", placeholder="")
|
123 |
+
token_count_instruct = gr.Slider(10, 512, label="Max Tokens", step=10, value=333)
|
124 |
+
temperature_instruct = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
|
125 |
+
top_p_instruct = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
126 |
+
presence_penalty_instruct = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0)
|
127 |
+
count_penalty_instruct = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.7)
|
128 |
with gr.Column():
|
129 |
with gr.Row():
|
130 |
submit = gr.Button("Submit", variant="primary")
|
131 |
clear = gr.Button("Clear", variant="secondary")
|
132 |
output = gr.Textbox(label="Output", lines=5)
|
133 |
+
data = gr.Dataset(components=[instruction, input_instruct, token_count_instruct, temperature_instruct, top_p_instruct, presence_penalty_instruct, count_penalty_instruct], samples=examples, label="Example Instructions", headers=["Instruction", "Input", "Max Tokens", "Temperature", "Top P", "Presence Penalty", "Count Penalty"])
|
134 |
submit.click(evaluate, [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty], [output])
|
135 |
clear.click(lambda: None, [], [output])
|
136 |
data.click(lambda x: x, [data], [instruction, input, token_count, temperature, top_p, presence_penalty, count_penalty])
|
|
|
142 |
msg = gr.Textbox(scale=4, show_label=False, placeholder="Enter text and press enter", container=False)
|
143 |
clear = gr.Button("Clear")
|
144 |
with gr.Column():
|
145 |
+
token_count_chat = gr.Slider(10, 512, label="Max Tokens", step=10, value=333)
|
146 |
+
temperature_chat = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.2)
|
147 |
+
top_p_chat = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
148 |
+
presence_penalty_chat = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=0)
|
149 |
+
count_penalty_chat = gr.Slider(0.0, 1.0, label="Count Penalty", step=0.1, value=0.7)
|
150 |
|
151 |
def clear_chat():
|
152 |
return "", []
|
|
|
156 |
return "", history + [[message, None]]
|
157 |
|
158 |
def chat(history):
|
159 |
+
global token_count_chat, temperature_chat, top_p_chat, presence_penalty_chat, count_penalty_chat
|
160 |
# get the last user message and the additional parameters
|
161 |
message = history[-1][0]
|
162 |
instruction = msg.value
|
163 |
+
token_count = token_count_chat.value
|
164 |
|
165 |
+
temperature = temperature_chat.value
|
166 |
+
top_p = top_p_chat.value
|
167 |
+
presence_penalty = presence_penalty_chat.value
|
168 |
+
count_penalty = count_penalty_chat.value
|
169 |
|
170 |
response = evaluate(instruction, None, token_count, temperature, top_p, presence_penalty, count_penalty, history)
|
171 |
|