mounseflit commited on
Commit
4b8a4a6
·
verified ·
1 Parent(s): 5d785fc

Create test.py

Browse files
Files changed (1) hide show
  1. test.py +21 -0
test.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+
4
+ client = InferenceClient("mounseflit/falcon-7b-marrakech-v2")
5
+
6
+ def predict(message, history):
7
+ history = history or []
8
+ history.append(message)
9
+ response = client.text_generation(text=" ".join(history), max_length=200, do_sample=True, top_k=10, num_return_sequences=1, temperature=0.1)[0]['generated_text']
10
+ history.append(response)
11
+ response = response.replace(" ".join(history[:-1]), "")
12
+ return response, history
13
+
14
+ with gr.Blocks() as demo:
15
+ chatbot = gr.Chatbot()
16
+ message = gr.Textbox(placeholder="Enter your message here")
17
+ state = gr.State()
18
+ submit = gr.Button("SEND")
19
+ submit.click(predict, inputs=[message, state], outputs=[chatbot, state])
20
+
21
+ demo.launch()