File size: 939 Bytes
5526ddd
31e97db
5526ddd
 
b9b741a
 
02148b2
51237a3
5b9f800
31e97db
 
 
 
646af15
2663344
31e97db
 
 
ede7b94
 
 
 
 
7dc6219
1f38246
51237a3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()