Spaces:
Sleeping
Sleeping
Download app.py from siriusdemon/chatapi: direct link, hf CLI and curl.
- Browser
- Download file 574 Bytes
-
https://huggingface.co/spaces/siriusdemon/chatapi/resolve/main/app.py
- Command line
-
hf download hf://spaces/siriusdemon/chatapi/app.py
-
curl -L -o app.py https://huggingface.co/spaces/siriusdemon/chatapi/resolve/main/app.py
574 Bytes
| import gradio as gr | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline | |
| model_id = "llm-jp/llm-jp-3-1.8b-instruct" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False) | |
| model = AutoModelForCausalLM.from_pretrained(model_id) | |
| pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) | |
| def chat(message, history=[]): | |
| prompt = message | |
| result = pipe(prompt, max_new_tokens=100, do_sample=True, temperature=0.7)[0]["generated_text"] | |
| return result | |
| gr.ChatInterface(fn=chat, title="🗣️ 日本語LLM Chatbot").launch() | |