Spaces:
Running
Running
File size: 1,715 Bytes
b4ef713 edf4acf b4ef713 edf4acf b4ef713 edf4acf b4ef713 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
## ローカルで作業時
```
uv sync
uv run python manage.py migrate
uv run python manage.py runserver
# local host 8000にアクセスしよう
# {"text": "こんにちは?"} でpostすればできる
```
config/settings.py の DEBUG は True にしておくと色々見えやすい
```
DEBUG =True
```
.env をつくって"dev-key"を入れておくとよい
```
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY", "dev-key")
```
## requirement.txt 更新するときは
```
uv pip compile pyproject.toml -o requirements.txt
```
を使うこと
## build 実行(docker)
```
docker build -t my-django-bot .
docker run -p 7860:7860 my-django-bot
```
## view とか書き換えただけの時?毎回ダウンロードいらないようです
```
docker run -p 7860:7860 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
my-django-bot
```
## 容量解放
```
# 特定のモデルだけ消すのが面倒な場合、hubフォルダごと消しても、
# 次回使う時に再ダウンロードされるだけなので安全です。
rm -rf ~/.cache/huggingface/hub/
# 使っていないイメージやコンテナを一括削除
docker system prune -a
# uv cache clean
uv cache clean
```
## huggingface に push するとき
```
uv run hf auth login
# あとはtokenとかを貼る?
git config --global credential.helper store
#トークン確認
cat ~/.cache/huggingface/token
# なんかpushできないとき
git push https://yuto0o:[email protected]/spaces/yuto0o/django-ai-chat main
# SECRET_KEY = os.environ.get("SECRET_KEY", "dev-key")の"SECRET_KEY"をリポジトリで登録しておくとよい
```
|