From 602d551fd1c04f62068b34ec69816f11717872ce Mon Sep 17 00:00:00 2001 From: root <953994191@qq.com> Date: Thu, 16 Apr 2026 04:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 33 ++++++- .gitea/workflows/deploy.yml | 30 ++++-- .gitignore | 176 +++++------------------------------- docker/docker-compose.yml | 2 +- 4 files changed, 75 insertions(+), 166 deletions(-) diff --git a/.env.example b/.env.example index fcc7e6b..60d775b 100644 --- a/.env.example +++ b/.env.example @@ -39,4 +39,35 @@ QDRANT_COLLECTION_NAME=mem0_user_memories # 前端 API 地址(本地开发时需显式配置) # 注意:这里只需要域名和端口,不需要 /chat 路径 -API_URL=http://localhost:8083 \ No newline at end of file +API_URL=http://localhost:8083 +``` + +``` +# ============================================================================ +# AI Agent 项目环境变量配置 +# ⚠️ 重要:此文件包含敏感信息,请勿提交到版本控制系统! +# ============================================================================ + +# AI 模型 API Keys(必须配置) +ZHIPUAI_API_KEY=your_zhipu_api_key_here +DEEPSEEK_API_KEY=your_deepseek_api_key_here +LLAMACPP_API_KEY=your_llamacpp_api_key_here + +# 日志配置(可选,有默认值) +LOG_LEVEL=WARNING +DEBUG=false +ENABLE_GRAPH_TRACE=false + +# 数据库配置(可选,有默认值) +DB_URI=postgresql://postgres:mysecretpassword@db:5432/langgraph_db?sslmode=disable + +# Qdrant 配置(可选,有默认值) +QDRANT_URL=http://qdrant:6333 +QDRANT_COLLECTION_NAME=mem0_user_memories + +# llama.cpp 服务配置(可选,有默认值) +VLLM_BASE_URL=http://llamacpp:8081/v1 +VLLM_EMBEDDING_URL=http://llamacpp:8082/v1 + +# 前端 API 地址(可选,有默认值) +API_URL=http://localhost:8083 diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 7fb62b3..09dfc5e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -27,29 +27,41 @@ jobs: echo "⚠️ ZHIPUAI_API_KEY 未注入(将使用空值,智谱模型不可用)" fi - if [ -n "$VLLM_LOCAL_KEY" ]; then - echo "✅ VLLM_LOCAL_KEY 已注入(长度:${#VLLM_LOCAL_KEY})" + if [ -n "$DEEPSEEK_API_KEY" ]; then + echo "✅ DEEPSEEK_API_KEY 已注入(长度:${#DEEPSEEK_API_KEY})" else - echo "⚠️ VLLM_LOCAL_KEY 未注入(将使用空值,本地模型不可用)" + echo "⚠️ DEEPSEEK_API_KEY 未注入(将使用空值,DeepSeek模型不可用)" + fi + + if [ -n "$LLAMACPP_API_KEY" ]; then + echo "✅ LLAMACPP_API_KEY 已注入(长度:${#LLAMACPP_API_KEY})" + else + echo "⚠️ LLAMACPP_API_KEY 未注入(将使用空值,本地LLM不可用)" fi echo "" echo "💡 提示:如果看到警告,请在 Gitea 仓库 Settings → Actions → Secrets 中添加对应密钥" env: ZHIPUAI_API_KEY: ${{ secrets.ZHIPUAI_API_KEY }} - VLLM_LOCAL_KEY: ${{ secrets.VLLM_LOCAL_KEY }} + DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} + LLAMACPP_API_KEY: ${{ secrets.LLAMACPP_API_KEY }} - name: 确保基础镜像已拉取 run: | - docker pull python:3.11-slim || true - docker pull postgres:16 || true + docker pull python:3.11-slim || true + docker pull postgres:16 || true - name: 构建并启动前后端服务(环境变量注入) env: ZHIPUAI_API_KEY: ${{ secrets.ZHIPUAI_API_KEY }} - VLLM_LOCAL_KEY: ${{ secrets.VLLM_LOCAL_KEY }} + DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }} + LLAMACPP_API_KEY: ${{ secrets.LLAMACPP_API_KEY }} run: | + # 方式一:直接在命令前设置环境变量(推荐,避免导出遗漏) export DOCKER_BUILDKIT=1 + ZHIPUAI_API_KEY="$ZHIPUAI_API_KEY" \ + DEEPSEEK_API_KEY="$DEEPSEEK_API_KEY" \ + LLAMACPP_API_KEY="$LLAMACPP_API_KEY" \ docker compose -f docker/docker-compose.yml up -d --build backend frontend - name: 健康检查 @@ -57,8 +69,8 @@ jobs: echo "等待后端服务启动..." sleep 15 for i in {1..10}; do - # 使用 Docker 默认网桥网关 IP (172.17.0.1) 访问宿主机的端口映射 - if curl -f http://172.17.0.1:8001/health > /dev/null 2>&1; then + # 修正端口为 8083(与 compose 暴露端口一致) + if curl -f http://172.17.0.1:8083/health > /dev/null 2>&1; then echo "✅ 后端服务正常" exit 0 fi diff --git a/.gitignore b/.gitignore index 50ef1b7..1ce3962 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,8 @@ # ---> Python -# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class - -# C extensions *.so - -# Distribution / packaging .Python build/ develop-eggs/ @@ -21,169 +16,40 @@ parts/ sdist/ var/ wheels/ -share/python-wheels/ *.egg-info/ .installed.cfg *.egg -MANIFEST -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# UV -# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -#uv.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/latest/usage/project/#working-with-version-control -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ +# Virtual Environment venv/ +env/ ENV/ -env.bak/ -venv.bak/ +.venv -# IDE 配置 +# IDE .vscode/ .idea/ +*.swp +*.swo +*~ -# 日志和数据 +# Logs logs/ *.log + +# Environment Variables(重要:防止密钥泄露) +.env +.env.local +.env.*.local + +# Docker +docker-compose.override.yml + +# Data data/*.db data/*.sqlite -# Docker 卷数据 -pg_data/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -# Ruff stuff: -.ruff_cache/ - -# PyPI configuration file -.pypirc +# OS +.DS_Store +Thumbs.db diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3b8ab32..6f3fe25 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -60,4 +60,4 @@ networks: # ⭐ PostgreSQL 和 Qdrant 已迁移到远程服务器,不再需要本地卷 # volumes: # pg_data: -# qdrant_storage: +# qdrant_storage: \ No newline at end of file