Spaces:
Runtime error
Runtime error
| import os | |
| from huggingface_hub import | |
| InferenceClient | |
| client = InferenceClient( | |
| model="Qwen/Qwen2.5-7B-Instruct", | |
| token=os.getenv("HF_TOKEN") | |
| ) | |
| def respond(message, history): | |
| messages = [{"role": "system", "content": "you are a friendly chatbot"}] | |
| if history: | |
| messages.extend(history) | |
| message.append({"role":"user", "content": message}) | |
| response = client.chat_completion ( | |
| messages, | |
| max_tokens=100 | |
| ) | |
| return random.choices[0].messages.content.strip() | |
| chatbot = gr.ChatInerfae(respond) | |
| chatbot.launh() |