Hikmahhh commited on
Commit
37eec80
·
verified ·
1 Parent(s): 7ad90c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,23 +1,28 @@
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": message})
13
- responses = client.chat_completion(messages, max_tokens = 100)
14
-
15
- return responses['choices'][0]['message']['content'].strip()
16
 
 
 
 
 
17
 
18
- chatbot = gr.ChatInterface(responding, type="messages", title="My chat bot") #conversation history and user input(chatbot UI)
19
- chatbot.launch()
 
 
20
 
 
21
 
22
 
23
 
 
1
  import gradio as gr
2
+ import random
3
  from huggingface_hub import InferenceClient
4
 
5
+ client = InferenceClient("microsoft/phi-4") #gen model
 
 
 
 
6
 
7
+ def random_respond(message, history):
8
+ messages = [{"role": "system", "content": "You are an expert financial advisor and you are an extremely smart teacher who graduated from LSE and Oxford and you will be extremely helpful with helping young people to learn about finance by breaking down difficult terms"}]
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 = 10000
18
+ )
19
 
20
+ return response['choices'][0]['message']['content'].strip()
21
+
22
+ # responses = ["yes", "no"]
23
+ # return random.choices(responses)
24
 
25
+ demo.launch()
26
 
27
 
28