diyapg commited on
Commit
ac839e1
·
verified ·
1 Parent(s): df42e95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,20 +1,21 @@
1
  import gradio as gr
2
  #import random #added here
3
 
4
- from huggingface_hub import InfrenceClient
5
- Client = InfrenceClient("microsoft/phi-4")
6
 
7
  def respond(message, history):
8
- messages = [{"role": "system", "content": "you are a friendly chatbox."}]
9
  if history:
10
  messages.extend(history)
11
- messages.append({"role": "user", "context":messages})
 
12
 
13
  responses = client.chat_completion(
14
  messages,
15
  max_tokens=100
16
  )
17
- return respond['choices'][0]['messages']['context'].strip()
18
 
19
 
20
  chatbot = gr.ChatInterface(respond, type="messages", title=("friendly, chatbot")) #chatbot UI - conversation history and user input
 
1
  import gradio as gr
2
  #import random #added here
3
 
4
+ from huggingface_hub import InferenceClient
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
+
12
+ messages.append({"role": "user", "context":message})
13
 
14
  responses = client.chat_completion(
15
  messages,
16
  max_tokens=100
17
  )
18
+ return response ['choices'][0]['messages']['context'].strip()
19
 
20
 
21
  chatbot = gr.ChatInterface(respond, type="messages", title=("friendly, chatbot")) #chatbot UI - conversation history and user input