Spaces:
Sleeping
Sleeping
Commit ·
af105a4
1
Parent(s): 7744e2a
Update app.py
Browse files12345678910111213141516789101718192021222324252627282930313233343536373839404142from huggingface_hub import InferenceClientimport gradio as grimport requests
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
manual_url = "https://script.google.com/macros/s/AKfycbwwJL_2bqJ4OVuYBYITKHg5VEE9fFPMx816ErNpuhhRlsNPAwNSd0WrNvN_Y_g77XjN/exec"manual_content = None
def get_manual_content(): global manual_content response = requests.get(manual_url) if response.status_code == 200: manual_content = response.text
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]" global manual_content if 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 prompt
def generate( prompt, history, temperature=0.2, max_new_tokens=300, top_p=0.95, repetition_penalty=1.0,):app.py+27-4