Chad commited on
Commit ·
6092af3
1
Parent(s): 85f3f5b
nwfbwfbwdwddwwdwd
Browse files
app.py
CHANGED
|
@@ -36,7 +36,7 @@ def respond(message, history):
|
|
| 36 |
temperature=0.7,
|
| 37 |
max_completion_tokens=512,
|
| 38 |
top_p=0.95,
|
| 39 |
-
stream=
|
| 40 |
stop=None,
|
| 41 |
)
|
| 42 |
reply = response.choices[0].message.content or "..."
|
|
@@ -46,33 +46,37 @@ def respond(message, history):
|
|
| 46 |
history.append((message, reply))
|
| 47 |
return history, ""
|
| 48 |
|
| 49 |
-
with gr.Blocks() as
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
],
|
| 71 |
-
|
| 72 |
)
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
-
|
|
|
|
|
|
| 36 |
temperature=0.7,
|
| 37 |
max_completion_tokens=512,
|
| 38 |
top_p=0.95,
|
| 39 |
+
stream=True,
|
| 40 |
stop=None,
|
| 41 |
)
|
| 42 |
reply = response.choices[0].message.content or "..."
|
|
|
|
| 46 |
history.append((message, reply))
|
| 47 |
return history, ""
|
| 48 |
|
| 49 |
+
with gr.Blocks() as interface:
|
| 50 |
+
gr.Markdown("## History Chatbot")
|
| 51 |
+
chatbot = gr.Chatbot(type="messages")
|
| 52 |
+
state = gr.State([])
|
| 53 |
+
user_input = gr.Textbox(placeholder="Enter your question here...")
|
| 54 |
+
send_button = gr.Button("Send")
|
| 55 |
|
| 56 |
+
examples=[
|
| 57 |
+
["How did the Leaning Tower of Pisa start leaning?"],
|
| 58 |
+
["Comment la tour de Pise a-t-elle commencé à pencher ?"],
|
| 59 |
+
["Who built the Colosseum?"],
|
| 60 |
+
["Qui a construit le Colisée ?"],
|
| 61 |
+
["What caused the fall of the Roman Empire?"],
|
| 62 |
+
["Quelles sont les causes de la chute de l'Empire romain ?"],
|
| 63 |
+
["When did World War II begin and end?"],
|
| 64 |
+
["Quand la Seconde Guerre mondiale a-t-elle commencé et terminé ?"],
|
| 65 |
+
["What was the significance of the Magna Carta?"],
|
| 66 |
+
["Quelle est l'importance de la Magna Carta ?"],
|
| 67 |
+
["Who was the first person to step on the moon?"],
|
| 68 |
+
["Qui était la première personne à marcher sur la lune?"]
|
| 69 |
+
]
|
| 70 |
+
|
| 71 |
+
send_button.click(
|
| 72 |
+
fn=generate_reply,
|
| 73 |
+
inputs=[user_input, state],
|
| 74 |
+
outputs=[chatbot, user_input],
|
| 75 |
)
|
| 76 |
|
| 77 |
+
reset_button = gr.Button("New Conversation")
|
| 78 |
+
reset_button.click(lambda: [], outputs=[state])
|
| 79 |
|
| 80 |
if __name__ == "__main__":
|
| 81 |
+
interface.launch(share=True)
|
| 82 |
+
|