Extensible RLM agent framework with video understanding
Project description
Sanjaya
Sanjaya is a Python library for building evidence-first RLM (Recursive Language Model) agents.
It runs a loop where the model writes Python, executes it in a sandboxed REPL, inspects results, calls tools, and iterates until it can return a grounded answer.
Why the name?
In the Mahabharata, Sanjaya narrates events to a blind king with "divine sight." This project follows the same idea: observe evidence and report what happened.
Install
pip install sanjaya
With extras:
pip install "sanjaya[video]" # video analysis
pip install "sanjaya[image]" # image analysis (Pillow, HEIC, SVG)
pip install "sanjaya[document]" # PDF/EPUB/PPTX/Markdown/text parsing
pip install "sanjaya[tracing]" # tracing integrations
pip install "sanjaya[all]" # everything
Configuration
Set at least:
OPENROUTER_API_KEY
Optional (depends on your model/provider setup):
OPENAI_API_KEYMOONDREAM_API_KEYLOGFIRE_TOKEN
Quick start
from sanjaya import Agent
agent = Agent(max_iterations=8)
answer = agent.ask("What is the capital of France?")
print(answer.text)
Video analysis
from sanjaya import Agent
agent = Agent(max_iterations=12)
answer = agent.ask(
"How many people are speaking and what are they discussing?",
video="/path/to/video.mp4",
# subtitle="/path/to/subtitle.json", # optional
)
print(answer.text)
print(answer.evidence)
When video=... is provided, VideoToolkit is auto-registered if you have not already added one.
Document analysis
from sanjaya import Agent
agent = Agent(max_iterations=12)
answer = agent.ask(
"Summarize the key claims and supporting evidence.",
document=["/path/to/report.pdf", "/path/to/appendix.md"],
)
print(answer.text)
print(answer.evidence)
Supported document types include .pdf, .epub, .pptx/.ppt, .md, and .txt.
When document=... is provided, DocumentToolkit is auto-registered if needed.
Image analysis
from sanjaya import Agent
agent = Agent(max_iterations=10)
answer = agent.ask(
"What text is visible in this screenshot?",
image="/path/to/screenshot.png",
)
print(answer.text)
print(answer.evidence)
Multiple images:
answer = agent.ask(
"Compare these two charts and summarize differences.",
image=["/path/to/chart_q1.png", "/path/to/chart_q2.png"],
)
Supported formats: JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC (requires sanjaya[image]), SVG (requires sanjaya[image]).
When image=... is provided, ImageToolkit is auto-registered if needed.
Custom tools
from sanjaya import Agent, Toolkit, tool
class MyToolkit(Toolkit):
@tool
def lookup(self, query: str) -> str:
return f"result for: {query}"
agent = Agent().use(MyToolkit())
answer = agent.ask("Find the latest status update")
print(answer.text)
Answer object
Agent.ask() returns an Answer object with:
textevidenceiterationsinput_tokens,output_tokens,cost_usdwall_time_s
Development (repo)
If you are working from the repository:
just dev— API + UIjust api— FastAPI backend (:8000)just ui— Next.js frontend (:5100)just demo— run demo prompts
Status
Sanjaya is actively developed. Core video + document flows are working, and evaluation/dashboard tooling is still evolving.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanjaya-0.2.1.tar.gz.
File metadata
- Download URL: sanjaya-0.2.1.tar.gz
- Upload date:
- Size: 96.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68ca6557f988f66d6208fe0984f7cca5e41dc2a285d6935ae65bb99501a94dd0
|
|
| MD5 |
5b2ee1f852fd2d27d2f7f42f4d3503f3
|
|
| BLAKE2b-256 |
ad6402c7195f91ad06d6134dfc5c081af7b60bde3c5bf473e197d4ff87de43ab
|
File details
Details for the file sanjaya-0.2.1-py3-none-any.whl.
File metadata
- Download URL: sanjaya-0.2.1-py3-none-any.whl
- Upload date:
- Size: 99.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46525eea000dee41f16e4540fe90d0be95ae60515e50b53d74eb1a8ee3c7e290
|
|
| MD5 |
58ec0438fa9113615015b0e33b024d84
|
|
| BLAKE2b-256 |
a7b712321502422d33f75e6cf0d0f072fc16160f500335b5c3fb7c5ccf9063f8
|