Spaces:
Sleeping
Sleeping
Update app.py
Browse files82 unmodified lines83848586878889909184 unmodified lines17617717817918018118218318418518618718818919082 unmodified linesclient_gemma = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")client_mixtral = InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO")client_llama = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")func_caller = []# Define the main chat functiondef respond(message, history):84 unmodified linesbuffer += new_textyield bufferelse:messages = f"<|start_header_id|>system\nYou are OpenCHAT mini a helpful assistant made by KingNish. You answers users query like human friend. You are also Expert in every field and also learn and try to answer from contexts related to previous question. Try your best to give best response possible to user. You also try to show emotions using Emojis and reply like human, use short forms, friendly tone and emotions.<|end_header_id|>"for msg in history:messages += f"\n<|start_header_id|>user\n{str(msg[0])}<|end_header_id|>"messages += f"\n<|start_header_id|>assistant\n{str(msg[1])}<|end_header_id|>"messages+=f"\n<|start_header_id|>user\n{message_text}<|end_header_id|>\n<|start_header_id|>assistant\n"stream = client_llama.text_generation(messages, max_new_tokens=2000, do_sample=True, stream=True, details=True, return_full_text=False)output = ""for response in stream:if not response.token.text == "<|eot_id|>":output += response.token.textyield outputexcept:82 unmodified lines8384858687888984 unmodified lines17417517617717817918018118218318418518618718882 unmodified linesclient_gemma = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")client_mixtral = InferenceClient("NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO")client_llama = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct")client_yi = InferenceClient("01-ai/Yi-1.5-34B-Chat")# Define the main chat functiondef respond(message, history):84 unmodified linesbuffer += new_textyield bufferelse:messages = f"<|im_start|>system\nYou are OpenCHAT mini a helpful assistant made by KingNish. You answers users query like human friend. You are also Expert in every field and also learn and try to answer from contexts related to previous question. Try your best to give best response possible to user. You also try to show emotions using Emojis and reply like human, use short forms, friendly tone and emotions.<|im_end|>"for msg in history:messages += f"\n<|im_start|>user\n{str(msg[0])}<|im_end|>"messages += f"\n<|im_start|>assistant\n{str(msg[1])}<|im_end|>"messages+=f"\n<|im_start|>user\n{message_text}<|im_end|>\n<|im_start|>assistant\n"stream = client_yi.text_generation(messages, max_new_tokens=2000, do_sample=True, stream=True, details=True, return_full_text=False)output = ""for response in stream:if not response.token.text == "<|endoftext|>":output += response.token.textyield outputexcept:
app.py+7-9