redjkh commited on
Commit
2f493e7
·
verified ·
1 Parent(s): 52f0687

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -1,12 +1,22 @@
1
  import gradio as gr
2
  import random as r
 
3
 
 
4
 
5
- def randomly(message, history):
6
- responses = ["Yes Queen!", "No...", "I'm unsure", "I will kill you", "definitely", "perhaps", "idk about that one...", "wouldn't you like to know", "100%", "in no universe"]
7
- return r.choice(responses)
 
 
8
 
9
- print("Hello World")
 
 
 
10
 
11
- chatbot = gr.ChatInterface(randomly, type = "messages", title="truth bot")
 
 
 
12
  chatbot.launch()
 
1
  import gradio as gr
2
  import random as r
3
+ from huggingface_hub import InferenceClient
4
 
5
+ client = InferenceClient("microsoft/phi-4")
6
 
7
+ def respond(message, history):
8
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
9
+ if history:
10
+ messages.extend(history)
11
+ messages.append({"role": "user", "content": message})
12
 
13
+ response = client.chat_completion(
14
+ messages,
15
+ max_tokens=100
16
+ )
17
 
18
+ return response['choices'][0]['message']['content'].strip()
19
+
20
+
21
+ chatbot = gr.ChatInterface(respond, type = "messages", title="truth bot")
22
  chatbot.launch()