Spaces:
Sleeping
Sleeping
aigenterativemodel/ adding huggingface model
Browse files
app.py
CHANGED
|
@@ -1,10 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
chatbot = gr.ChatInterface(eightball, type='messages', title= "brutal opinions", description="brutally honest opinions about you", theme='shivi/calm_seafoam')
|
| 10 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 4 |
|
| 5 |
+
def respond(message,history):
|
| 6 |
+
messages = [{"role":"system","content":"Your are friend chatbot"}]
|
| 7 |
+
|
| 8 |
+
if history:
|
| 9 |
+
messages.extend(history)
|
| 10 |
+
|
| 11 |
+
messages.append({"role":"user", "content": message})
|
| 12 |
+
|
| 13 |
+
response = client.chat_completion(
|
| 14 |
+
messages,
|
| 15 |
+
max_tokens=100
|
| 16 |
+
temperature=0.2
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
return response['choices'][0]['message']['content'].strip()
|
| 20 |
+
|
| 21 |
+
chatbot = gr.ChatInterface(eightball, type='messages')
|
| 22 |
|
|
|
|
| 23 |
chatbot.launch()
|