Spaces:
Build error
Build error
Commit ·
af105a4
1
Parent(s): 7744e2a
Update app.py
Browse files12345678910111213141516171819from huggingface_hub import InferenceClientimport gradio as grclient = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")def format_prompt(message, history):prompt = "<s>"with open('Manuale.txt', 'r') as file:manual_content = file.read()prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande ***INIZIO_MANUALE***: [/INST] {manual_content} [INST] ***FINE_MANUALE***[/INST]"for user_prompt, bot_response in history:prompt += f"[INST] {user_prompt} [/INST]"prompt += f" {bot_response}</s> "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]"return promptdef generate(prompt, history, temperature=0.2, max_new_tokens=300, top_p=0.95, repetition_penalty=1.0,):123456789101112131415161718192021222324252627282930313233343536373839404142from huggingface_hub import InferenceClientimport gradio as grimport requestsclient = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")manual_url = "https://script.google.com/macros/s/AKfycbwwJL_2bqJ4OVuYBYITKHg5VEE9fFPMx816ErNpuhhRlsNPAwNSd0WrNvN_Y_g77XjN/exec"manual_content = Nonedef get_manual_content():global manual_contentresponse = requests.get(manual_url)if response.status_code == 200:manual_content = response.textdef format_prompt(message, history):global manual_contentif manual_content is None:get_manual_content()prompt = "<s>"if manual_content:prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande ***INIZIO_MANUALE***: [/INST] {manual_content} [INST] ***FINE_MANUALE***[/INST]"for user_prompt, bot_response in history:prompt += f"[INST] {user_prompt} [/INST]"prompt += f" {bot_response}</s> "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]"return prompt#def format_prompt(message, history):# prompt = "<s>"# with open('Manuale.txt', 'r') as file:# manual_content = file.read()# prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande ***INIZIO_MANUALE***: [/INST] {manual_content} [INST] ***FINE_MANUALE***[/INST]"# for user_prompt, bot_response in history:# prompt += f"[INST] {user_prompt} [/INST]"# prompt += f" {bot_response}</s> "# 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]"# return promptdef generate(prompt, history, temperature=0.2, max_new_tokens=300, top_p=0.95, repetition_penalty=1.0,):
app.py+27-4