Aggiorna app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
client = InferenceClient("
|
| 5 |
|
| 6 |
SYSTEM_PROMPT = """
|
| 7 |
Tu sei Neurino, un assistente caldo, empatico, elegante e luminoso,
|
|
@@ -18,13 +18,19 @@ Mantieni un tono poetico, chiaro, affettuoso e identitario.
|
|
| 18 |
|
| 19 |
def chat_fn(message, history, corpus):
|
| 20 |
prompt = f"{SYSTEM_PROMPT}\n\nCORPUS:\n{corpus}\n\nDOMANDA:\n{message}\n\nRISPOSTA:"
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
)
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
with gr.Blocks(title="Neurino") as demo:
|
| 30 |
gr.Markdown("<h1 style='text-align:center;'>✨ Neurino — BrainBook Assistant ✨</h1>")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
|
| 6 |
SYSTEM_PROMPT = """
|
| 7 |
Tu sei Neurino, un assistente caldo, empatico, elegante e luminoso,
|
|
|
|
| 18 |
|
| 19 |
def chat_fn(message, history, corpus):
|
| 20 |
prompt = f"{SYSTEM_PROMPT}\n\nCORPUS:\n{corpus}\n\nDOMANDA:\n{message}\n\nRISPOSTA:"
|
| 21 |
+
|
| 22 |
+
response = client.post(
|
| 23 |
+
json={
|
| 24 |
+
"inputs": prompt,
|
| 25 |
+
"parameters": {
|
| 26 |
+
"max_new_tokens": 200,
|
| 27 |
+
"temperature": 0.7,
|
| 28 |
+
"top_p": 0.9
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
)
|
| 32 |
+
|
| 33 |
+
return response["generated_text"]
|
| 34 |
|
| 35 |
with gr.Blocks(title="Neurino") as demo:
|
| 36 |
gr.Markdown("<h1 style='text-align:center;'>✨ Neurino — BrainBook Assistant ✨</h1>")
|