Spaces:
Runtime error
Runtime error
before knowledge base
Browse files
app.py
CHANGED
|
@@ -4,26 +4,6 @@ import torch
|
|
| 4 |
import numpy as np
|
| 5 |
import random
|
| 6 |
from huggingface_hub import InferenceClient
|
|
|
|
| 7 |
|
| 8 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 9 |
-
|
| 10 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 11 |
-
def respond(message, history):
|
| 12 |
-
messages = [{"role": "system", "content": "You are a big sister chatbot named, Nessie. Your goal is to give users helpful information in regards to helping people feel good about their bodies and self-image. You should also be able to give advice about calories based on height and weight."}]
|
| 13 |
-
# change the personality
|
| 14 |
-
if history:
|
| 15 |
-
messages.extend(history)
|
| 16 |
-
messages.append({"role": "user", "content": message})
|
| 17 |
-
|
| 18 |
-
response = ""
|
| 19 |
-
for messages in client.chat_completion(
|
| 20 |
-
messages,
|
| 21 |
-
max_tokens = 100,
|
| 22 |
-
stream = True,
|
| 23 |
-
):
|
| 24 |
-
token = messages.choices[0].delta.content
|
| 25 |
-
response+= token
|
| 26 |
-
yield response
|
| 27 |
-
|
| 28 |
-
chatbot = gr.ChatInterface(respond, type = "messages")
|
| 29 |
-
chatbot.launch(debug=True)
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
import random
|
| 6 |
from huggingface_hub import InferenceClient
|
| 7 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", provider='hf-inference')
|
| 8 |
|
| 9 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|