File size: 1,296 Bytes
ef37daa
711f069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e1ff28f
69a5dec
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
import gradio as gr
import os
from huggingface_hub import InferenceClient

# Read API key from environment variable
hf_token = os.getenv("hf_token")

# Initialize InferenceClient with the token from the environment
client = InferenceClient(api_key=hf_token)

# Function to get responses from the model
def get_response(user_input):
    messages = [
        { "role": "system", "content": "you are xylaria 1.4 senoa, developed by sk md saad amin" },
        { "role": "user", "content": user_input }
    ]
    
    stream = client.chat.completions.create(
        model="Qwen/QwQ-32B-Preview", 
        messages=messages, 
        temperature=0.5,
        max_tokens=10240,
        top_p=0.7,
        stream=True
    )
    
    response = ""
    for chunk in stream:
        response += chunk.choices[0].delta.content
    return response

# Set up the Gradio interface
iface = gr.Interface(
    fn=get_response, 
    inputs=gr.Textbox(label="Your message", placeholder="Type your message here..."), 
    outputs=gr.Textbox(label="Response", interactive=False),
    title="Xylaria 1.4 Senoa Chatbot",
    description="A chatbot powered by Xylaria 1.4 Senoa, developed by Sk Md Saad Amin."
)

# Launch the interface
iface.launch()

gr.load("models/Qwen/QwQ-32B-Preview").launch()