Hikmahhh commited on
Commit
982b8a6
·
verified ·
1 Parent(s): 00eb35e

Update app.py

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