{"repo": "alchosyn/anti-fraud-agent", "files": {"deploy/docker-compose.prod.yml": {"2e508809b384f8602be55dc398e93095711adc08": {"t": 1785745252.7590451, "n": 2018, "h": "a1cd980fd0f01bc1", "c": "# 生产编排:nginx(80/443) → app → db/redis,仅 nginx 对外\n#\n# 在仓库根目录执行:\n# docker compose -f deploy/docker-compose.prod.yml up -d --build\n# 前置步骤见 deploy/DEPLOY.md(前端构建、域名、证书)\n\nname: anti-fraud-agent-prod\n\nservices:\n db:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: app\n POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}\n POSTGRES_DB: antifraud\n volumes:\n - pgdata:/var/lib/postgresql/data\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U app -d antifraud\"]\n interval: 5s\n timeout: 3s\n retries: 10\n restart: always\n\n redis:\n image: redis:7-alpine\n command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru\n volumes:\n - redisdata:/data\n healthcheck:\n test: [\"CMD\", \"redis-cli\", \"ping\"]\n interval: 5s\n timeout: 3s\n retries: 10\n restart: always\n\n app:\n build:\n context: ..\n # 国内服务器构建提速:\n # args:\n # HF_ENDPOINT: https://hf-mirror.com\n # PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple\n env_file:\n - ../.env # DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n environment:\n DATABASE_URL: postgresql+asyncpg://app:${POSTGRES_PASSWORD:?set in .env}@db:5432/antifraud\n REDIS_URL: redis://redis:6379/0\n JWT_SECRET: ${JWT_SECRET:?generate one: openssl rand -hex 32}\n depends_on:\n db:\n condition: service_healthy\n redis:\n condition: service_healthy\n restart: always\n # 不对外发布端口,只经 nginx\n\n nginx:\n image: nginx:1.27-alpine\n ports:\n - \"80:80\"\n - \"443:443\"\n volumes:\n # nginx.live.conf 由 DEPLOY.md 步骤从 nginx.bootstrap.conf / nginx.conf 生成(gitignore)\n - ./nginx.live.conf:/etc/nginx/conf.d/default.conf:ro\n - ../frontend/dist:/usr/share/nginx/html:ro\n - letsencrypt:/etc/letsencrypt:ro\n - certbot-webroot:/var/www/certbot\n depends_on:\n - app\n restart: always\n\nvolumes:\n pgdata:\n redisdata:\n letsencrypt:\n certbot-webroot:\n"}, "ef20677e254e393818619d9a375b5b1eafd52d65": {"t": 1785749275.9285111, "n": 2018, "h": "a1cd980fd0f01bc1", "c": "# 生产编排:nginx(80/443) → app → db/redis,仅 nginx 对外\n#\n# 在仓库根目录执行:\n# docker compose -f deploy/docker-compose.prod.yml up -d --build\n# 前置步骤见 deploy/DEPLOY.md(前端构建、域名、证书)\n\nname: anti-fraud-agent-prod\n\nservices:\n db:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: app\n POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}\n POSTGRES_DB: antifraud\n volumes:\n - pgdata:/var/lib/postgresql/data\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U app -d antifraud\"]\n interval: 5s\n timeout: 3s\n retries: 10\n restart: always\n\n redis:\n image: redis:7-alpine\n command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru\n volumes:\n - redisdata:/data\n healthcheck:\n test: [\"CMD\", \"redis-cli\", \"ping\"]\n interval: 5s\n timeout: 3s\n retries: 10\n restart: always\n\n app:\n build:\n context: ..\n # 国内服务器构建提速:\n # args:\n # HF_ENDPOINT: https://hf-mirror.com\n # PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple\n env_file:\n - ../.env # DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n environment:\n DATABASE_URL: postgresql+asyncpg://app:${POSTGRES_PASSWORD:?set in .env}@db:5432/antifraud\n REDIS_URL: redis://redis:6379/0\n JWT_SECRET: ${JWT_SECRET:?generate one: openssl rand -hex 32}\n depends_on:\n db:\n condition: service_healthy\n redis:\n condition: service_healthy\n restart: always\n # 不对外发布端口,只经 nginx\n\n nginx:\n image: nginx:1.27-alpine\n ports:\n - \"80:80\"\n - \"443:443\"\n volumes:\n # nginx.live.conf 由 DEPLOY.md 步骤从 nginx.bootstrap.conf / nginx.conf 生成(gitignore)\n - ./nginx.live.conf:/etc/nginx/conf.d/default.conf:ro\n - ../frontend/dist:/usr/share/nginx/html:ro\n - letsencrypt:/etc/letsencrypt:ro\n - certbot-webroot:/var/www/certbot\n depends_on:\n - app\n restart: always\n\nvolumes:\n pgdata:\n redisdata:\n letsencrypt:\n certbot-webroot:\n"}}, "notebooks/NPC_agent.ipynb": {"2e508809b384f8602be55dc398e93095711adc08": {"t": 1785745497.4008956, "n": 4233, "h": "3e76fad48feae87d", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {\n \"id\": \"intro\"\n },\n \"source\": [\n \"
\\n\",\n \"\\n\",\n \"# NPC Dialogue AI Agent —— 信噪\\n\",\n \"\\n\",\n \"所有逻辑已经拆到 `src/npc_agent/` 包里。这个 notebook 只负责拉代码、装依赖、注入 API key、跑对话循环。\\n\",\n \"\\n\",\n \"想看实现细节请直接打开 [src/npc_agent/](https://github.com/alchosyn/npc-dialogue-ai-agent/tree/main/src/npc_agent) 下的源文件。\"\n ],\n \"id\": \"intro\"\n },\n {\n \"cell_type\": \"code\",\n \"source\": [\n \"!python scripts/clear_history.py\"\n ],\n \"metadata\": {\n \"id\": \"seN_6DbVGiL0\",\n \"outputId\": \"afddb23d-76a7-485a-c72f-174f9a150577\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"id\": \"seN_6DbVGiL0\",\n \"execution_count\": 5,\n \"outputs\": [\n {\n \"output_type\": \"stream\",\n \"name\": \"stdout\",\n \"text\": [\n \"已清除旧存档\\n\"\n ]\n }\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {\n \"id\": \"setup\",\n \"outputId\": \"2ab82ca5-f360-4867-f2f0-7676a6569869\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"outputs\": [\n {\n \"output_type\": \"stream\",\n \"name\": \"stdout\",\n \"text\": [\n \"Already up to date.\\n\",\n \"/content/npc-dialogue-ai-agent\\n\"\n ]\n }\n ],\n \"source\": [\n \"# 1. 拉代码 + 装依赖(重复运行不会重复克隆)\\n\",\n \"import os\\n\",\n \"\\n\",\n \"REPO_DIR = \\\"/content/npc-dialogue-ai-agent\\\"\\n\",\n \"\\n\",\n \"if not os.path.exists(REPO_DIR):\\n\",\n \" !git clone https://github.com/alchosyn/npc-dialogue-ai-agent.git {REPO_DIR}\\n\",\n \"else:\\n\",\n \" !cd {REPO_DIR} && git pull --ff-only\\n\",\n \"\\n\",\n \"%cd {REPO_DIR}\\n\",\n \"!pip install -q -r requirements.txt\"\n ],\n \"id\": \"setup\"\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 3,\n \"metadata\": {\n \"id\": \"secrets\"\n },\n \"outputs\": [],\n \"source\": [\n \"# 2. 从 Colab Secrets 读 API key 注入环境变量\\n\",\n \"# 左边栏 钥匙 图标里要先添加 DEEPSEEK_API_KEY 和 TAVILY_API_KEY\\n\",\n \"import os\\n\",\n \"from google.colab import userdata\\n\",\n \"\\n\",\n \"os.environ[\\\"DEEPSEEK_API_KEY\\\"] = userdata.get(\\\"DEEPSEEK_API_KEY\\\")\\n\",\n \"os.environ[\\\"TAVILY_API_KEY\\\"] = userdata.get(\\\"TAVILY_API_KEY\\\")\"\n ],\n \"id\": \"secrets\"\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {\n \"id\": \"chat\",\n \"outputId\": \"962655d8-ef05-4961-a7aa-25b25ba98907\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"你:信噪,我摊上事儿了\\n\",\n \"信噪:又来一遍?你刚问完\\\"银行卡洗钱\\\"的事。别慌,告诉你怎么办了没?\\n\",\n \"你:说让我把钱打到他们账户上\\n\",\n \"信噪:这是最明显不过的冒充公检法诈骗。你现在还有机会止损。 第一,一分钱都别转。第二,马上打96110报备。第三,打银行客服或者去柜台冻结你的卡。 别犹豫了,骗子不会等你。快去。\\n\",\n \"你:quit\\n\"\n ]\n }\n ],\n \"source\": [\n \"# 3. 跑对话循环。输入 quit 结束。\\n\",\n \"import sys\\n\",\n \"sys.path.insert(0, \\\"src\\\")\\n\",\n \"\\n\",\n \"from npc_agent import run_chat_loop\\n\",\n \"run_chat_loop()\"\n ],\n \"id\": \"chat\"\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {\n \"id\": \"extras\"\n },\n \"source\": [\n \"## 其他维护操作\\n\",\n \"\\n\",\n \"- 清空对话存档:`!python scripts/clear_history.py`\\n\",\n \"- 查看最近一条 trace:`!python scripts/inspect_traces.py`\\n\",\n \"- 查看所有 trace:`!python scripts/list_traces.py`\"\n ],\n \"id\": \"extras\"\n }\n ],\n \"metadata\": {\n \"colab\": {\n \"provenance\": []\n },\n \"kernelspec\": {\n \"display_name\": \"Python 3\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"name\": \"python\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 5\n}"}, "2d88de9d7150d55f4bf0a022d41a2b37f5e66903": {"t": 1785749276.5788538, "n": 4233, "h": "3e76fad48feae87d", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {\n \"id\": \"intro\"\n },\n \"source\": [\n \"
\\n\",\n \"\\n\",\n \"# NPC Dialogue AI Agent —— 信噪\\n\",\n \"\\n\",\n \"所有逻辑已经拆到 `src/npc_agent/` 包里。这个 notebook 只负责拉代码、装依赖、注入 API key、跑对话循环。\\n\",\n \"\\n\",\n \"想看实现细节请直接打开 [src/npc_agent/](https://github.com/alchosyn/npc-dialogue-ai-agent/tree/main/src/npc_agent) 下的源文件。\"\n ],\n \"id\": \"intro\"\n },\n {\n \"cell_type\": \"code\",\n \"source\": [\n \"!python scripts/clear_history.py\"\n ],\n \"metadata\": {\n \"id\": \"seN_6DbVGiL0\",\n \"outputId\": \"afddb23d-76a7-485a-c72f-174f9a150577\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"id\": \"seN_6DbVGiL0\",\n \"execution_count\": 5,\n \"outputs\": [\n {\n \"output_type\": \"stream\",\n \"name\": \"stdout\",\n \"text\": [\n \"已清除旧存档\\n\"\n ]\n }\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 2,\n \"metadata\": {\n \"id\": \"setup\",\n \"outputId\": \"2ab82ca5-f360-4867-f2f0-7676a6569869\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"outputs\": [\n {\n \"output_type\": \"stream\",\n \"name\": \"stdout\",\n \"text\": [\n \"Already up to date.\\n\",\n \"/content/npc-dialogue-ai-agent\\n\"\n ]\n }\n ],\n \"source\": [\n \"# 1. 拉代码 + 装依赖(重复运行不会重复克隆)\\n\",\n \"import os\\n\",\n \"\\n\",\n \"REPO_DIR = \\\"/content/npc-dialogue-ai-agent\\\"\\n\",\n \"\\n\",\n \"if not os.path.exists(REPO_DIR):\\n\",\n \" !git clone https://github.com/alchosyn/npc-dialogue-ai-agent.git {REPO_DIR}\\n\",\n \"else:\\n\",\n \" !cd {REPO_DIR} && git pull --ff-only\\n\",\n \"\\n\",\n \"%cd {REPO_DIR}\\n\",\n \"!pip install -q -r requirements.txt\"\n ],\n \"id\": \"setup\"\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 3,\n \"metadata\": {\n \"id\": \"secrets\"\n },\n \"outputs\": [],\n \"source\": [\n \"# 2. 从 Colab Secrets 读 API key 注入环境变量\\n\",\n \"# 左边栏 钥匙 图标里要先添加 DEEPSEEK_API_KEY 和 TAVILY_API_KEY\\n\",\n \"import os\\n\",\n \"from google.colab import userdata\\n\",\n \"\\n\",\n \"os.environ[\\\"DEEPSEEK_API_KEY\\\"] = userdata.get(\\\"DEEPSEEK_API_KEY\\\")\\n\",\n \"os.environ[\\\"TAVILY_API_KEY\\\"] = userdata.get(\\\"TAVILY_API_KEY\\\")\"\n ],\n \"id\": \"secrets\"\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 4,\n \"metadata\": {\n \"id\": \"chat\",\n \"outputId\": \"962655d8-ef05-4961-a7aa-25b25ba98907\",\n \"colab\": {\n \"base_uri\": \"https://localhost:8080/\"\n }\n },\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"你:信噪,我摊上事儿了\\n\",\n \"信噪:又来一遍?你刚问完\\\"银行卡洗钱\\\"的事。别慌,告诉你怎么办了没?\\n\",\n \"你:说让我把钱打到他们账户上\\n\",\n \"信噪:这是最明显不过的冒充公检法诈骗。你现在还有机会止损。 第一,一分钱都别转。第二,马上打96110报备。第三,打银行客服或者去柜台冻结你的卡。 别犹豫了,骗子不会等你。快去。\\n\",\n \"你:quit\\n\"\n ]\n }\n ],\n \"source\": [\n \"# 3. 跑对话循环。输入 quit 结束。\\n\",\n \"import sys\\n\",\n \"sys.path.insert(0, \\\"src\\\")\\n\",\n \"\\n\",\n \"from npc_agent import run_chat_loop\\n\",\n \"run_chat_loop()\"\n ],\n \"id\": \"chat\"\n },\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {\n \"id\": \"extras\"\n },\n \"source\": [\n \"## 其他维护操作\\n\",\n \"\\n\",\n \"- 清空对话存档:`!python scripts/clear_history.py`\\n\",\n \"- 查看最近一条 trace:`!python scripts/inspect_traces.py`\\n\",\n \"- 查看所有 trace:`!python scripts/list_traces.py`\"\n ],\n \"id\": \"extras\"\n }\n ],\n \"metadata\": {\n \"colab\": {\n \"provenance\": []\n },\n \"kernelspec\": {\n \"display_name\": \"Python 3\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"name\": \"python\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 5\n}"}}, "docker-compose.yml": {"2e508809b384f8602be55dc398e93095711adc08": {"t": 1785746977.5259006, "n": 1714, "h": "e44d303eac79f9a9", "c": "# 本地/演示环境编排:app + PostgreSQL + Redis\n#\n# 用法:\n# 1. .env 里准备 DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n# 2. docker compose up -d --build\n# 3. http://localhost:8000/docs 看 API;前端另起:cd frontend && npm run dev\n#\n# 生产部署(Nginx + HTTPS)见 deploy/docker-compose.prod.yml 与 deploy/DEPLOY.md\n\nname: anti-fraud-agent\n\nservices:\n db:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: app\n POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-apppass-dev}\n POSTGRES_DB: antifraud\n volumes:\n - pgdata:/var/lib/postgresql/data\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U app -d antifraud\"]\n interval: 5s\n timeout: 3s\n retries: 10\n # 本机调试需要直连数据库时再打开:\n # ports:\n # - \"5432:5432\"\n\n redis:\n image: redis:7-alpine\n command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru\n volumes:\n - redisdata:/data\n healthcheck:\n test: [\"CMD\", \"redis-cli\", \"ping\"]\n interval: 5s\n timeout: 3s\n retries: 10\n\n app:\n build:\n context: .\n # 国内网络打开下面两行:\n # args:\n # HF_ENDPOINT: https://hf-mirror.com\n # PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple\n env_file:\n - .env # DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n environment:\n DATABASE_URL: postgresql+asyncpg://app:${POSTGRES_PASSWORD:-apppass-dev}@db:5432/antifraud\n REDIS_URL: redis://redis:6379/0\n JWT_SECRET: ${JWT_SECRET:-dev-secret-change-in-production}\n ports:\n - \"8000:8000\"\n depends_on:\n db:\n condition: service_healthy\n redis:\n condition: service_healthy\n restart: unless-stopped\n\nvolumes:\n pgdata:\n redisdata:\n"}, "ef20677e254e393818619d9a375b5b1eafd52d65": {"t": 1785749275.972308, "n": 1714, "h": "e44d303eac79f9a9", "c": "# 本地/演示环境编排:app + PostgreSQL + Redis\n#\n# 用法:\n# 1. .env 里准备 DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n# 2. docker compose up -d --build\n# 3. http://localhost:8000/docs 看 API;前端另起:cd frontend && npm run dev\n#\n# 生产部署(Nginx + HTTPS)见 deploy/docker-compose.prod.yml 与 deploy/DEPLOY.md\n\nname: anti-fraud-agent\n\nservices:\n db:\n image: postgres:16-alpine\n environment:\n POSTGRES_USER: app\n POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-apppass-dev}\n POSTGRES_DB: antifraud\n volumes:\n - pgdata:/var/lib/postgresql/data\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U app -d antifraud\"]\n interval: 5s\n timeout: 3s\n retries: 10\n # 本机调试需要直连数据库时再打开:\n # ports:\n # - \"5432:5432\"\n\n redis:\n image: redis:7-alpine\n command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru\n volumes:\n - redisdata:/data\n healthcheck:\n test: [\"CMD\", \"redis-cli\", \"ping\"]\n interval: 5s\n timeout: 3s\n retries: 10\n\n app:\n build:\n context: .\n # 国内网络打开下面两行:\n # args:\n # HF_ENDPOINT: https://hf-mirror.com\n # PIP_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple\n env_file:\n - .env # DEEPSEEK_API_KEY / TAVILY_API_KEY / OPENAI_API_KEY\n environment:\n DATABASE_URL: postgresql+asyncpg://app:${POSTGRES_PASSWORD:-apppass-dev}@db:5432/antifraud\n REDIS_URL: redis://redis:6379/0\n JWT_SECRET: ${JWT_SECRET:-dev-secret-change-in-production}\n ports:\n - \"8000:8000\"\n depends_on:\n db:\n condition: service_healthy\n redis:\n condition: service_healthy\n restart: unless-stopped\n\nvolumes:\n pgdata:\n redisdata:\n"}}}}