trishat commited on
Commit
6ff0b22
·
verified ·
1 Parent(s): 5d101d3

Added AI model

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,9 +1,23 @@
1
  import gradio as gr
2
  import random
 
 
 
3
 
4
  def random_response(message, history):
5
- response_options = ["Without a doubt","Outlook not so good", "As I see it, yes","Most likely","Ask again later","It is certain", "Cannot predict now", "My sources say no"]
6
- return random.choice(response_options)
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  chatbot = gr.ChatInterface(random_response, title = "Random Magic 8-ball Chatbot")
9
 
 
1
  import gradio as gr
2
  import random
3
+ import huggingface_hub import InferenceClient
4
+
5
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
6
 
7
  def random_response(message, history):
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_toxens = 100
18
+ )
19
+
20
+ return response.choices[0].message.content.strip()
21
 
22
  chatbot = gr.ChatInterface(random_response, title = "Random Magic 8-ball Chatbot")
23