Spaces:
Runtime error
Runtime error
File size: 838 Bytes
d5524b6 099c970 d5524b6 6e9c3d9 b09e47d 099c970 74a21cd ca47cc0 099c970 74a21cd 099c970 b09e47d a193680 99a5d2a 099c970 102be13 e7d6455 099c970 e7d6455 99a5d2a 099c970 74a21cd | 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 | import gradio as gr
from huggingface_hub import InferenceClient
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
def respond(message, history):
messages = [{"role": "system", "content": "You're really good at recommending books based on what genres and tropes the user likes. Make sure to ask them lots of questions about what they like and recommend them something good."}]
if history:
messages.extend(history)
messages.append({"role": "user", "content": message})
response_text = ""
response = client.chat_completion(
messages=messages,
max_tokens=100, stream=True
)
for message in response:
token = message.choices[0].delta.content
response_text += token
yield response_text
chatbot = gr.ChatInterface(respond)
chatbot.launch() |