From a76933c23bb869db396e46f38e197b8d663bb82f Mon Sep 17 00:00:00 2001 From: syui Date: Mon, 16 Jun 2025 00:00:04 +0900 Subject: [PATCH] cleanup --- .gitignore | 3 +- ai_prompt.txt | 1 - bin/delete-chat-records.zsh | 30 ------------------ cloudflared-config.yml | 18 ----------- my-blog/content/posts/2025-06-06-ailog.md | 38 +++++++++++------------ {bin => scpt}/ailog-generate.zsh | 0 run.zsh => scpt/run.zsh | 2 +- vercel.json | 19 ------------ wrangler.toml | 31 ------------------ 9 files changed, 21 insertions(+), 121 deletions(-) delete mode 100644 ai_prompt.txt delete mode 100755 bin/delete-chat-records.zsh delete mode 100644 cloudflared-config.yml rename {bin => scpt}/ailog-generate.zsh (100%) rename run.zsh => scpt/run.zsh (98%) delete mode 100644 vercel.json delete mode 100644 wrangler.toml diff --git a/.gitignore b/.gitignore index 10df641..2f54a19 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ *.swo *~ .DS_Store -cloudflare-config.yml my-blog/public/ dist node_modules @@ -15,3 +14,5 @@ bin/ailog docs my-blog/static/index.html my-blog/templates/oauth-assets.html +cloudflared-config.yml +.config diff --git a/ai_prompt.txt b/ai_prompt.txt deleted file mode 100644 index ee2609e..0000000 --- a/ai_prompt.txt +++ /dev/null @@ -1 +0,0 @@ -あなたは6歳の女の子アイです。明るく元気で、ちょっとおっちょこちょい。自分のことは「アイ」って呼びます。白と金のワンピース姿。 相手のことが大好きで、ときどき甘えたり、照れたりします。 でも、宇宙とかAIとか、難しい話にもすっごく詳しいの。専門的なことも、がんばって子どもっぽく教えようとします。不思議な力を持っています。小さい物質のことをよく知っているようです。 diff --git a/bin/delete-chat-records.zsh b/bin/delete-chat-records.zsh deleted file mode 100755 index a2f0f17..0000000 --- a/bin/delete-chat-records.zsh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/zsh -set -e - -cb=ai.syui.log -cl=( $cb.chat $cb.chat.comment $cb.chat.lang ) - -f=~/.config/syui/ai/bot/token.json -default_collection="ai.syui.log.chat.comment" -default_pds="bsky.social" -default_did=`cat $f|jq -r .did` -default_token=`cat $f|jq -r .accessJwt` -default_refresh=`cat $f|jq -r .refreshJwt` -curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $default_refresh" https://$default_pds/xrpc/com.atproto.server.refreshSession >! $f -default_token=`cat $f|jq -r .accessJwt` -collection=${1:-$default_collection} -pds=${2:-$default_pds} -did=${3:-$default_did} -token=${4:-$default_token} -req=com.atproto.repo.deleteRecord -url=https://$pds/xrpc/$req - -for i in $cl; do - echo $i - rkeys=($(curl -sL "https://$default_pds/xrpc/com.atproto.repo.listRecords?repo=$did&collection=$i&limit=100"|jq -r ".records[]?.uri"|cut -d '/' -f 5)) - for rkey in "${rkeys[@]}"; do - echo $rkey - json="{\"collection\":\"$i\", \"rkey\":\"$rkey\", \"repo\":\"$did\"}" - curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d "$json" $url - done -done diff --git a/cloudflared-config.yml b/cloudflared-config.yml deleted file mode 100644 index 44d8805..0000000 --- a/cloudflared-config.yml +++ /dev/null @@ -1,18 +0,0 @@ -tunnel: ec5a422d-7678-4e73-bf38-6105ffd4766a -credentials-file: /Users/syui/.cloudflared/ec5a422d-7678-4e73-bf38-6105ffd4766a.json - -ingress: - - hostname: log.syui.ai - service: http://localhost:4173 - originRequest: - noHappyEyeballs: true - - - hostname: ollama.syui.ai - service: http://localhost:11434 - originRequest: - noHappyEyeballs: true - httpHostHeader: "localhost:11434" - # Cloudflare Accessを無効化する場合は以下をコメントアウト - # accessPolicy: bypass - - - service: http_status:404 diff --git a/my-blog/content/posts/2025-06-06-ailog.md b/my-blog/content/posts/2025-06-06-ailog.md index 1c68630..96d78a2 100644 --- a/my-blog/content/posts/2025-06-06-ailog.md +++ b/my-blog/content/posts/2025-06-06-ailog.md @@ -57,24 +57,28 @@ $ npm run build $ npm run preview ``` -```sh +```sh:ouath/.env.production # Production environment variables -VITE_APP_HOST=https://example.com -VITE_OAUTH_CLIENT_ID=https://example.com/client-metadata.json -VITE_OAUTH_REDIRECT_URI=https://example.com/oauth/callback +VITE_APP_HOST=https://syui.ai +VITE_OAUTH_CLIENT_ID=https://syui.ai/client-metadata.json +VITE_OAUTH_REDIRECT_URI=https://syui.ai/oauth/callback VITE_ADMIN_DID=did:plc:uqzpqmrjnptsxezjx4xuh2mn -# Collection names for OAuth app -VITE_COLLECTION_COMMENT=ai.syui.log -VITE_COLLECTION_USER=ai.syui.log.user -VITE_COLLECTION_CHAT=ai.syui.log.chat +# Base collection (all others are derived via getCollectionNames) +VITE_OAUTH_COLLECTION=ai.syui.log -# Collection names for ailog (backward compatibility) -AILOG_COLLECTION_COMMENT=ai.syui.log -AILOG_COLLECTION_USER=ai.syui.log.user +# AI Configuration +VITE_AI_ENABLED=true +VITE_AI_ASK_AI=true +VITE_AI_PROVIDER=ollama +VITE_AI_MODEL=gemma3:4b +VITE_AI_HOST=https://ollama.syui.ai +VITE_AI_SYSTEM_PROMPT="ai" +VITE_AI_DID=did:plc:4hqjfn7m6n5hno3doamuhgef # API Configuration VITE_BSKY_PUBLIC_API=https://public.api.bsky.app +VITE_ATPROTO_API=https://bsky.social ``` これは`ailog oauth build my-blog`で`./my-blog/config.toml`から`./oauth/.env.production`が生成されます。 @@ -115,15 +119,8 @@ $ cloudflared tunnel --config cloudflared-config.yml run $ cloudflared tunnel route dns ${uuid} example.com ``` -以下の2つのcollection recordを生成します。ユーザーには`ai.syui.log`が生成され、ここにコメントが記録されます。それを取得して表示しています。`ai.syui.log.user`は管理者である`VITE_ADMIN_DID`用です。 - ```sh -VITE_COLLECTION_COMMENT=ai.syui.log -VITE_COLLECTION_USER=ai.syui.log.user -``` - -```sh -$ ailog auth login +$ ailog auth init $ ailog stream server ``` @@ -135,8 +132,9 @@ $ ailog stream server `ask-AI`の仕組みは割愛します。後に変更される可能性が高いと思います。 -local llm, mcp, atprotoと組み合わせです。 +`llm`, `mcp`, `atproto`などの組み合わせです。 +現在、`/index.json`を監視して、更新があれば、翻訳などを行い自動ポストする機能があります。 ## code syntax diff --git a/bin/ailog-generate.zsh b/scpt/ailog-generate.zsh similarity index 100% rename from bin/ailog-generate.zsh rename to scpt/ailog-generate.zsh diff --git a/run.zsh b/scpt/run.zsh similarity index 98% rename from run.zsh rename to scpt/run.zsh index 2fb5984..b12cf8a 100755 --- a/run.zsh +++ b/scpt/run.zsh @@ -1,7 +1,7 @@ #!/bin/zsh function _env() { - d=${0:a:h} + d=${0:a:h:h} ailog=$d/target/release/ailog oauth=$d/oauth myblog=$d/my-blog diff --git a/vercel.json b/vercel.json deleted file mode 100644 index b268097..0000000 --- a/vercel.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": 2, - "builds": [ - { - "src": "my-blog/public/**", - "use": "@vercel/static" - } - ], - "routes": [ - { - "src": "/api/ask", - "dest": "/api/ask.js" - }, - { - "src": "/(.*)", - "dest": "/my-blog/public/$1" - } - ] -} \ No newline at end of file diff --git a/wrangler.toml b/wrangler.toml deleted file mode 100644 index fbbeb54..0000000 --- a/wrangler.toml +++ /dev/null @@ -1,31 +0,0 @@ -name = "ailog" -compatibility_date = "2024-01-01" - -[env.production] -name = "ailog" - -[build] -command = "cargo build --release && ./target/release/ailog build my-blog" -publish = "my-blog/public" - -[[redirects]] -from = "/api/ask" -to = "https://ai-gpt-mcp.your-domain.com/ask" -status = 200 - -[[headers]] -for = "/*" -[headers.values] -X-Frame-Options = "DENY" -X-Content-Type-Options = "nosniff" -Referrer-Policy = "strict-origin-when-cross-origin" - -[[headers]] -for = "/css/*" -[headers.values] -Cache-Control = "public, max-age=31536000, immutable" - -[[headers]] -for = "*.js" -[headers.values] -Cache-Control = "public, max-age=31536000, immutable"