TEST / app.py
Reality123b's picture
Update app.py
711f069 verified
raw
history blame
1.3 kB
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()