Spaces:
Running on Zero
Running on Zero
| import os | |
| import gradio as gr | |
| import spaces | |
| from huggingface_hub import InferenceClient | |
| MODEL = "huihui-ai/Huihui-Qwen3.6-35B-A3B-Claude-4.7-Opus-abliterated" | |
| client = InferenceClient( | |
| api_key=os.environ["HF_TOKEN"] | |
| ) | |
| def chat(message, history): | |
| messages = [] | |
| history = history or [] | |
| for user, assistant in history: | |
| messages.append({"role": "user", "content": user}) | |
| messages.append({"role": "assistant", "content": assistant}) | |
| messages.append({"role": "user", "content": message}) | |
| response = "" | |
| stream = client.chat.completions.create( | |
| model=MODEL, | |
| messages=messages, | |
| stream=True, | |
| max_tokens=2048, | |
| ) | |
| for chunk in stream: | |
| delta = chunk.choices[0].delta.content | |
| if delta: | |
| response += delta | |
| yield response | |
| demo = gr.ChatInterface( | |
| fn=chat, | |
| title="Huihui-Qwen3.6-35B-A3B-Claude-4.7-Opus-abliterated", | |
| description="Powered by Hugging Face Inference Providers", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |