Spaces:
Sleeping
Sleeping
Commit
·
af105a4
1
Parent(s):
7744e2a
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,42 @@
|
|
1 |
from huggingface_hub import InferenceClient
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def format_prompt(message, history):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
for user_prompt, bot_response in history:
|
12 |
prompt += f"[INST] {user_prompt} [/INST]"
|
13 |
prompt += f" {bot_response}</s> "
|
14 |
prompt += f"[INST]Tu sei Zucchetti AI, il mio assistente personale di AdHoc e... io ho un problema in AdHoc, rispondi proponendo SOLO con soluzione relativa al problmea a partire dal manuale (testo tra ***INIZIO_MANUALE*** e ***FINE_MANUALE***): {message} [/INST]"
|
15 |
return prompt
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def generate(
|
18 |
prompt, history, temperature=0.2, max_new_tokens=300, top_p=0.95, repetition_penalty=1.0,
|
19 |
):
|
|
|
1 |
from huggingface_hub import InferenceClient
|
2 |
import gradio as gr
|
3 |
+
import requests
|
4 |
|
5 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
6 |
|
7 |
+
manual_url = "https://script.google.com/macros/s/AKfycbwwJL_2bqJ4OVuYBYITKHg5VEE9fFPMx816ErNpuhhRlsNPAwNSd0WrNvN_Y_g77XjN/exec"
|
8 |
+
manual_content = None
|
9 |
+
|
10 |
+
def get_manual_content():
|
11 |
+
global manual_content
|
12 |
+
response = requests.get(manual_url)
|
13 |
+
if response.status_code == 200:
|
14 |
+
manual_content = response.text
|
15 |
+
|
16 |
def format_prompt(message, history):
|
17 |
+
global manual_content
|
18 |
+
if manual_content is None:
|
19 |
+
get_manual_content()
|
20 |
+
prompt = "<s>"
|
21 |
+
if manual_content:
|
22 |
+
prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande ***INIZIO_MANUALE***: [/INST] {manual_content} [INST] ***FINE_MANUALE***[/INST]"
|
23 |
for user_prompt, bot_response in history:
|
24 |
prompt += f"[INST] {user_prompt} [/INST]"
|
25 |
prompt += f" {bot_response}</s> "
|
26 |
prompt += f"[INST]Tu sei Zucchetti AI, il mio assistente personale di AdHoc e... io ho un problema in AdHoc, rispondi proponendo SOLO con soluzione relativa al problmea a partire dal manuale (testo tra ***INIZIO_MANUALE*** e ***FINE_MANUALE***): {message} [/INST]"
|
27 |
return prompt
|
28 |
|
29 |
+
#def format_prompt(message, history):
|
30 |
+
# prompt = "<s>"
|
31 |
+
# with open('Manuale.txt', 'r') as file:
|
32 |
+
# manual_content = file.read()
|
33 |
+
# prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande ***INIZIO_MANUALE***: [/INST] {manual_content} [INST] ***FINE_MANUALE***[/INST]"
|
34 |
+
# for user_prompt, bot_response in history:
|
35 |
+
# prompt += f"[INST] {user_prompt} [/INST]"
|
36 |
+
# prompt += f" {bot_response}</s> "
|
37 |
+
# prompt += f"[INST]Tu sei Zucchetti AI, il mio assistente personale di AdHoc e... io ho un problema in AdHoc, rispondi proponendo SOLO con soluzione relativa al problmea a partire dal manuale (testo tra ***INIZIO_MANUALE*** e ***FINE_MANUALE***): {message} [/INST]"
|
38 |
+
# return prompt
|
39 |
+
|
40 |
def generate(
|
41 |
prompt, history, temperature=0.2, max_new_tokens=300, top_p=0.95, repetition_penalty=1.0,
|
42 |
):
|