e113anore commited on
Commit
22d72c6
·
verified ·
1 Parent(s): f8aa260

Update app.py

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