use pydantic
All checks were successful
Build and Push Agent Docker Image / build (push) Successful in 2m10s
Build and Push Web Docker Image / build (push) Successful in 3m33s

This commit is contained in:
2025-12-13 01:39:31 +01:00
parent bad9a4e547
commit 79fc89a7f4
8 changed files with 1459 additions and 609 deletions

View File

@@ -1,17 +1,16 @@
# Cavepedia Web
Next.js frontend with integrated LangGraph agent for Cavepedia.
Next.js frontend with integrated PydanticAI agent for Cavepedia.
## Project Structure
```
web/
├── src/ # Next.js application
├── agent/ # LangGraph agent (Python)
│ ├── main.py # Agent graph definition
│ ├── langgraph.json
── pyproject.toml
│ └── Dockerfile # Production container
├── agent/ # PydanticAI agent (Python)
│ ├── main.py # Agent definition
│ ├── server.py # FastAPI server with AG-UI
── pyproject.toml
└── ...
```
@@ -20,7 +19,7 @@ web/
- Node.js 24+
- Python 3.13
- npm
- Google AI API Key (for the LangGraph agent)
- Google AI API Key (for the PydanticAI agent)
## Development
@@ -46,77 +45,37 @@ cp agent/.env.example agent/.env
npm run dev
```
This starts both the Next.js UI and LangGraph agent servers concurrently.
This starts both the Next.js UI and PydanticAI agent servers concurrently.
## Agent Deployment
The agent is containerized for production deployment.
The agent can be containerized for production deployment.
### Building the Docker image
### Environment Variables
```bash
cd agent
docker build -t cavepediav2-agent .
```
| Variable | Required | Description |
|----------|----------|-------------|
| `GOOGLE_API_KEY` | Yes | Google AI API key for Gemini |
### Running in production
The agent requires PostgreSQL and Valkey for persistence and pub/sub:
```bash
docker run \
-p 8123:8000 \
-e REDIS_URI="redis://valkey:6379" \
-e DATABASE_URI="postgres://user:pass@postgres:5432/langgraph" \
-e GOOGLE_API_KEY="your-key" \
-e LANGSMITH_API_KEY="your-key" \
cavepediav2-agent
cd agent
uv run uvicorn server:app --host 0.0.0.0 --port 8000
```
Or use Docker Compose with the required services:
```yaml
services:
valkey:
image: valkey/valkey:9
postgres:
image: postgres:16
environment:
POSTGRES_DB: langgraph
POSTGRES_USER: langgraph
POSTGRES_PASSWORD: langgraph
agent:
image: git.seaturtle.pw/cavepedia/cavepediav2-agent:latest
ports:
- "8123:8000"
environment:
REDIS_URI: redis://valkey:6379
DATABASE_URI: postgres://langgraph:langgraph@postgres:5432/langgraph
GOOGLE_API_KEY: ${GOOGLE_API_KEY}
depends_on:
- valkey
- postgres
```
### CI/CD
The agent image is automatically built and pushed to `git.seaturtle.pw/cavepedia/cavepediav2-agent:latest` on push to `main` via Gitea Actions.
## Web Deployment
### Environment Variables
| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `LANGGRAPH_DEPLOYMENT_URL` | Yes | `http://localhost:8000` | URL to the LangGraph agent |
| `LANGGRAPH_DEPLOYMENT_URL` | Yes | `http://localhost:8000` | URL to the agent |
| `AUTH0_SECRET` | Yes | - | Session encryption key (`openssl rand -hex 32`) |
| `AUTH0_DOMAIN` | Yes | - | Auth0 tenant domain |
| `AUTH0_CLIENT_ID` | Yes | - | Auth0 application client ID |
| `AUTH0_CLIENT_SECRET` | Yes | - | Auth0 application client secret |
| `APP_BASE_URL` | Yes | - | Public URL of the app |
| `LANGSMITH_API_KEY` | No | - | LangSmith API key for tracing |
### Docker Compose (Full Stack)
@@ -139,29 +98,14 @@ services:
agent:
image: git.seaturtle.pw/cavepedia/cavepediav2-agent:latest
environment:
REDIS_URI: redis://valkey:6379
DATABASE_URI: postgres://langgraph:langgraph@postgres:5432/langgraph
GOOGLE_API_KEY: ${GOOGLE_API_KEY}
depends_on:
- valkey
- postgres
valkey:
image: valkey/valkey:9
postgres:
image: postgres:16
environment:
POSTGRES_DB: langgraph
POSTGRES_USER: langgraph
POSTGRES_PASSWORD: langgraph
```
## Available Scripts
- `dev` - Start both UI and agent servers
- `dev:ui` - Start only Next.js
- `dev:agent` - Start only LangGraph agent
- `dev:agent` - Start only PydanticAI agent
- `build` - Build Next.js for production
- `start` - Start production server
- `lint` - Run ESLint
@@ -169,7 +113,7 @@ services:
## References
- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)
- [PydanticAI Documentation](https://ai.pydantic.dev/)
- [CopilotKit Documentation](https://docs.copilotkit.ai)
- [Next.js Documentation](https://nextjs.org/docs)
- [Auth0 Next.js SDK Examples](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md)