Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,20 @@ from huggingface_hub import InferenceClient
|
|
| 3 |
import gradio as gr
|
| 4 |
import random
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
with gr.Blocks() as chatbot:
|
| 7 |
gr.Image(
|
| 8 |
value="NutriAssist Logo.png",
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
import random
|
| 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 |
+
|
| 12 |
+
messages.append({"role":"user", "content":message})
|
| 13 |
+
|
| 14 |
+
response = client.chat_completion(messages, max_tokens = 100, temperature = 1.3, top_p = 0.3) #temp & top_p control random
|
| 15 |
+
|
| 16 |
+
print(response)
|
| 17 |
+
|
| 18 |
+
return response["choices"][0]["message"]["content"].strip()
|
| 19 |
+
|
| 20 |
with gr.Blocks() as chatbot:
|
| 21 |
gr.Image(
|
| 22 |
value="NutriAssist Logo.png",
|