Skip to main content

The AI Application Runtime — @agent, @tool, >> chaining, any model.

Project description

Synapse — The AI Application Runtime

pip install synapse-runtime

Not a framework. Not a wrapper. The missing AI layer for your Python stack.

30-Second Demo

from synapse import agent, tool, workflow, step

@tool
def search_web(query: str) -> list[str]:
    """Search the web. Returns top results."""
    ...  # your implementation

@agent(model='gpt-4o', fallback='ollama/llama3')
async def researcher(topic: str) -> str: ...

@agent(model='claude-3-5-sonnet')
async def writer(content: str) -> str: ...

# Chain agents with >>
pipeline = researcher >> writer
result   = await pipeline.run('AI application runtimes')

That's it. No subclassing. No boilerplate. No JSON schema by hand.


The Four Primitives (v0.1)

@tool — Auto-generated schemas

@tool
def send_email(to: str, subject: str, body: str = '') -> bool:
    """Send an email. Returns True on success."""
    ...

Synapse reads the type annotations and docstring. The JSON schema is generated automatically — no BaseTool, no {type: "function", function: {…}} by hand.

Pass tools explicitly to the agents that need them:

@agent(model='gpt-4o', tools=[search_web])   # only this agent can call search_web
async def researcher(topic: str) -> str: ...

@agent(model='gpt-4o')                        # clean — no tools injected
async def writer(draft: str) -> str: ...

Each agent only receives the schemas you declare. No global bleed between agents.

@agent — Any model, same API

@agent(model='gpt-4o')                  # OpenAI
@agent(model='claude-3-5-sonnet')       # Anthropic
@agent(model='gemini/gemini-pro')       # Google
@agent(model='ollama/llama3')           # Local (free)

Powered by litellm — 100+ providers, one decorator.

Add guardrails:

@agent(
    model='gpt-4o',
    fallback='ollama/llama3',
    must_not=['PII', 'speculation'],
    token_budget=2000,
)
async def safe_agent(prompt: str) -> str: ...

>> — Readable pipelines

pipeline = researcher >> writer >> reviewer
result   = await pipeline.run(topic='climate change')

LangGraph needs nodes and edges. Synapse uses >>.

@workflow + step() — Composable pipelines

@workflow
async def research_pipeline(topic: str) -> str:
    data  = await step(researcher, topic)
    draft = await step(writer, data)
    return await step(reviewer, draft)

Zero-Cost Testing

from synapse import MockLLM

def test_my_agent():
    with MockLLM("expected response") as mock:
        result = await my_agent("prompt")
    assert result == "expected response"
    assert mock.call_count == 1

MockLLM patches litellm. No API calls. No tokens spent.


Synapse vs the alternatives

Feature Synapse LangChain OpenAI SDK LangGraph
Any LLM provider ❌ OpenAI only
Schema from annotations ❌ manual ❌ manual ❌ manual
>> chaining ❌ verbose
Built-in guardrails ⚠️ external
Readable 3-line agent ❌ subclass
MockLLM for tests

Roadmap

Version Name Ships
v0.1 The Tiny Core @agent, @tool, >>, MockLLM ← you are here
v0.3 Useful Projects Memory API, streaming, prompt templates, CLI
v0.5 AI Runtime Workflow engine, checkpointing, observability, guardrails
v0.8 Synapse Identity Prompt debugger, multi-agent graphs, human-in-the-loop
v1.0 Production Multi-tenancy, audit trail, intent routing

Install

pip install synapse-runtime

# For local LLM (free, no API key needed):
# Install Ollama → https://ollama.ai
ollama pull llama3

MIT License · Built in public · Issues welcome

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synapse_runtime-0.1.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synapse_runtime-0.1.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file synapse_runtime-0.1.1.tar.gz.

File metadata

  • Download URL: synapse_runtime-0.1.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for synapse_runtime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5b3bf5a274277c1f19c9702724da9df68121355170288edb6df8d8bdc6a94e8
MD5 9f4f488d512fd472ce0b8d2b4ad83ced
BLAKE2b-256 ddcf257a2a3ccaacac1b2658e96ce63b05a55b7de256ee964faa828e0c6213ba

See more details on using hashes here.

File details

Details for the file synapse_runtime-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for synapse_runtime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c13876776be88b8522de54deecd53ad4e4a3bb8911accff8d1d7cbf601444d1
MD5 fc1f6818a53abaa1b39c2a0ad66988a8
BLAKE2b-256 7a9fd8c57af4949286a1147681f6987786fcb83bf2bb8164646093e199559d96

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page