Преглед изворни кода

feat(langgraph): scaffold Python sidecar project

- pyproject.toml with FastAPI, LangChain, LangGraph, ChromaDB deps
- FastAPI app skeleton with /health endpoint
- Dockerfile, .env.example, .gitignore
- Fix root .gitignore *.py exclusion for cfc-langgraph/
iwt пре 2 месеци
родитељ
комит
7563afba0c

+ 26 - 0
cfc-langgraph/.env.example

@@ -0,0 +1,26 @@
+# LLM
+LLM_API_KEY=sk-your-key
+LLM_BASE_URL=https://api.deepseek.com/v1
+LLM_MODEL=deepseek-chat
+
+# Embedding
+EMBEDDING_API_KEY=${LLM_API_KEY}
+EMBEDDING_BASE_URL=https://api.deepseek.com/v1
+EMBEDDING_MODEL=text-embedding-v3
+
+# Java Backend
+JAVA_BASE_URL=http://localhost:9082
+JAVA_CONTEXT_URL=${JAVA_BASE_URL}/api/ai/context
+
+# LangSmith (optional)
+LANGCHAIN_TRACING_V2=false
+LANGCHAIN_API_KEY=
+LANGCHAIN_PROJECT=cfc-langgraph
+
+# Service
+SERVICE_HOST=0.0.0.0
+SERVICE_PORT=9000
+LOG_LEVEL=info
+
+# Chroma
+CHROMA_DB_PATH=./data/chroma_db

+ 11 - 0
cfc-langgraph/.gitignore

@@ -0,0 +1,11 @@
+__pycache__/
+*.py[cod]
+.env
+data/
+*.egg-info/
+dist/
+.ruff_cache/
+.pytest_cache/
+
+# Un-ignore .py files (root .gitignore has *.py)
+!*.py

+ 13 - 0
cfc-langgraph/Dockerfile

@@ -0,0 +1,13 @@
+FROM python:3.11-slim
+
+WORKDIR /app
+
+COPY pyproject.toml .
+RUN pip install --no-cache-dir -e .
+
+COPY app/ app/
+COPY data/ data/ 2>/dev/null || true
+
+EXPOSE 9000
+
+CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "9000"]

+ 0 - 0
cfc-langgraph/app/__init__.py


+ 0 - 0
cfc-langgraph/app/api/__init__.py


+ 8 - 0
cfc-langgraph/app/api/health.py

@@ -0,0 +1,8 @@
+from fastapi import APIRouter
+
+router = APIRouter(tags=["health"])
+
+
+@router.get("/health")
+async def health():
+    return {"status": "ok"}

+ 16 - 0
cfc-langgraph/app/main.py

@@ -0,0 +1,16 @@
+from fastapi import FastAPI
+from app.api import health
+
+app = FastAPI(title="cfc-langgraph", version="0.1.0")
+
+app.include_router(health.router)
+
+
+@app.on_event("startup")
+async def startup():
+    pass  # 后续 Phase 在此初始化 RAG / Agent
+
+
+@app.on_event("shutdown")
+async def shutdown():
+    pass  # 后续 Phase 在此清理资源

+ 33 - 0
cfc-langgraph/pyproject.toml

@@ -0,0 +1,33 @@
+[project]
+name = "cfc-langgraph"
+version = "0.1.0"
+description = "cfc AI sidecar service with LangGraph"
+requires-python = ">=3.11"
+dependencies = [
+    "fastapi>=0.115",
+    "uvicorn[standard]>=0.34",
+    "pydantic>=2.10",
+    "pydantic-settings>=2.7",
+    "httpx>=0.28",
+    "langchain>=0.3",
+    "langchain-community>=0.3",
+    "langchain-openai>=0.3",
+    "langgraph>=0.3",
+    "chromadb>=0.6",
+    "langchain-chroma>=0.2",
+    "python-multipart>=0.0.20",
+]
+
+[project.optional-dependencies]
+dev = [
+    "pytest>=8",
+    "pytest-asyncio>=0.25",
+    "ruff>=0.8",
+    "httpx",
+]
+
+[tool.ruff]
+target-version = "py311"
+line-length = 100
+select = ["E", "F", "I", "N", "W"]
+ignore = ["E501"]