Spaces:
Running on Zero
Running on Zero
File size: 1,062 Bytes
286dffa 4872c21 286dffa 4872c21 286dffa 4872c21 286dffa 4872c21 286dffa 4872c21 286dffa 4872c21 286dffa 4872c21 | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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"]
)
@spaces.GPU
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() |