Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| #with open("knowledge.txt", "r", encoding="https://huggingface.co/spaces/MindMattersKWK/mindmatters/resolve/main/knowledge.txt") as file: | |
| #knowledge_text = file.read() | |
| client = InferenceClient("Qwen/Qwen2.5-7B-Instruct") | |
| def respond(message, history): | |
| messages = [{"role": "system", | |
| "content":"You are an emotional support chatbot. " | |
| }] | |
| if history: | |
| messages.extend(history) | |
| messages.append({"role":"user", | |
| "content":message | |
| }) | |
| response = " " | |
| for msg in client.chat_completion(messages, max_tokens = 1000, temperature = 1, top_p = 0.5, stream = True): | |
| token = msg.choices[0].delta.content | |
| response += token | |
| yield response | |
| chatbot = gr.ChatInterface(fn=respond, title = "Mind Matters", description = "_put this rn_", editable = True) | |
| chatbot.launch() |