Spaces:
Sleeping
Sleeping
Download app.py from HandsomeSyed/claude-like-coder: direct link, hf CLI and curl.
- Browser
- Download file 607 Bytes
-
https://huggingface.co/spaces/HandsomeSyed/claude-like-coder/resolve/main/app.py
- Command line
-
hf download hf://spaces/HandsomeSyed/claude-like-coder/app.py
-
curl -L -o app.py https://huggingface.co/spaces/HandsomeSyed/claude-like-coder/resolve/main/app.py
607 Bytes
| import gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| model_name = "Qwen/Qwen2.5-Coder-7B-Instruct" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_name, | |
| device_map="auto", | |
| torch_dtype="auto", | |
| trust_remote_code=True | |
| ) | |
| def chat(message, history): | |
| inputs = tokenizer(message, return_tensors="pt") | |
| output = model.generate(**inputs, max_new_tokens=300) | |
| reply = tokenizer.decode(output[0], skip_special_tokens=True) | |
| return reply | |
| gr.ChatInterface(fn=chat).launch() |