Spaces:
Paused
Paused
Download app.py from Wayed11/wheelie-brain: direct link, hf CLI and curl.
- Browser
- Download file 749 Bytes
-
https://huggingface.co/spaces/Wayed11/wheelie-brain/resolve/main/app.py
- Command line
-
hf download hf://spaces/Wayed11/wheelie-brain/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Wayed11/wheelie-brain/resolve/main/app.py
749 Bytes
| import json, spaces, torch, gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| M="Qwen/Qwen3-14B" | |
| tok=AutoTokenizer.from_pretrained(M) | |
| model=AutoModelForCausalLM.from_pretrained(M, torch_dtype=torch.bfloat16).to("cuda") | |
| def chat(messages_json, max_tokens=300): | |
| msgs=json.loads(messages_json) | |
| ids=tok.apply_chat_template(msgs, add_generation_prompt=True, enable_thinking=False, return_tensors="pt").to("cuda") | |
| out=model.generate(ids, max_new_tokens=int(max_tokens), do_sample=True, temperature=0.8, top_p=0.9) | |
| return tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True).strip() | |
| gr.Interface(chat,[gr.Textbox(),gr.Number(value=300)],gr.Textbox(),api_name="chat").queue().launch() | |