Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,10 @@ def chat_with_openai(user_input, history):
|
|
9 |
if history is None:
|
10 |
history = []
|
11 |
# OpenAI APIに送信するメッセージの構築
|
12 |
-
messages = [
|
13 |
for human, assistant in history:
|
14 |
messages.append({"role": "user", "content": human})
|
15 |
-
if assistant
|
16 |
messages.append({"role": "assistant", "content": assistant})
|
17 |
messages.append({"role": "user", "content": user_input})
|
18 |
|
@@ -33,13 +33,14 @@ with gr.Blocks() as demo:
|
|
33 |
state = gr.State([])
|
34 |
|
35 |
with gr.Row():
|
36 |
-
with gr.Column(scale=
|
37 |
txt = gr.Textbox(
|
38 |
show_label=False,
|
39 |
placeholder="メッセージを入力してください...",
|
40 |
-
lines=1
|
41 |
-
|
42 |
-
|
|
|
43 |
btn = gr.Button("送信")
|
44 |
|
45 |
def on_submit(user_input, chat_history):
|
|
|
9 |
if history is None:
|
10 |
history = []
|
11 |
# OpenAI APIに送信するメッセージの構築
|
12 |
+
messages = []
|
13 |
for human, assistant in history:
|
14 |
messages.append({"role": "user", "content": human})
|
15 |
+
if assistant:
|
16 |
messages.append({"role": "assistant", "content": assistant})
|
17 |
messages.append({"role": "user", "content": user_input})
|
18 |
|
|
|
33 |
state = gr.State([])
|
34 |
|
35 |
with gr.Row():
|
36 |
+
with gr.Column(scale=8):
|
37 |
txt = gr.Textbox(
|
38 |
show_label=False,
|
39 |
placeholder="メッセージを入力してください...",
|
40 |
+
lines=1,
|
41 |
+
container=False
|
42 |
+
)
|
43 |
+
with gr.Column(scale=2, min_width=0):
|
44 |
btn = gr.Button("送信")
|
45 |
|
46 |
def on_submit(user_input, chat_history):
|