Anripa commited on
Commit
2cd033e
·
verified ·
1 Parent(s): 26b833a

Aggiorna app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
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
- response = client.text_generation(
22
- prompt,
23
- max_new_tokens=300,
24
- temperature=0.6,
25
- top_p=0.9,
 
 
 
 
 
26
  )
27
- return response
 
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>")