shaneli1020 commited on
Commit
b227aa5
·
verified ·
1 Parent(s): d2914c2

Created a new chatbot - RAG

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