Chad commited on
Commit
6092af3
·
1 Parent(s): 85f3f5b

nwfbwfbwdwddwwdwd

Browse files
Files changed (1) hide show
  1. app.py +30 -26
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=False,
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 demo:
50
- with gr.Row():
51
- chatbot = gr.Chatbot(height=450)
 
 
 
52
 
53
- chat = gr.ChatInterface(
54
- respond,
55
- chatbot=chatbot,
56
- additional_inputs=[],
57
- examples=[
58
- ["How did the Leaning Tower of Pisa start leaning?"],
59
- ["Comment la tour de Pise a-t-elle commencé à pencher ?"],
60
- ["Who built the Colosseum?"],
61
- ["Qui a construit le Colisée ?"],
62
- ["What caused the fall of the Roman Empire?"],
63
- ["Quelles sont les causes de la chute de l'Empire romain ?"],
64
- ["When did World War II begin and end?"],
65
- ["Quand la Seconde Guerre mondiale a-t-elle commencé et terminé ?"],
66
- ["What was the significance of the Magna Carta?"],
67
- ["Quelle est l'importance de la Magna Carta ?"],
68
- ["Who was the first person to step on the moon?"],
69
- ["Qui était la première personne à marcher sur la lune?"]
70
- ],
71
- cache_examples=False
72
  )
73
 
74
- clear_button = gr.Button("New/Nouvelle Conversation")
75
- clear_button.click(lambda: None, outputs=[chatbot], queue=False)
76
 
77
  if __name__ == "__main__":
78
- demo.launch(share=True)
 
 
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
+