Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
@@ -13,13 +16,16 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 13 |
|
| 14 |
prompt += f"User: {message}\nAssistant:"
|
| 15 |
|
| 16 |
-
|
| 17 |
prompt,
|
| 18 |
max_new_tokens=max_tokens,
|
| 19 |
temperature=temperature,
|
| 20 |
top_p=top_p,
|
|
|
|
| 21 |
)
|
| 22 |
|
|
|
|
|
|
|
| 23 |
|
| 24 |
chatbot = gr.ChatInterface(
|
| 25 |
respond,
|
|
@@ -34,5 +40,4 @@ chatbot = gr.ChatInterface(
|
|
| 34 |
|
| 35 |
demo = chatbot
|
| 36 |
|
| 37 |
-
|
| 38 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
pipe = pipeline(
|
| 5 |
+
"text-generation",
|
| 6 |
+
model="Simon0900/personalized-fitness-coach-JSON"
|
| 7 |
+
)
|
| 8 |
|
| 9 |
|
| 10 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
|
|
| 16 |
|
| 17 |
prompt += f"User: {message}\nAssistant:"
|
| 18 |
|
| 19 |
+
result = pipe(
|
| 20 |
prompt,
|
| 21 |
max_new_tokens=max_tokens,
|
| 22 |
temperature=temperature,
|
| 23 |
top_p=top_p,
|
| 24 |
+
do_sample=True
|
| 25 |
)
|
| 26 |
|
| 27 |
+
return result[0]["generated_text"][len(prompt):]
|
| 28 |
+
|
| 29 |
|
| 30 |
chatbot = gr.ChatInterface(
|
| 31 |
respond,
|
|
|
|
| 40 |
|
| 41 |
demo = chatbot
|
| 42 |
|
| 43 |
+
demo.launch()
|
|
|