nclbond commited on
Commit
3754ac4
·
verified ·
1 Parent(s): a738a52

added respond message template code

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -1,5 +1,23 @@
1
- import gradio as gr
 
 
2
 
3
- chatbot = gr.ChatInterface()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- chatbot.launch
 
 
 
1
+ import gradio as
2
+ import random
3
+ from huggingface_hub import InferenceClient
4
 
5
+ def respond(message, history):
6
+
7
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
8
+
9
+ if history:
10
+ messages.extend(history)
11
+
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens=100
17
+ )
18
+
19
+ return response.choices[0].message.content.strip()
20
 
21
+ chatbot = gr.ChatInterface(respond)
22
+
23
+ chatbot.launch()