Spaces:
Sleeping
Sleeping
File size: 802 Bytes
ef4f874 bc6935b 20859ae edb8f65 ef4f874 bc6935b 20859ae ab8c379 2fab1f8 e00a58f 2fab1f8 ef4f874 e72870b ef4f874 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import gradio as gr
import random as rand
from huggingface_hub import InferenceClient
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct") #todo: change model?
def respond(message, history):
messages = [{"role": "system",
"content": "You are a friendly chatbot."
}]
if history:
messages.extend(history)
messages.append({"role": "user",
"content": message
})
response = ""
for msg in client.chat_completion(messages, max_tokens=200, temperature=1, top_p=0.5, stream = True):
token = msg.choices[0].delta.content
response += msg
yield response
chatbot = gr.ChatInterface(fn=respond, title="Magic 8 Ball", description="Discover your fortune...", editable=True)
chatbot.launch()
|