Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions docs/agents/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -1334,3 +1334,93 @@ The `whatsapp:` prefix is handled automatically — pass a plain E.164 number fo
- Tier-based rate limits (1K/10K/100K unique users per 24h) apply to business-initiated conversations only
- Business-initiated conversations (marketing, utility, authentication) carry an additional per-conversation charge on top of the per-message fee; user-initiated conversations have no per-conversation fee
:::

## NewsTool

Fetch news headlines and search articles via NewsAPI. No extra dependencies — stdlib `urllib` only.

```python
from synapsekit import NewsTool

tool = NewsTool(api_key="your-newsapi-key")
# or set NEWS_API_KEY env var

# Get top headlines
result = await tool.run(action="get_headlines", country="us", category="technology")

# Search articles
result = await tool.run(action="search", query="AI developments", sort_by="publishedAt")

print(result.output) # JSON array of articles
```

| Parameter | Default | Description |
|---|---|---|
| `action` | — | `get_headlines` or `search` (required) |
| `query` | — | Search query (required for `search`) |
| `country` | `us` | 2-letter country code for headlines |
| `category` | — | `business`, `entertainment`, `general`, `health`, `science`, `sports`, `technology` |
| `from_date` | — | Oldest article date (ISO 8601) |
| `sort_by` | — | `relevancy`, `popularity`, or `publishedAt` |

Auth via constructor arg or `NEWS_API_KEY` env var. Get a free API key at [newsapi.org](https://newsapi.org).

## WeatherTool

Get current weather and short-term forecasts via OpenWeatherMap. No extra dependencies — stdlib `urllib` only.

```python
from synapsekit import WeatherTool

tool = WeatherTool()
# set OPENWEATHERMAP_API_KEY env var

# Current weather
result = await tool.run(action="current", city="London,UK")

# 3-day forecast
result = await tool.run(action="forecast", city="Tokyo", days=3)

print(result.output)
```

| Parameter | Default | Description |
|---|---|---|
| `action` | `current` | `current` or `forecast` |
| `city` | — | City name, e.g. `Delhi` or `London,UK` (required) |
| `days` | `5` | Forecast days 1–5 (for `forecast` action) |

Auth via `OPENWEATHERMAP_API_KEY` env var.

## StripeTool

Read-only Stripe data lookup. No extra dependencies — stdlib `urllib` only.

```python
from synapsekit import StripeTool

tool = StripeTool()
# set STRIPE_API_KEY env var

# Look up customer
result = await tool.run(action="get_customer", id_or_email="cus_123")

# List invoices
result = await tool.run(action="list_invoices", customer_id="cus_123", limit=5)

# Get charge details
result = await tool.run(action="get_charge", charge_id="ch_abc")

# List products with pricing
result = await tool.run(action="list_products", limit=10)
```

| Parameter | Default | Description |
|---|---|---|
| `action` | — | `get_customer`, `list_invoices`, `get_charge`, `list_products` (required) |
| `id_or_email` | — | Customer ID (`cus_...`) or email for `get_customer` |
| `customer_id` | — | Stripe customer ID for `list_invoices` |
| `charge_id` | — | Stripe charge ID for `get_charge` |
| `limit` | `10` | Max results for list endpoints (max 100) |

Auth via `STRIPE_API_KEY` env var (use restricted read-only keys in production).
4 changes: 2 additions & 2 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1

# Introduction

**SynapseKit** is an async-native Python framework for building LLM applications — RAG pipelines, tool-using agents, and graph workflows. Streaming-first, transparent API, 2 hard deps. 27 providers · 43 tools · 26 loaders · 9 vector stores.
**SynapseKit** is an async-native Python framework for building LLM applications — RAG pipelines, tool-using agents, and graph workflows. Streaming-first, transparent API, 2 hard deps. 30 providers · 45 tools · 26 loaders · 9 vector stores.

It is designed from the ground up to be **async-native** and **streaming-first**. Every public API is `async`. Streaming tokens is the default, not an opt-in. There are no hidden chains, no magic callbacks, no global state.

Expand Down Expand Up @@ -65,7 +65,7 @@ InMemoryVectorStore (built-in, `.npz` persistence), ChromaDB, FAISS, Qdrant, Pin
`ReActAgent` — Thought → Action → Observation loop, works with any LLM.
`FunctionCallingAgent` — native `tool_calls` / `tool_use` for OpenAI, Anthropic, Gemini, and Mistral.
`AgentExecutor` — unified runner, picks the right agent from config.
43 built-in tools: Calculator, PythonREPL, FileRead, FileWrite, FileList, WebSearch, DuckDuckGoSearch, SQL, HTTP, GraphQL, DateTime, Regex, JSONQuery, HumanInput, Wikipedia, Summarization, SentimentAnalysis, Translation, WebScraper, Shell, SQLSchemaInspection, PDFReader, ArxivSearch, TavilySearch, Email, GitHubAPI, PubMedSearch, VectorSearch, YouTubeSearch, Slack, Notion, Jira, BraveSearch, APIBuilder, GoogleCalendar, AWSLambda, ImageAnalysis, TextToSpeech, SpeechToText, BingSearch, WolframAlpha, GoogleSearch, Twilio.
45 built-in tools: Calculator, PythonREPL, FileRead, FileWrite, FileList, WebSearch, DuckDuckGoSearch, SQL, HTTP, GraphQL, DateTime, Regex, JSONQuery, HumanInput, Wikipedia, Summarization, SentimentAnalysis, Translation, WebScraper, Shell, SQLSchemaInspection, PDFReader, ArxivSearch, TavilySearch, Email, GitHubAPI, PubMedSearch, VectorSearch, YouTubeSearch, Slack, Notion, Jira, BraveSearch, APIBuilder, GoogleCalendar, AWSLambda, ImageAnalysis, TextToSpeech, SpeechToText, BingSearch, WolframAlpha, GoogleSearch, Twilio, NewsTool, WeatherTool, StripeTool.

→ [Agent docs](/docs/agents/overview)

Expand Down
48 changes: 48 additions & 0 deletions docs/llms/novita.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
sidebar_position: 29
---

# NovitaAI

NovitaAI hosts popular open models (Llama, Mistral, Qwen, etc.) via an OpenAI-compatible API.

## Install

```bash
pip install synapsekit[openai]
```

## Usage

```python
from synapsekit.llm.novita import NovitaLLM
from synapsekit import LLMConfig

config = LLMConfig(
model="meta-llama/llama-3.1-8b-instruct",
api_key="nvt_...",
provider="novita",
)

llm = NovitaLLM(config)

# Streaming
async for token in llm.stream("Summarize the French Revolution"):
print(token, end="")

# Generate
response = await llm.generate("Explain async/await in Python")
```

## Available models

NovitaAI hosts hundreds of models. Popular choices:

| Model | Notes |
|---|---|
| `meta-llama/llama-3.1-8b-instruct` | Fast, 8B params |
| `meta-llama/llama-3.1-70b-instruct` | High quality |
| `mistralai/mistral-7b-instruct-v0.3` | Efficient |
| `qwen/qwen2.5-72b-instruct` | Strong multilingual |

See the full list at [novita.ai/models](https://novita.ai/models/text-generation).
6 changes: 6 additions & 0 deletions docs/llms/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ See [Caching & Retries](/docs/llms/caching-retries) for details on response cach
| Aleph Alpha | `AlephAlphaLLM` | `pip install synapsekit[aleph-alpha]` | `"aleph-alpha"` |
| Hugging Face | `HuggingFaceLLM` | `pip install synapsekit[huggingface]` | `"huggingface"` |
| SambaNova | `SambaNovaLLM` | `pip install synapsekit[openai]` | `"sambanova"` |
| xAI (Grok) | `XaiLLM` | `pip install synapsekit[openai]` | `"xai"` |
| NovitaAI | `NovitaLLM` | `pip install synapsekit[openai]` | `"novita"` |
| Writer (Palmyra) | `WriterLLM` | `pip install synapsekit[openai]` | `"writer"` |

## Auto-detection

Expand Down Expand Up @@ -138,6 +141,9 @@ The `TokenTracer` in `RAGPipeline` aggregates this across all calls.
- [Aleph Alpha](./aleph-alpha) — European LLMs, German-language and multilingual
- [Hugging Face](./huggingface) — thousands of open-source models via Inference API and Dedicated Endpoints
- [SambaNova](./sambanova) — fast inference on Llama, Qwen, and other open models
- [xAI](./xai) — Grok models (grok-2, grok-2-mini)
- [NovitaAI](./novita) — hosted open models (Llama, Mistral, Qwen, etc.)
- [Writer](./writer) — Palmyra models including domain-specific (palmyra-med, palmyra-fin)
- [Caching & Retries](./caching-retries) — LRU caching, exponential backoff, rate limiting
- [CostRouter & FallbackChain](./cost-router) — route to cheapest model or cascade on failure
- [Cost Tracker](../observability/cost-tracker) — attribute and budget LLM spending
59 changes: 59 additions & 0 deletions docs/llms/writer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
sidebar_position: 30
---

# Writer (Palmyra)

Writer's Palmyra models via the OpenAI-compatible API. Includes domain-specific models for medicine and finance.

## Install

```bash
pip install synapsekit[openai]
```

## Usage

```python
from synapsekit.llm.writer import WriterLLM
from synapsekit import LLMConfig

config = LLMConfig(
model="palmyra-x-004",
api_key="...",
provider="writer",
)

llm = WriterLLM(config)

# Streaming
async for token in llm.stream("Draft a contract summary"):
print(token, end="")

# Generate
response = await llm.generate("Explain HIPAA compliance")
```

## Available models

| Model | Notes |
|---|---|
| `palmyra-x-004` | Latest general purpose |
| `palmyra-x-003-instruct` | Instruction-tuned |
| `palmyra-med` | Medical domain |
| `palmyra-fin` | Financial domain |

## Function calling

```python
from synapsekit import AgentExecutor, AgentConfig, CalculatorTool

config = AgentConfig(
model="palmyra-x-004",
api_key="...",
provider="writer",
tools=[CalculatorTool()],
)
executor = AgentExecutor(config)
result = await executor.run("Calculate compound interest on $10,000 at 5% for 3 years")
```
58 changes: 58 additions & 0 deletions docs/llms/xai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
sidebar_position: 28
---

# xAI (Grok)

xAI's Grok models via the OpenAI-compatible API.

## Install

```bash
pip install synapsekit[openai]
```

## Usage

```python
from synapsekit.llm.xai import XaiLLM
from synapsekit import LLMConfig

config = LLMConfig(
model="grok-2",
api_key="xai-...",
provider="xai",
)

llm = XaiLLM(config)

# Streaming
async for token in llm.stream("Explain the trolley problem"):
print(token, end="")

# Generate
response = await llm.generate("What is entropy?")
```

## Available models

| Model | Notes |
|---|---|
| `grok-beta` | Original Grok |
| `grok-2` | Latest generation |
| `grok-2-mini` | Faster, lower cost |

## Function calling

```python
from synapsekit import AgentExecutor, AgentConfig, CalculatorTool

config = AgentConfig(
model="grok-2",
api_key="xai-...",
provider="xai",
tools=[CalculatorTool()],
)
executor = AgentExecutor(config)
result = await executor.run("What is 15% of 284?")
```
21 changes: 21 additions & 0 deletions docs/rag/splitter.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,24 @@ splitter = SentenceSplitter()
chunks = splitter.split("First sentence. Second sentence. Third sentence.")
# ["First sentence.", "Second sentence.", "Third sentence."]
```

## HTMLTextSplitter

Splits HTML documents on block-level tags and returns plain-text chunks. Uses stdlib `html.parser` — no extra dependencies.

```python
from synapsekit import HTMLTextSplitter

splitter = HTMLTextSplitter(chunk_size=512, chunk_overlap=50)
chunks = splitter.split("<h1>Title</h1><p>First paragraph.</p><p>Second paragraph.</p>")
# ["Title", "First paragraph.", "Second paragraph."]
```

Block tags used as split boundaries: `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `p`, `div`, `section`, `article`, `li`, `blockquote`, `pre`.

Long sections that exceed `chunk_size` fall back to `RecursiveCharacterTextSplitter`.

| Parameter | Default | Description |
|---|---|---|
| `chunk_size` | `512` | Maximum characters per chunk |
| `chunk_overlap` | `50` | Characters of overlap between consecutive chunks |
Loading