CJDA commited on
Commit
df63ba5
·
verified ·
1 Parent(s): 1c03860

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -1,13 +1,23 @@
1
  import gradio as gr
2
- import random
3
 
4
- def respond_yes_no_randomly(message, history):
5
- responses = ["Yes", "No"]
6
- return random.choice(responses)
 
 
 
 
 
 
 
 
 
 
7
 
8
  print("Hello,world!")
9
 
10
- chatbot = gr.ChatInterface(respond_yes_no_randomly, type = "messages", title = "Answer Machine") #chatbot UI - conversation history and user input
11
 
12
  chatbot.launch()
13
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("microsoft/phi-4")
5
+
6
+ def respond(message, history):
7
+ messages({"role": "system", "content": "You are a friendly chatbot."})
8
+ if history:
9
+ messages.extend(history)
10
+
11
+ messages.append({"role":,"user","content": message})
12
+ response = client.chat_completion(
13
+ messages,
14
+ max_tokens=100
15
+ )
16
+ return response['choices'][0]['message']['content'].strip()
17
 
18
  print("Hello,world!")
19
 
20
+ chatbot = gr.ChatInterface(respond, type = "messages", title = "Answer Machine") #chatbot UI - conversation history and user input
21
 
22
  chatbot.launch()
23