adding hugging face& transitioning to a generative AI model
Browse files
app.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
chatbot = gr.ChatInterface(magic_eight_ball, type = 'messages', title = 'Best Friend', description = 'Ask me your most pressing questions!', theme = 'mgetz/Celeb_Glitzy')
|
| 10 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InfrenceClient
|
| 3 |
|
| 4 |
+
client = IntferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
+
|
| 6 |
+
def respond(message,history):
|
| 7 |
+
messages = [{"role":"system","content":"You are a friendly chatbot"}]
|
| 8 |
+
|
| 9 |
+
if history:
|
| 10 |
+
messages.extend(history)
|
| 11 |
+
messages.append([{"role":"user","content": message}])
|
| 12 |
+
|
| 13 |
+
response = client.chat_completion(messages,max_tokens=100,temperature=0.2)
|
| 14 |
+
return response['choices'][0]['message']['content'].strip()
|
| 15 |
+
|
| 16 |
+
chatbot = gr.ChatInterface(respond, type = 'messages')
|
| 17 |
|
|
|
|
| 18 |
chatbot.launch()
|