Skip to content

Commit 5f8f3b5

Browse files
pushpit kambojpushpit kamboj
authored andcommitted
[feature] shipping v3 of vtxlabs with improved research logic, reranking and chunking strategy, moved to langfuse, deploy at hostinger
1 parent 247bca7 commit 5f8f3b5

80 files changed

Lines changed: 4174 additions & 4944 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ R2_BUCKET=""
1111

1212
# LangGraph → Manim worker
1313
MANIM_WORKER_URL=""
14+
MANIM_WORKER_POLL_SECONDS="5"
15+
MANIM_WORKER_MAX_WAIT_SECONDS="900"
16+
PUBLIC_MEDIA_BASE_URL=""
1417

1518
# Chroma / RAG
19+
SEMANTIC_CACHE_ENABLED="false"
1620
CHROMA_OPENAI_API_KEY="" # can be same as OPENAI_API_KEY
21+
CHROMA_OPENAI_EMBEDDING_MODEL="text-embedding-3-small"
1722
CHROMA_API_KEY=""
23+
CHROMA_HOST="api.trychroma.com"
1824
CHROMA_TENANT=""
19-
CHROMA_DATABASE=""
25+
CHROMA_DATABASE=""
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy AnimAI to Hostinger
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out repository
14+
uses: actions/checkout@v5
15+
16+
- name: Deploy to Hostinger
17+
uses: hostinger/deploy-action@v1
18+
with:
19+
api-key: ${{ secrets.HOSTINGER_API_KEY }}
20+
virtual-machine: ${{ vars.HOSTINGER_VM_ID }}
21+
project-name: animai
22+
docker-compose-path: docker-compose.hostinger.yml
23+
environment-variables: |
24+
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
25+
SEMANTIC_CACHE_ENABLED=${{ vars.SEMANTIC_CACHE_ENABLED }}
26+
CHROMA_OPENAI_API_KEY=${{ secrets.CHROMA_OPENAI_API_KEY }}
27+
CHROMA_OPENAI_EMBEDDING_MODEL=${{ vars.CHROMA_OPENAI_EMBEDDING_MODEL }}
28+
CHROMA_API_KEY=${{ secrets.CHROMA_API_KEY }}
29+
CHROMA_HOST=${{ vars.CHROMA_HOST }}
30+
CHROMA_TENANT=${{ vars.CHROMA_TENANT }}
31+
CHROMA_DATABASE=${{ vars.CHROMA_DATABASE }}
32+
R2_ACCOUNT_ID=${{ secrets.R2_ACCOUNT_ID }}
33+
R2_ACCESS_KEY_ID=${{ secrets.R2_ACCESS_KEY_ID }}
34+
R2_SECRET_ACCESS_KEY=${{ secrets.R2_SECRET_ACCESS_KEY }}
35+
R2_BUCKET=${{ vars.R2_BUCKET }}
36+
R2_PUBLIC_BASE_URL=${{ vars.R2_PUBLIC_BASE_URL }}
37+
SKIP_UPLOAD=${{ vars.SKIP_UPLOAD }}
38+
PUBLIC_MEDIA_BASE_URL=${{ vars.PUBLIC_MEDIA_BASE_URL }}
39+
LANGFUSE_PUBLIC_KEY=${{ secrets.LANGFUSE_PUBLIC_KEY }}
40+
LANGFUSE_SECRET_KEY=${{ secrets.LANGFUSE_SECRET_KEY }}
41+
LANGFUSE_BASE_URL=${{ vars.LANGFUSE_BASE_URL }}
42+
LANGFUSE_HOST=${{ vars.LANGFUSE_HOST }}
43+
LANGFUSE_TIMEOUT=${{ vars.LANGFUSE_TIMEOUT }}
44+
LANGFUSE_FLUSH_AT=${{ vars.LANGFUSE_FLUSH_AT }}
45+
LANGFUSE_FLUSH_INTERVAL=${{ vars.LANGFUSE_FLUSH_INTERVAL }}
46+
LANGFUSE_TRACING_ENVIRONMENT=${{ vars.LANGFUSE_TRACING_ENVIRONMENT }}
47+
LANGFUSE_AUTH_CHECK_ON_STARTUP=${{ vars.LANGFUSE_AUTH_CHECK_ON_STARTUP }}
48+
MANIM_RENDER_TIMEOUT_SECONDS=${{ vars.MANIM_RENDER_TIMEOUT_SECONDS }}
49+
MANIM_QUALITY_FLAG=${{ vars.MANIM_QUALITY_FLAG }}
50+
KEEP_RENDER_ARTIFACTS=${{ vars.KEEP_RENDER_ARTIFACTS }}

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ============================================
44

55
.PHONY: all format lint test tests test_watch integration_tests docker_tests help extended_tests
6-
.PHONY: install dev docker-build docker-run docker-stop deploy logs health clean
6+
.PHONY: install dev worker-dev compose-up compose-down docker-build docker-run docker-stop deploy logs health clean
77

88
# Configuration
99
PROJECT_ID := anim-482714
@@ -36,6 +36,18 @@ dev:
3636
@echo "$(GREEN)Starting local development server...$(NC)"
3737
PYTHONPATH=src uvicorn src.api.main:app --reload --host 0.0.0.0 --port 8000
3838

39+
worker-dev:
40+
@echo "$(GREEN)Starting manim-worker locally...$(NC)"
41+
uvicorn app:app --app-dir manim-worker --reload --host 0.0.0.0 --port 8080
42+
43+
compose-up:
44+
@echo "$(GREEN)Starting API + manim-worker with Docker Compose...$(NC)"
45+
docker compose up --build
46+
47+
compose-down:
48+
@echo "$(YELLOW)Stopping Docker Compose stack...$(NC)"
49+
docker compose down
50+
3951
dev-port:
4052
@echo "$(GREEN)Starting on port $(PORT)...$(NC)"
4153
PYTHONPATH=src uvicorn src.api.main:app --reload --host 0.0.0.0 --port $(PORT)
@@ -244,6 +256,8 @@ help:
244256
@echo '$(YELLOW)Local Development:$(NC)'
245257
@echo ' make install - Install Python dependencies'
246258
@echo ' make dev - Run API locally with hot-reload'
259+
@echo ' make worker-dev - Run manim-worker locally with hot-reload'
260+
@echo ' make compose-up - Run API and worker together via Docker Compose'
247261
@echo ''
248262
@echo '$(YELLOW)Docker:$(NC)'
249263
@echo ' make docker-build - Build Docker image'
@@ -281,4 +295,3 @@ help:
281295
@echo '$(YELLOW)Cleanup:$(NC)'
282296
@echo ' make clean - Clean local artifacts'
283297
@echo ' make clean-all - Clean everything including Docker'
284-

README.md

Lines changed: 71 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- Top-level decorative header and architecture image -->
21
<p align="center">
32
<a href="https://github.com/pushpitkamboj/AnimAI">
43
<img src="https://raw.githubusercontent.com/pushpitkamboj/AnimAI/main/arch_image.png" alt="Architecture" width="900"/>
@@ -12,196 +11,117 @@
1211
<a href="https://github.com/pushpitkamboj/AnimAI/blob/main/LICENSE"><img src="https://img.shields.io/github/license/pushpitkamboj/AnimAI" alt="license"/></a>
1312
</p>
1413

15-
# AnimAI — manim-app
14+
# AnimAI
1615

17-
An opinionated Manim-based animation generator that converts natural language prompts into Manim scenes using LangChain/LangGraph agents, a RAG index and optional HTTP API.
16+
AnimAI converts natural-language prompts into Manim videos.
1817

19-
> Beautiful, reproducible animations—driven by LLMs + retrieval.
18+
The active backend is a small server-side pipeline:
2019

21-
## Table of contents
20+
`POST /run` -> `src/api/main.py` -> `src/agent/graph.py` -> `src/agent/execute_code.py` -> `manim-worker/app.py`
2221

23-
- [Project summary](#project-summary)
24-
- [Architecture](#architecture)
25-
- [Technologies used](#technologies-used)
26-
- [Deployment options](#deployment-options)
27-
- [1) Langsmith / LangGraph](#1-deploy-through-langsmith--langgraph)
28-
- [2) Self-host (FastAPI)](#2-self-host-fastapi)
29-
- [Quickstart (local)](#quickstart-local)
30-
- [Codebase overview](#codebase-overview)
31-
- [Examples](#examples)
32-
- [Troubleshooting & tips](#troubleshooting--tips)
33-
- [Contributing](#contributing)
34-
- [License](#license)
22+
The API plans and generates Manim code, submits it to a dedicated render worker, polls every 5 seconds for job status, and returns a public video URL on success.
3523

36-
## Project summary
24+
## Current Architecture
3725

38-
The app translates user prompts into Manim commands via an LLM-backed agent and RAG index, then renders animations with Manim. It is designed to be run as a local service (FastAPI) or deployed via LangGraph/Langsmith flows.
26+
- `src/api/main.py`
27+
FastAPI entrypoint with language normalization, semantic cache lookup, Langfuse tracing, and the `/run` + `/health` endpoints.
28+
- `src/agent/graph.py`
29+
Active LangGraph workflow for prompt classification, grounding, planning, retrieval, generation, execution, and recovery.
30+
- `src/agent/execute_code.py`
31+
Submit-and-poll client for the render worker.
32+
- `manim-worker/app.py`
33+
Dedicated Manim execution service with `/jobs` and `/jobs/{job_id}`.
34+
- `src/rag/`
35+
Retrieval stack and supporting chunks for Manim-aware grounding.
36+
- `src/manim_docs/`
37+
Manim reference material used for retrieval/indexing.
3938

40-
## Architecture
39+
## Legacy Code
4140

42-
- Agent layer — LangChain / LangGraph agent composes, enhances and executes prompts. See `src/agent/`.
43-
- Retrieval (RAG) — document chunking and vector indexing in `src/rag/` to make Manim commands and docs searchable.
44-
- API — optional FastAPI endpoint at `src/api/main.py` (commented by default; see Self-host section).
45-
- Renderer — Manim scenes and helpers live under `src/manim_docs/` and are used to produce final video assets.
46-
- Storage / delivery — produced videos are uploaded (example: Cloudflare R2) and returned as URLs by the API.
41+
The repository still keeps the fine-tune graph experiments under:
4742

48-
High-level flow
49-
1. User sends a natural language prompt to the agent.
50-
2. Agent enhances the prompt and issues RAG queries to the vector store.
51-
3. Agent produces a Manim script or workflow; rendering is performed by a worker running Manim.
52-
4. Rendered video is stored and the API returns a shareable URL or status.
43+
- `src/agent/graph_fine_tune.py`
44+
- `src/agent/generate_code_fine_tune.py`
45+
- `src/agent/regenerate_code_fine_tune.py`
46+
- `src/agent/fine_tune_agent/`
5347

54-
## NOTE- the code written in fe folder is not source of truth, the production frontend code is here - https://github.com/AnshBansalOfficial/v0-anim-ai
55-
## Technologies used
48+
These files are legacy experimental pipelines. They are not part of the active production request flow and are kept only as reference material.
5649

57-
- Python 3.10+
58-
- Manim library (rendering)
59-
- LangChain / langchain_core (agent logic)
60-
- LangGraph (workflow orchestration)
61-
- Langsmith (for tracing & deployment)
62-
- FastAPI (optional REST endpoint)
63-
- Chroma or other vector store (RAG)
64-
- Cloudflare R2
65-
- e2b code interpreter for sandboxing the code execution
50+
## Frontend Note
6651

67-
Key files: `pyproject.toml`, `src/agent/`, `src/rag/`, `src/api/main.py`.
52+
The code in `src/fe/` is not the source of truth for production frontend work.
6853

69-
## Deployment options
54+
Production frontend repo:
55+
`https://github.com/AnshBansalOfficial/v0-anim-ai`
7056

71-
### 1) Deploy through Langsmith / LangGraph
57+
## Local Development
7258

73-
- Use LangGraph to publish the workflow/graph; Langsmith can be used for tracing and CI-based deployments.
74-
- Steps (high level):
75-
1. Get `LANGSMITH_API_KEY` and set it in your CI or environment.
76-
2. Confirm `langgraph.json` or your graph module is up to date.
77-
3. Use platform-specific CLI/CI to publish the graph (CI should set `LANGSMITH_API_KEY` as secret and may set `LANGSMITH_TRACING=true`).
78-
79-
See `langraph/project_langraph_platform/pyproject.toml` for compatible package versions used in examples.
80-
81-
### 2) Self-host (FastAPI)
82-
83-
This project contains a commented FastAPI entrypoint at `src/api/main.py` (marked "MIGRATED TO LANGGRAPH API FOR DEPLOYEMENT"). To enable self-hosting:
84-
85-
1. Open `manimation/manim-app/src/api/main.py` and uncomment the FastAPI app code. The endpoints provided are `/run` (POST) and `/health` (GET).
86-
2. Ensure dependencies are installed (see Quickstart below).
87-
3. Run the app from the `manim-app` root:
59+
### Docker
8860

8961
```bash
90-
python -m uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --reload
62+
docker compose up --build
9163
```
9264

93-
The `/run` endpoint expects `{ "prompt": "..." }` and will return a `result` (a `video_url` on success) and `status`.
94-
95-
Production notes: ensure `PYTHONPATH` includes the project root or use package-style imports. Replace permissive CORS with specific origins. Consider running the renderer as a background worker or container for heavier workloads.
65+
This starts:
9666

97-
## Quickstart (local)
67+
- API on `http://localhost:8000`
68+
- Manim worker on `http://localhost:8080`
9869

99-
1. Clone and change directory
70+
### Direct API run
10071

10172
```bash
102-
git clone https://github.com/pushpitkamboj/AnimAI
103-
cd manimation/manim-app
104-
```
105-
106-
2. Create and activate a venv
107-
108-
```bash
109-
python -m venv .venv
110-
source .venv/bin/activate
111-
```
112-
113-
3. Install dependencies
114-
115-
```bash
116-
pip install -e .
117-
# or: poetry install
118-
```
119-
120-
4. Environment variables (example)
121-
122-
```bash
123-
export OPENAI_API_KEY=sk-...
124-
export LANGSMITH_API_KEY=lsv2_...
125-
export LANGSMITH_TRACING=true
73+
python -m uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --reload
12674
```
12775

128-
5. Run unit tests
76+
If you run the API directly, you should also run the worker separately:
12977

13078
```bash
131-
pytest -q
79+
uvicorn app:app --app-dir manim-worker --host 0.0.0.0 --port 8080 --reload
13280
```
13381

134-
6. Start the optional API (if uncommented)
82+
## Request Example
13583

13684
```bash
137-
python -m uvicorn src.api.main:app --reload
85+
curl -X POST http://localhost:8000/run \
86+
-H 'Content-Type: application/json' \
87+
-d '{"prompt":"2 squares rotating","language":"en"}'
13888
```
13989

140-
## Codebase overview
141-
142-
- `src/agent/` — agent code and prompt enhancement (`enhance_prompt.py`).
143-
- `src/rag/` — chunking and indexing utilities for RAG.
144-
- `src/api/main.py` — optional FastAPI endpoint (commented by default).
145-
- `src/manim_docs/` — Manim helper modules and example scene code.
146-
- `pyproject.toml` — dependencies and packaging metadata.
147-
- `langgraph.json` — LangGraph workflow definition used for deployments.
148-
- `tests/` — unit and integration tests.
149-
150-
## Examples
151-
152-
1) Call the API (if self-hosted)
153-
154-
POST /run
155-
156-
Request body:
157-
158-
```json
159-
{ "prompt": "Animate a circle turning into a square" }
160-
```
161-
162-
Response (success):
90+
Example response:
16391

16492
```json
165-
{ "result": "https://.../generated_video.mp4", "status": "success" }
93+
{"result":"https://.../scene.mp4","status":"success"}
16694
```
16795

168-
2) Run a quick local render (example developer flow)
96+
## Environment
97+
98+
Common environment variables:
99+
100+
- `OPENAI_API_KEY`
101+
- `MANIM_WORKER_URL`
102+
- `CHROMA_API_KEY`
103+
- `CHROMA_DATABASE`
104+
- `CHROMA_TENANT`
105+
- `R2_ACCOUNT_ID`
106+
- `R2_ACCESS_KEY_ID`
107+
- `R2_SECRET_ACCESS_KEY`
108+
- `R2_BUCKET`
109+
- `R2_PUBLIC_BASE_URL`
110+
- `LANGFUSE_PUBLIC_KEY`
111+
- `LANGFUSE_SECRET_KEY`
112+
- `LANGFUSE_BASE_URL` or `LANGFUSE_HOST`
113+
- `LANGFUSE_TIMEOUT` optional, defaults to `15` in this app
114+
- `LANGFUSE_FLUSH_AT` optional, defaults to `64` in this app
115+
- `LANGFUSE_FLUSH_INTERVAL` optional, defaults to `2` in this app
116+
- `LANGFUSE_TRACING_ENVIRONMENT` optional, e.g. `development`
117+
- `LANGFUSE_AUTH_CHECK_ON_STARTUP` optional, set to `true` for a startup connectivity check
118+
119+
## Testing
169120

170121
```bash
171-
# Create a prompt payload and POST to /run, or call the agent runner directly from a script
172-
python -c "from src.agent.enhance_prompt import enhance; print(enhance('Make a bouncing ball'))"
122+
pytest -q
173123
```
174124

175-
## Troubleshooting & tips
176-
177-
- Rendering slow? Use a dedicated worker or scale compute for Manim tasks. Reduce resolution for testing.
178-
- Langsmith tracing failing? Confirm `LANGSMITH_API_KEY` and `LANGSMITH_TRACING=true`.
179-
- Import errors after enabling API? Ensure you run from repo root and `PYTHONPATH` includes project root or run with `python -m uvicorn src.api.main:app`.
180-
181-
## Contributing
182-
183-
Contributions are welcome! Typical workflow:
184-
185-
1. Fork the repo
186-
2. Create a feature branch
187-
3. Add tests and documentation
188-
4. Open a pull request
189-
190-
Please follow pep8 formatting and add unit tests for new features.
191-
192125
## License
193126

194-
This project includes a `LICENSE` file in the repository root. Review it for licensing details.
195-
196-
---
197-
198-
If you'd like I can also:
199-
200-
- add a `docker-compose.yml` for local testing (worker + API + vector DB),
201-
- create a `quickstart.md` with screenshots and sample prompts, or
202-
- pin dependency versions and add `requirements-dev.txt`.
203-
204-
## Special thanks
205-
206-
Special thanks to the Manim community for their beautiful documentation, examples, and continuous support — their work greatly inspired this project. See the official docs: https://docs.manim.community/en/stable/index.html
207-
Note: Manim library and Manim Community edition are different, refer manim community docs for more details.
127+
See [LICENSE](/Users/pushpitkamboj/PersonalProjects/AnimAI/LICENSE).

arch_image.png

-82.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)