Download app.py from ShadowTak/Bot: direct link, hf CLI and curl.
- Browser
- Download file 646 Bytes
-
https://huggingface.co/spaces/ShadowTak/Bot/resolve/main/app.py
- Command line
-
hf download hf://spaces/ShadowTak/Bot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ShadowTak/Bot/resolve/main/app.py
646 Bytes
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| # โหลดโมเดลและโทเคนไนเซอร์ | |
| model_name = "scb10x/llama-3-typhoon-v1.5-8b" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name) | |
| def ask_question(question): | |
| inputs = tokenizer(question, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_length=500) | |
| answer = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| return answer | |
| iface = gr.Interface(fn=ask_question, inputs="text", outputs="text", title="LLaMA Chatbot") | |
| iface.launch() |