Spaces:
Sleeping
Sleeping
Download app.py from keita-origin/Test: direct link, hf CLI and curl.
- Browser
- Download file 598 Bytes
-
https://huggingface.co/spaces/keita-origin/Test/resolve/main/app.py
- Command line
-
hf download hf://spaces/keita-origin/Test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/keita-origin/Test/resolve/main/app.py
598 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # モデルの読み込み | |
| generator = pipeline("text-generation", model="keita-origin/Da-1.1b") | |
| # チャット履歴を保持する関数 | |
| def chatbot(message, history): | |
| history.append((message, "")) | |
| response = generator(message, max_length=100)[0]["generated_text"] | |
| history[-1] = (message, response) | |
| return history | |
| # ChatGPT 風のインターフェース | |
| chatbot_ui = gr.ChatInterface( | |
| chatbot, | |
| title="AI Chatbot", | |
| description="Hugging Face のモデルを使った対話型 AI", | |
| ) | |
| # 実行 | |
| chatbot_ui.launch() |