Merge remote-tracking branch 'origin/main' into eri/dev-1300
This commit is contained in:
commit
7cabb7d8f4
|
|
@ -101,6 +101,8 @@ jobs:
|
|||
SENTRY_ENABLED: false
|
||||
LLM_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
LLM_ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
LLM_OPENAI_COMPATIBLE_API_KEY: test-key
|
||||
LLM_OPENAI_COMPATIBLE_BASE_URL: http://localhost:8000
|
||||
DERIVER_PROVIDER: openai
|
||||
DERIVER_MODEL: test
|
||||
DIALECTIC_PROVIDER: openai
|
||||
|
|
|
|||
35
CHANGELOG.md
35
CHANGELOG.md
|
|
@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [2.5.0] - 2025-12-03
|
||||
|
||||
### Added
|
||||
|
||||
- Message level configurations
|
||||
- CRUD operations for observations
|
||||
- Comprehensive test cases for harness
|
||||
- Peer level get_context
|
||||
- Set Peer Card Method
|
||||
- Manual dreaming trigger endpoint
|
||||
|
||||
### Changed
|
||||
|
||||
- Configurations to support more flags for fine-grained control of the deriver, peer cards, summaries, etc.
|
||||
- Working Representations to support more fine-grained parameters
|
||||
|
||||
### Fixed
|
||||
|
||||
- File uploads to match `MessageCreate` structure
|
||||
- Cache invalidation strategy
|
||||
|
||||
## [2.4.3] - 2025-11-20
|
||||
|
||||
### Added
|
||||
|
||||
- Redis caching to improve DB IO
|
||||
- Backup LLM provider to avoid failures when a provider is down
|
||||
|
||||
### Changed
|
||||
|
||||
- QueueItems to use standardized columns
|
||||
- Improved Deduplication logic for Representation Tasks
|
||||
- More finegrained metrics for representation, summary, and peer card tasks
|
||||
- DB constraint to follow standard naming conventions
|
||||
|
||||
## [2.4.2] - 2025-11-03
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
18
CLAUDE.md
18
CLAUDE.md
|
|
@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||
|
||||
## What is Honcho?
|
||||
|
||||
Honcho is an infrastructure layer for building AI agents with social cognition and theory of mind capabilities. Its primary purposes include:
|
||||
Honcho is an infrastructure layer for building AI agents with memory and social cognition. Its primary purposes include:
|
||||
|
||||
- Imbuing agents with a sense of identity
|
||||
- Personalizing user experiences through understanding user psychology
|
||||
|
|
@ -14,7 +14,7 @@ Honcho is an infrastructure layer for building AI agents with social cognition a
|
|||
- Supporting development of LLM-powered applications that adapt to end users
|
||||
- Enabling multi-peer sessions where multiple participants (users or agents) can interact
|
||||
|
||||
Honcho leverages the inherent theory-of-mind capabilities of LLMs to build coherent models of user psychology over time, enabling more personalized and effective AI interactions.
|
||||
Honcho leverages the inherent reasoning capabilities of LLMs to build coherent models of user psychology over time, enabling more personalized and effective AI interactions.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ Honcho uses a peer-based model where both users and agents are represented as "p
|
|||
- **Peer** (formerly User): Any participant in the system (human or AI)
|
||||
- **Session**: A conversation context that can involve multiple peers
|
||||
- **Message**: Data units that can represent communication between peers OR arbitrary data ingested by a peer to enhance its global representation
|
||||
- **Collections & Documents**: Internal vector storage for theory-of-mind representations (not exposed via API)
|
||||
- **Collections & Documents**: Internal vector storage for peer representations (not exposed via API)
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ All API routes follow the pattern: `/v1/{resource}/{id}/{action}`
|
|||
|
||||
#### Dialectic API (`/peers/{peer_id}/chat`)
|
||||
|
||||
- Provides theory-of-mind informed responses
|
||||
- Provides bespoke responses informed by the representation
|
||||
- Integrates long-term facts from vector storage
|
||||
- Supports streaming responses
|
||||
- Configurable LLM providers
|
||||
|
|
@ -59,18 +59,11 @@ All API routes follow the pattern: `/v1/{resource}/{id}/{action}`
|
|||
|
||||
1. Messages created via API (batch or single)
|
||||
2. Enqueued for background processing:
|
||||
- `representation`: Update peer's theory of mind
|
||||
- `representation`: Update peer's context
|
||||
- `summary`: Create session summaries
|
||||
3. Session-based queue processing ensures order
|
||||
4. Results stored internally in vector DB
|
||||
|
||||
#### Theory of Mind System
|
||||
|
||||
- Multiple implementation methods (conversational, single_prompt, long_term)
|
||||
- Facts extracted from messages and stored in collections
|
||||
- Representations combine short-term inference with long-term facts
|
||||
- Configurable via peer and session feature flags
|
||||
|
||||
### Configuration
|
||||
|
||||
- Hierarchical config: config.toml + environment variables
|
||||
|
|
@ -179,7 +172,6 @@ src/
|
|||
### Key Architectural Decisions
|
||||
|
||||
1. **Multi-Peer Sessions**: Sessions can have multiple participants with different observation settings
|
||||
2. **Flexible Theory of Mind**: Pluggable ToM implementations (conversational, single_prompt, long_term)
|
||||
3. **Background Processing**: Async queue system for expensive operations
|
||||
4. **Provider Abstraction**: Model client supports multiple LLM providers
|
||||
5. **Scoped Authentication**: JWTs can be scoped to workspace, peer, or session level
|
||||
|
|
|
|||
17
README.md
17
README.md
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
---
|
||||
|
||||

|
||||

|
||||
[](https://pypi.org/project/honcho-ai/)
|
||||
[](https://npmjs.org/package/@honcho-ai/sdk)
|
||||
[](https://discord.gg/plasticlabs)
|
||||
|
|
@ -429,7 +429,7 @@ Then modify the values as needed. The TOML file is organized into sections:
|
|||
- `[cache]` - Redis cache configuration
|
||||
- `[llm]` - LLM provider API keys and general settings
|
||||
- `[dialectic]` - Dialectic API configuration (provider, model, search settings)
|
||||
- `[deriver]` - Background worker settings and theory of mind configuration
|
||||
- `[deriver]` - Background worker settings and representation configuration
|
||||
- `[peer_card]` - Peer card generation settings
|
||||
- `[summary]` - Session summarization settings
|
||||
- `[dream]` - Dream processing configuration
|
||||
|
|
@ -501,8 +501,8 @@ Honcho uses a peer-based model where both users and agents are represented as "p
|
|||
|
||||
#### Key Features
|
||||
|
||||
- **Theory-of-Mind System**: Multiple implementation methods that extract facts from interactions and build comprehensive models of peer psychology
|
||||
- **Dialectic API**: Provides theory-of-mind informed responses that integrate long-term facts with current context
|
||||
- **Rich Reasoning System**: Multiple implementation methods that extract facts from interactions and build comprehensive models of peer psychology
|
||||
- **Dialectic API**: Provides reasoned informed responses that integrate long-term facts with current context
|
||||
- **Background Processing**: Asynchronous processing pipeline for expensive operations like representation updates and session summarization
|
||||
- **Multi-Provider Support**: Configurable LLM providers for different use cases
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ The `Message` represents an atomic data unit that can exist at two levels:
|
|||
- **Session-level Messages**: Communication between peers within a session context
|
||||
|
||||
All messages are labeled by their source peer and can be processed
|
||||
asynchronously to update theory-of-mind models. This flexible design allows for
|
||||
asynchronously to update their representations. This flexible design allows for
|
||||
both conversational interactions and broader data ingestion for personality
|
||||
modeling.
|
||||
|
||||
|
|
@ -578,8 +578,7 @@ familiar with RAG based applications will be familiar with these. `Collections`
|
|||
store vector embedded data that developers and agents can retrieve against using
|
||||
functions like cosine similarity.
|
||||
|
||||
Collections are also used internally by Honcho while creating theory-of-mind
|
||||
representations of peers.
|
||||
Collections are also used internally by Honcho while creating representations of peers.
|
||||
|
||||
#### Documents
|
||||
|
||||
|
|
@ -596,7 +595,7 @@ A high level summary of the pipeline is as follows:
|
|||
|
||||
1. Messages are created via the API
|
||||
2. Derivation Tasks are enqueued for background processing including:
|
||||
- `representation`: To update theory-of-mind representations of `Peers`
|
||||
- `representation`: To update representations of `Peers`
|
||||
- `summary`: To create summaries of `Sessions`
|
||||
3. Session-based queue processing ensures proper ordering
|
||||
4. Results are stored internally
|
||||
|
|
@ -638,7 +637,7 @@ A developer's application can treat Honcho as an oracle to the `Peer` and
|
|||
consult it when necessary. Some examples of how to leverage the Dialectic
|
||||
API include:
|
||||
|
||||
- Asking Honcho for a theory-of-mind insight about the `Peer`
|
||||
- Asking Honcho for a generic or specific insight about the `Peer`
|
||||
- Asking Honcho to hydrate a prompt with data about the `Peer`s behavior
|
||||
- Asking Honcho for a 2nd opinion or approach about how to respond to the Peer
|
||||
- Getting personalized responses that incorporate long-term facts and context
|
||||
|
|
|
|||
|
|
@ -8,23 +8,23 @@ This guide helps you understand which versions of Honcho's API are compatible wi
|
|||
|
||||
## Version Compatibility
|
||||
|
||||
### Honcho API v2.4.2 (Current)
|
||||
### Honcho API v2.5.0 (Current)
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="TypeScript SDK" icon="js">
|
||||
**Compatible Version:** v1.5.0
|
||||
**Compatible Version:** v1.6.0
|
||||
|
||||
Install with:
|
||||
```bash
|
||||
npm install @honcho-ai/sdk@1.5.0
|
||||
npm install @honcho-ai/sdk@1.6.0
|
||||
```
|
||||
</Card>
|
||||
<Card title="Python SDK" icon="python">
|
||||
**Compatible Version:** v1.5.0
|
||||
**Compatible Version:** v1.6.0
|
||||
|
||||
Install with:
|
||||
```bash
|
||||
pip install honcho-ai==1.5.0
|
||||
pip install honcho-ai==1.6.0
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -34,7 +34,9 @@ This guide helps you understand which versions of Honcho's API are compatible wi
|
|||
|
||||
| Honcho API Version | TypeScript SDK | Python SDK |
|
||||
|-------------------|---------------|------------|
|
||||
| v2.4.2 (Current) | v1.5.0 | v1.5.0 |
|
||||
| v2.5.0 (Current) | v1.6.0 | v1.6.0 |
|
||||
| v2.4.3 | v1.5.0 | v1.5.0 |
|
||||
| v2.4.2 | v1.5.0 | v1.5.0 |
|
||||
| v2.4.1 | v1.5.0 | v1.5.0 |
|
||||
| v2.4.0 | v1.5.0 | v1.5.0 |
|
||||
| v2.3.3 | v1.4.1 | v1.4.1 |
|
||||
|
|
|
|||
|
|
@ -27,7 +27,42 @@ Welcome to the Honcho changelog! This section documents all notable changes to t
|
|||
### Honcho API and SDK Changelogs
|
||||
<Tabs>
|
||||
<Tab title="Honcho API">
|
||||
<Update label="v2.4.2 (Current)">
|
||||
<Update label="v2.5.0 (Current)">
|
||||
### Added
|
||||
|
||||
- Message level configurations
|
||||
- CRUD operations for observations
|
||||
- Comprehensive test cases for harness
|
||||
- Peer level get_context
|
||||
- Set Peer Card Method
|
||||
- Manual dreaming trigger endpoint
|
||||
|
||||
### Changed
|
||||
|
||||
- Configurations to support more flags for fine-grained control of the deriver, peer cards, summaries, etc.
|
||||
- Working Representations to support more fine-grained parameters
|
||||
|
||||
### Fixed
|
||||
|
||||
- File uploads to match `MessageCreate` structure
|
||||
- Cache invalidation strategy
|
||||
</Update>
|
||||
|
||||
<Update label="v2.4.3">
|
||||
### Added
|
||||
|
||||
- Redis caching to improve DB IO
|
||||
- Backup LLM provider to avoid failures when a provider is down
|
||||
|
||||
### Changed
|
||||
|
||||
- QueueItems to use standardized columns
|
||||
- Improved Deduplication logic for Representation Tasks
|
||||
- More finegrained metrics for representation, summary, and peer card tasks
|
||||
- DB constraint to follow standard naming conventions
|
||||
</Update>
|
||||
|
||||
<Update label="v2.4.2">
|
||||
### Fixed
|
||||
|
||||
- Langfuse tracing to have readable waterfalls
|
||||
|
|
@ -365,6 +400,19 @@ Welcome to the Honcho changelog! This section documents all notable changes to t
|
|||
|
||||
<Tab title="Python SDK">
|
||||
[Python SDK](https://pypi.org/project/honcho-ai/)
|
||||
<Update label="v1.6.0 (Current)">
|
||||
### Added
|
||||
|
||||
- metadata and configuration fields to Workspace, Peer, Session, and Message objects
|
||||
- Session Clone methods
|
||||
- Peer level get_context method
|
||||
- `ObservationScope` object to perform CRUD operations on observations
|
||||
- Representation object for WorkingRepresentations
|
||||
|
||||
### Changed
|
||||
|
||||
- methods that take IDs, can all optionally take an object of the same type
|
||||
</Update>
|
||||
<Update label="v1.5.0">
|
||||
### Added
|
||||
|
||||
|
|
@ -439,6 +487,19 @@ Welcome to the Honcho changelog! This section documents all notable changes to t
|
|||
|
||||
<Tab title="TypeScript SDK">
|
||||
[TypeScript SDK](https://www.npmjs.com/package/@honcho-ai/sdk)
|
||||
<Update label="v1.6.0 (Current)">
|
||||
### Added
|
||||
|
||||
- metadata and configuration fields to Workspace, Peer, Session, and Message objects
|
||||
- Session Clone methods
|
||||
- Peer level get_context method
|
||||
- `ObservationScope` object to perform CRUD operations on observations
|
||||
- Representation object for WorkingRepresentations
|
||||
|
||||
### Changed
|
||||
|
||||
- methods that take IDs, can all optionally take an object of the same type
|
||||
</Update>
|
||||
<Update label="v1.5.0">
|
||||
### Added
|
||||
|
||||
|
|
|
|||
378
docs/docs.json
378
docs/docs.json
|
|
@ -2,6 +2,12 @@
|
|||
"$schema": "https://mintlify.com/docs.json",
|
||||
"theme": "mint",
|
||||
"name": "Honcho",
|
||||
"redirects": [
|
||||
{
|
||||
"source": "/",
|
||||
"destination": "/v2/documentation/introduction/overview"
|
||||
}
|
||||
],
|
||||
"colors": {
|
||||
"primary": "#66AAFF",
|
||||
"dark": "#151E27",
|
||||
|
|
@ -9,14 +15,21 @@
|
|||
},
|
||||
"favicon": "/favicon.svg",
|
||||
"contextual": {
|
||||
"options": ["copy", "view", "chatgpt", "claude"]
|
||||
"options": [
|
||||
"copy",
|
||||
"view",
|
||||
"chatgpt",
|
||||
"claude"
|
||||
]
|
||||
},
|
||||
"navigation": {
|
||||
"versions": [
|
||||
{
|
||||
"version": "v2.4.2",
|
||||
"version": "v2.5.0",
|
||||
"api": {
|
||||
"openapi": ["openapi.documented.yml"]
|
||||
"openapi": [
|
||||
"openapi.json"
|
||||
]
|
||||
},
|
||||
"tabs": [
|
||||
{
|
||||
|
|
@ -34,28 +47,19 @@
|
|||
"group": "Core Concepts",
|
||||
"pages": [
|
||||
"v2/documentation/core-concepts/architecture",
|
||||
"v2/documentation/core-concepts/reasoning",
|
||||
"v2/documentation/core-concepts/representation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Features",
|
||||
"pages": [
|
||||
"v2/documentation/features/get-context",
|
||||
"v2/documentation/features/chat",
|
||||
{
|
||||
"group": "Advanced",
|
||||
"pages": [
|
||||
"v2/documentation/features/advanced/overview",
|
||||
"v2/documentation/features/advanced/queue-status",
|
||||
"v2/documentation/features/advanced/toggle-reasoning",
|
||||
"v2/documentation/features/advanced/representation-scopes",
|
||||
"v2/documentation/features/advanced/summarizer",
|
||||
"v2/documentation/features/advanced/search",
|
||||
"v2/documentation/features/advanced/using-filters",
|
||||
"v2/documentation/features/advanced/streaming-response"
|
||||
]
|
||||
}
|
||||
"v2/documentation/core-concepts/features/storing-data",
|
||||
"v2/documentation/core-concepts/features/dialectic-endpoint",
|
||||
"v2/documentation/core-concepts/features/get-context",
|
||||
"v2/documentation/core-concepts/features/search",
|
||||
"v2/documentation/core-concepts/features/working-rep",
|
||||
"v2/documentation/core-concepts/features/streaming-response",
|
||||
"v2/documentation/core-concepts/features/using-filters",
|
||||
"v2/documentation/core-concepts/features/file-uploads",
|
||||
"v2/documentation/core-concepts/features/queue-status",
|
||||
"v2/documentation/core-concepts/features/local-vs-global",
|
||||
"v2/documentation/core-concepts/configuration",
|
||||
"v2/documentation/core-concepts/summarizer",
|
||||
"v2/documentation/core-concepts/glossary"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -68,32 +72,30 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"tab": "Guides",
|
||||
"tab": "Spellbooks",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Overview",
|
||||
"group": "Getting Started",
|
||||
"pages": [
|
||||
"v2/guides/overview",
|
||||
"v2/guides/file-uploads",
|
||||
"v2/guides/storing-data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Integrations",
|
||||
"pages": [
|
||||
"v2/guides/integrations/crewai",
|
||||
"v2/guides/integrations/langgraph",
|
||||
"v2/guides/integrations/mcp"
|
||||
"v2/guides/overview"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Migrations",
|
||||
"pages": [
|
||||
"v2/guides/migrations/mem0"
|
||||
"v2/migrations/from-mem0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Chatbots",
|
||||
"group": "Integrations",
|
||||
"pages": [
|
||||
"v2/integrations/crewai",
|
||||
"v2/integrations/langgraph",
|
||||
"v2/integrations/mcp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Application Interfaces",
|
||||
"pages": [
|
||||
"v2/guides/discord",
|
||||
"v2/guides/telegram"
|
||||
|
|
@ -101,31 +103,14 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Open Source",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Self-Hosting",
|
||||
"pages": [
|
||||
"v2/contributing/self-hosting",
|
||||
"v2/contributing/configuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Contributing",
|
||||
"pages": [
|
||||
"v2/contributing/guidelines",
|
||||
"v2/contributing/license"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "API Reference",
|
||||
"groups": [
|
||||
{
|
||||
"group": "API Documentation",
|
||||
"pages": ["v2/api-reference/introduction"]
|
||||
"pages": [
|
||||
"v2/api-reference/introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "workspaces",
|
||||
|
|
@ -135,7 +120,8 @@
|
|||
"v2/api-reference/endpoint/workspaces/update-workspace",
|
||||
"v2/api-reference/endpoint/workspaces/delete-workspace",
|
||||
"v2/api-reference/endpoint/workspaces/search-workspace",
|
||||
"v2/api-reference/endpoint/workspaces/get-deriver-status"
|
||||
"v2/api-reference/endpoint/workspaces/get-deriver-status",
|
||||
"v2/api-reference/endpoint/workspaces/trigger-dream"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -147,8 +133,10 @@
|
|||
"v2/api-reference/endpoint/peers/get-sessions-for-peer",
|
||||
"v2/api-reference/endpoint/peers/chat",
|
||||
"v2/api-reference/endpoint/peers/get-working-representation",
|
||||
"v2/api-reference/endpoint/peers/search-peer",
|
||||
"v2/api-reference/endpoint/peers/get-peer-card"
|
||||
"v2/api-reference/endpoint/peers/get-peer-card",
|
||||
"v2/api-reference/endpoint/peers/set-peer-card",
|
||||
"v2/api-reference/endpoint/peers/get-peer-context",
|
||||
"v2/api-reference/endpoint/peers/search-peer"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -180,6 +168,15 @@
|
|||
"v2/api-reference/endpoint/messages/create-messages-with-file"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "observations",
|
||||
"pages": [
|
||||
"v2/api-reference/endpoint/observations/create-observations",
|
||||
"v2/api-reference/endpoint/observations/list-observations",
|
||||
"v2/api-reference/endpoint/observations/query-observations",
|
||||
"v2/api-reference/endpoint/observations/delete-observation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "webhooks",
|
||||
"pages": [
|
||||
|
|
@ -198,6 +195,235 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Changelog",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Overview",
|
||||
"pages": [
|
||||
"changelog/introduction",
|
||||
"changelog/compatibility-guide"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Contributing",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Contributing",
|
||||
"pages": [
|
||||
"v2/contributing/guidelines",
|
||||
"v2/contributing/self-hosting",
|
||||
"v2/contributing/configuration",
|
||||
"v2/contributing/license"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "v2.6.0-alpha",
|
||||
"api": {
|
||||
"openapi": [
|
||||
"openapi.json"
|
||||
]
|
||||
},
|
||||
"tabs": [
|
||||
{
|
||||
"tab": "Documentation",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Introduction",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/documentation/introduction/overview",
|
||||
"v2.6.0-alpha/documentation/introduction/quickstart",
|
||||
"v2.6.0-alpha/documentation/introduction/vibecoding"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Core Concepts",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/documentation/core-concepts/architecture",
|
||||
"v2.6.0-alpha/documentation/core-concepts/reasoning",
|
||||
"v2.6.0-alpha/documentation/core-concepts/representation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Features",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/documentation/features/get-context",
|
||||
"v2.6.0-alpha/documentation/features/chat",
|
||||
{
|
||||
"group": "Advanced",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/documentation/features/advanced/overview",
|
||||
"v2.6.0-alpha/documentation/features/advanced/queue-status",
|
||||
"v2.6.0-alpha/documentation/features/advanced/toggle-reasoning",
|
||||
"v2.6.0-alpha/documentation/features/advanced/representation-scopes",
|
||||
"v2.6.0-alpha/documentation/features/advanced/summarizer",
|
||||
"v2.6.0-alpha/documentation/features/advanced/search",
|
||||
"v2.6.0-alpha/documentation/features/advanced/using-filters",
|
||||
"v2.6.0-alpha/documentation/features/advanced/streaming-response"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Reference",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/documentation/reference/platform",
|
||||
"v2.6.0-alpha/documentation/reference/sdk"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Guides",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Overview",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/guides/overview",
|
||||
"v2.6.0-alpha/guides/file-uploads",
|
||||
"v2.6.0-alpha/guides/storing-data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Integrations",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/guides/integrations/crewai",
|
||||
"v2.6.0-alpha/guides/integrations/langgraph",
|
||||
"v2.6.0-alpha/guides/integrations/mcp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Migrations",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/guides/migrations/mem0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Chatbots",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/guides/discord",
|
||||
"v2.6.0-alpha/guides/telegram"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Open Source",
|
||||
"groups": [
|
||||
{
|
||||
"group": "Self-Hosting",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/contributing/self-hosting",
|
||||
"v2.6.0-alpha/contributing/configuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Contributing",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/contributing/guidelines",
|
||||
"v2.6.0-alpha/contributing/license"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "API Reference",
|
||||
"groups": [
|
||||
{
|
||||
"group": "API Documentation",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "workspaces",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/get-or-create-workspace",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/get-all-workspaces",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/update-workspace",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/delete-workspace",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/search-workspace",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/get-deriver-status",
|
||||
"v2.6.0-alpha/api-reference/endpoint/workspaces/trigger-dream"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "peers",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-peers",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-or-create-peer",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/update-peer",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-sessions-for-peer",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/chat",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-working-representation",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-peer-card",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/set-peer-card",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/get-peer-context",
|
||||
"v2.6.0-alpha/api-reference/endpoint/peers/search-peer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "sessions",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-or-create-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-sessions",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/update-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/delete-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/clone-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-session-peers",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/set-session-peers",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/add-peers-to-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/remove-peers-from-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-peer-config",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/set-peer-config",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-session-context",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/get-session-summaries",
|
||||
"v2.6.0-alpha/api-reference/endpoint/sessions/search-session"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "messages",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/messages/create-messages-for-session",
|
||||
"v2.6.0-alpha/api-reference/endpoint/messages/get-messages",
|
||||
"v2.6.0-alpha/api-reference/endpoint/messages/get-message",
|
||||
"v2.6.0-alpha/api-reference/endpoint/messages/update-message",
|
||||
"v2.6.0-alpha/api-reference/endpoint/messages/create-messages-with-file"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "observations",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/observations/create-observations",
|
||||
"v2.6.0-alpha/api-reference/endpoint/observations/list-observations",
|
||||
"v2.6.0-alpha/api-reference/endpoint/observations/query-observations",
|
||||
"v2.6.0-alpha/api-reference/endpoint/observations/delete-observation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "webhooks",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/webhooks/list-webhook-endpoints",
|
||||
"v2.6.0-alpha/api-reference/endpoint/webhooks/get-or-create-webhook-endpoint",
|
||||
"v2.6.0-alpha/api-reference/endpoint/webhooks/delete-webhook-endpoint",
|
||||
"v2.6.0-alpha/api-reference/endpoint/webhooks/test-emit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "miscellaneous",
|
||||
"pages": [
|
||||
"v2.6.0-alpha/api-reference/endpoint/keys/create-key",
|
||||
"v2.6.0-alpha/api-reference/endpoint/metrics"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tab": "Changelog",
|
||||
"groups": [
|
||||
|
|
@ -215,7 +441,9 @@
|
|||
{
|
||||
"version": "v1.1.0",
|
||||
"api": {
|
||||
"openapi": ["openapi.json"]
|
||||
"openapi": [
|
||||
"openapi.json"
|
||||
]
|
||||
},
|
||||
"tabs": [
|
||||
{
|
||||
|
|
@ -245,15 +473,23 @@
|
|||
"groups": [
|
||||
{
|
||||
"group": "Getting Started",
|
||||
"pages": ["v1/guides/overview", "v1/guides/streaming-response"]
|
||||
"pages": [
|
||||
"v1/guides/overview",
|
||||
"v1/guides/streaming-response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Application Interfaces",
|
||||
"pages": ["v1/guides/discord", "v1/guides/honcho-mcp"]
|
||||
"pages": [
|
||||
"v1/guides/discord",
|
||||
"v1/guides/honcho-mcp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "Personal Memory",
|
||||
"pages": ["v1/guides/dialectic-endpoint"]
|
||||
"pages": [
|
||||
"v1/guides/dialectic-endpoint"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -262,7 +498,9 @@
|
|||
"groups": [
|
||||
{
|
||||
"group": "API Documentation",
|
||||
"pages": ["v1/api-reference/introduction"]
|
||||
"pages": [
|
||||
"v1/api-reference/introduction"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "apps",
|
||||
|
|
@ -310,7 +548,9 @@
|
|||
},
|
||||
{
|
||||
"group": "keys",
|
||||
"pages": ["v1/api-reference/endpoint/keys/create-key"]
|
||||
"pages": [
|
||||
"v1/api-reference/endpoint/keys/create-key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "metamessages",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
"main": ".pnp.js",
|
||||
"scripts": {
|
||||
"dev": "mint dev",
|
||||
"openapi": "npx @mintlify/scraping openapi-file openapi.documented.yml -o api-reference/endpoint",
|
||||
"openapi": "npx @mintlify/scraping openapi-file v2/openapi.json -o v2/api-reference/endpoint",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
This subdirectory contains the peer-paradigm documentation for Honcho (Honcho v2.0.0 onwards).
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/keys
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/messages/
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/messages/upload
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/messages/{message_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/messages/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/messages/{message_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /metrics
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/observations
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2.6.0-alpha/workspaces/{workspace_id}/observations/{observation_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/observations/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/observations/query
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/chat
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/card
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/context
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/sessions
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/representation
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/search
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}/card
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}/peers/{peer_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/clone
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers/{peer_id}/config
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/context
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/summaries
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/search
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers/{peer_id}/config
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}/peers
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}/sessions/{session_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2.6.0-alpha/workspaces/{workspace_id}/webhooks/{endpoint_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/webhooks
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/webhooks
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/webhooks/test
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2.6.0-alpha/workspaces/{workspace_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2.6.0-alpha/workspaces/{workspace_id}/deriver/status
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/search
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2.6.0-alpha/workspaces/{workspace_id}/trigger_dream
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: put /v2.6.0-alpha/workspaces/{workspace_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
title: 'Introduction'
|
||||
---
|
||||
|
||||
This section documents all available API endpoints in the Honcho Server. Each
|
||||
endpoint provides CRUD operations for our core primitives. For information
|
||||
about these primitives, see
|
||||
[Architecture](/v2.6.0-alpha/documentation/core-concepts/architecture).
|
||||
|
||||
<Warning>
|
||||
We strongly recommend using our official SDKs instead of calling these APIs directly. The SDKs provide better error handling, type safety, and developer experience.
|
||||
</Warning>
|
||||
|
||||
## Recommended approach
|
||||
|
||||
Use our official SDKs for the best development experience:
|
||||
- [Python SDK](https://pypi.org/project/honcho-ai/)
|
||||
- [TypeScript SDK](https://www.npmjs.com/package/@honcho-ai/sdk)
|
||||
|
||||
## When to use this API reference
|
||||
|
||||
This reference is primarily useful for:
|
||||
- Debugging SDK behavior
|
||||
- Building integrations in unsupported languages
|
||||
- Understanding the underlying data structures
|
||||
|
||||
The endpoints pages are autogenerated and include interactive examples for testing.
|
||||
|
|
@ -0,0 +1,638 @@
|
|||
---
|
||||
title: "Configuration Guide"
|
||||
description: "Complete guide to configuring Honcho for development and production"
|
||||
icon: "gear"
|
||||
---
|
||||
|
||||
Honcho uses a flexible configuration system that supports both TOML files and environment variables. Configuration values are loaded in the following priority order (highest to lowest):
|
||||
|
||||
1. Environment variables (always take precedence)
|
||||
2. `.env` file (for local development)
|
||||
3. `config.toml` file (base configuration)
|
||||
4. Default values
|
||||
|
||||
## Recommended Configuration Approaches
|
||||
|
||||
### Option 1: Environment Variables Only (Production)
|
||||
- Use environment variables for all configuration
|
||||
- No config files needed
|
||||
- Ideal for containerized deployments (Docker, Kubernetes)
|
||||
- Secrets managed by your deployment platform
|
||||
|
||||
### Option 2: config.toml (Development/Simple Deployments)
|
||||
- Use config.toml for base configuration
|
||||
- Override sensitive values with environment variables
|
||||
- Good for development and simple deployments
|
||||
|
||||
### Option 3: Hybrid Approach
|
||||
- Use config.toml for non-sensitive base settings
|
||||
- Use .env file for sensitive values (API keys, secrets)
|
||||
- Good for development teams
|
||||
|
||||
### Option 4: .env Only (Local Development)
|
||||
- Use .env file for all configuration
|
||||
- Simple for local development
|
||||
- Never commit .env files to version control
|
||||
|
||||
## Configuration Methods
|
||||
|
||||
### Using config.toml
|
||||
|
||||
Copy the example configuration file to get started:
|
||||
|
||||
```bash
|
||||
cp config.toml.example config.toml
|
||||
```
|
||||
|
||||
Then modify the values as needed. The TOML file is organized into sections:
|
||||
|
||||
- `[app]` - Application-level settings (log level, session limits, embedding settings, Langfuse integration, local metrics collection)
|
||||
- `[db]` - Database connection and pool settings (connection URI, pool size, timeouts, connection recycling)
|
||||
- `[auth]` - Authentication configuration (enable/disable auth, JWT secret)
|
||||
- `[cache]` - Redis cache configuration (enable/disable caching, Redis URL, TTL settings, lock configuration for cache stampede prevention)
|
||||
- `[llm]` - LLM provider API keys (Anthropic, OpenAI, Gemini, Groq, OpenAI-compatible endpoints) and general LLM settings
|
||||
- `[dialectic]` - Dialectic API configuration (provider, model, query generation settings, semantic search parameters, context window size)
|
||||
- `[deriver]` - Background worker settings (worker count, polling intervals, queue management) and theory of mind configuration (model, tokens, observation limits)
|
||||
- `[peer_card]` - Peer card generation settings (provider, model, token limits)
|
||||
- `[summary]` - Session summarization settings (frequency thresholds, provider, model, token limits for short and long summaries)
|
||||
- `[dream]` - Dream processing configuration (enable/disable, thresholds, idle timeouts, dream types, LLM settings)
|
||||
- `[webhook]` - Webhook configuration (webhook secret, workspace limits)
|
||||
- `[metrics]` - Metrics collection settings (enable/disable metrics, namespace)
|
||||
- `[sentry]` - Error tracking and monitoring settings (enable/disable, DSN, environment, sample rates)
|
||||
|
||||
### Using Environment Variables
|
||||
|
||||
All configuration values can be overridden using environment variables. The environment variable names follow this pattern:
|
||||
|
||||
- `{SECTION}_{KEY}` for nested settings
|
||||
- Just `{KEY}` for app-level settings
|
||||
|
||||
Examples:
|
||||
|
||||
- `DB_CONNECTION_URI` → `[db].CONNECTION_URI`
|
||||
- `DB_POOL_SIZE` → `[db].POOL_SIZE`
|
||||
- `AUTH_JWT_SECRET` → `[auth].JWT_SECRET`
|
||||
- `DIALECTIC_MODEL` → `[dialectic].MODEL`
|
||||
- `LOG_LEVEL` (no section) → `[app].LOG_LEVEL`
|
||||
|
||||
### Configuration Priority
|
||||
|
||||
When a configuration value is set in multiple places, Honcho uses this priority:
|
||||
|
||||
1. **Environment variables** - Always take precedence
|
||||
2. **.env file** - Loaded for local development
|
||||
3. **config.toml** - Base configuration
|
||||
4. **Default values** - Built-in defaults
|
||||
|
||||
This allows you to:
|
||||
|
||||
- Use `config.toml` for base configuration
|
||||
- Override specific values with environment variables in production
|
||||
- Use `.env` files for local development without modifying config.toml
|
||||
|
||||
### Example
|
||||
|
||||
If you have this in `config.toml`:
|
||||
|
||||
```toml
|
||||
[db]
|
||||
CONNECTION_URI = "postgresql://localhost/honcho_dev"
|
||||
POOL_SIZE = 10
|
||||
```
|
||||
|
||||
You can override just the connection URI in production:
|
||||
|
||||
```bash
|
||||
export DB_CONNECTION_URI="postgresql://prod-server/honcho_prod"
|
||||
```
|
||||
|
||||
The application will use the production connection URI while keeping the pool size from config.toml.
|
||||
|
||||
## Core Configuration
|
||||
|
||||
### Application Settings
|
||||
|
||||
Application-level settings control core behavior of the Honcho server including logging, session limits, message handling, and optional integrations.
|
||||
|
||||
**Basic Application Configuration:**
|
||||
```bash
|
||||
# Logging and server settings
|
||||
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
||||
|
||||
# Session and context limits
|
||||
SESSION_OBSERVERS_LIMIT=10 # Maximum number of observers per session
|
||||
GET_CONTEXT_MAX_TOKENS=100000 # Maximum tokens for context retrieval
|
||||
MAX_MESSAGE_SIZE=25000 # Maximum message size in characters
|
||||
|
||||
# Embedding settings
|
||||
EMBED_MESSAGES=true # Enable vector embeddings for messages
|
||||
MAX_EMBEDDING_TOKENS=8192 # Maximum tokens per embedding
|
||||
MAX_EMBEDDING_TOKENS_PER_REQUEST=300000 # Batch embedding limit
|
||||
```
|
||||
|
||||
**Optional Integrations:**
|
||||
```bash
|
||||
# Langfuse integration for LLM observability
|
||||
LANGFUSE_HOST=https://cloud.langfuse.com
|
||||
LANGFUSE_PUBLIC_KEY=your-langfuse-public-key
|
||||
|
||||
# Local metrics collection
|
||||
COLLECT_METRICS_LOCAL=false
|
||||
LOCAL_METRICS_FILE=metrics.jsonl
|
||||
```
|
||||
|
||||
### Database Configuration
|
||||
|
||||
**Required Database Settings:**
|
||||
```bash
|
||||
# PostgreSQL connection string (required)
|
||||
DB_CONNECTION_URI=postgresql+psycopg://username:password@host:port/database
|
||||
|
||||
# Example for local development
|
||||
DB_CONNECTION_URI=postgresql+psycopg://postgres:postgres@localhost:5432/honcho
|
||||
|
||||
# Example for production
|
||||
DB_CONNECTION_URI=postgresql+psycopg://honcho_user:secure_password@db.example.com:5432/honcho_prod
|
||||
```
|
||||
|
||||
**Database Pool Settings:**
|
||||
```bash
|
||||
# Connection pool configuration
|
||||
DB_SCHEMA=public
|
||||
DB_POOL_SIZE=10
|
||||
DB_MAX_OVERFLOW=20
|
||||
DB_POOL_TIMEOUT=30
|
||||
DB_POOL_RECYCLE=300
|
||||
DB_POOL_PRE_PING=true
|
||||
DB_SQL_DEBUG=false
|
||||
DB_TRACING=false
|
||||
```
|
||||
|
||||
**Docker Compose for PostgreSQL:**
|
||||
```yaml
|
||||
# docker-compose.yml
|
||||
version: '3.8'
|
||||
services:
|
||||
database:
|
||||
image: pgvector/pgvector:pg15
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: honcho
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
```
|
||||
|
||||
### Authentication Configuration
|
||||
|
||||
**JWT Authentication:**
|
||||
```bash
|
||||
# Enable/disable authentication
|
||||
AUTH_USE_AUTH=false # Set to true for production
|
||||
|
||||
# JWT settings (required if AUTH_USE_AUTH is true)
|
||||
AUTH_JWT_SECRET=your-super-secret-jwt-key
|
||||
```
|
||||
|
||||
**Generate JWT Secret:**
|
||||
```bash
|
||||
# Generate a secure JWT secret
|
||||
python scripts/generate_jwt_secret.py
|
||||
```
|
||||
|
||||
### Cache Configuration
|
||||
|
||||
Honcho supports Redis caching to improve performance by caching frequently accessed data like peers, sessions, and working representations. Caching also includes lock mechanisms to prevent cache stampede scenarios.
|
||||
|
||||
**Redis Cache Settings:**
|
||||
```bash
|
||||
# Enable/disable Redis caching
|
||||
CACHE_ENABLED=false # Set to true to enable caching
|
||||
|
||||
# Redis connection
|
||||
CACHE_URL=redis://localhost:6379/0?suppress=true
|
||||
|
||||
# Cache namespace and TTL
|
||||
CACHE_NAMESPACE=honcho # Prefix for all cache keys
|
||||
CACHE_DEFAULT_TTL_SECONDS=300 # How long items stay in cache (5 minutes)
|
||||
|
||||
# Lock settings for preventing cache stampede
|
||||
CACHE_DEFAULT_LOCK_TTL_SECONDS=5 # Lock duration when fetching from DB on cache miss
|
||||
```
|
||||
|
||||
**When to Enable Caching:**
|
||||
- High-traffic production environments
|
||||
- Applications with many repeated reads of the same data
|
||||
- When you need to reduce database load
|
||||
|
||||
**Note:** Caching requires a Redis instance. You can run Redis locally with Docker:
|
||||
```bash
|
||||
docker run -d -p 6379:6379 redis:latest
|
||||
```
|
||||
|
||||
## LLM Provider Configuration
|
||||
|
||||
Honcho supports multiple LLM providers for different tasks. API keys are configured in the `[llm]` section, while specific features use their own configuration sections.
|
||||
|
||||
### API Keys
|
||||
|
||||
All provider API keys use the `LLM_` prefix:
|
||||
|
||||
```bash
|
||||
# Provider API Keys
|
||||
LLM_ANTHROPIC_API_KEY=your-anthropic-api-key
|
||||
LLM_OPENAI_API_KEY=your-openai-api-key
|
||||
LLM_GEMINI_API_KEY=your-gemini-api-key
|
||||
LLM_GROQ_API_KEY=your-groq-api-key
|
||||
|
||||
# OpenAI-compatible endpoints
|
||||
LLM_OPENAI_COMPATIBLE_API_KEY=your-api-key
|
||||
LLM_OPENAI_COMPATIBLE_BASE_URL=https://your-openai-compatible-endpoint.com
|
||||
```
|
||||
|
||||
### General LLM Settings
|
||||
|
||||
```bash
|
||||
# Default settings for all LLM calls
|
||||
LLM_DEFAULT_MAX_TOKENS=2500
|
||||
|
||||
# Embedding provider (used when EMBED_MESSAGES=true)
|
||||
LLM_EMBEDDING_PROVIDER=openai # Options: openai, gemini
|
||||
```
|
||||
|
||||
### Feature-Specific Model Configuration
|
||||
|
||||
Different features can use different providers and models:
|
||||
|
||||
**Dialectic API:**
|
||||
|
||||
The Dialectic API provides theory-of-mind informed responses by integrating long-term facts with current context.
|
||||
|
||||
```bash
|
||||
# Main dialectic model (default: Anthropic)
|
||||
DIALECTIC_PROVIDER=anthropic
|
||||
DIALECTIC_MODEL=claude-sonnet-4-20250514
|
||||
DIALECTIC_MAX_OUTPUT_TOKENS=2500
|
||||
DIALECTIC_THINKING_BUDGET_TOKENS=1024 # Only used with Anthropic provider
|
||||
DIALECTIC_CONTEXT_WINDOW_SIZE=100000 # Maximum context window tokens
|
||||
|
||||
# Query generation for dialectic searches
|
||||
DIALECTIC_PERFORM_QUERY_GENERATION=false # Enable query generation for semantic search
|
||||
DIALECTIC_QUERY_GENERATION_PROVIDER=groq
|
||||
DIALECTIC_QUERY_GENERATION_MODEL=llama-3.1-8b-instant
|
||||
|
||||
# Semantic search settings
|
||||
DIALECTIC_SEMANTIC_SEARCH_TOP_K=10 # Number of results to retrieve
|
||||
DIALECTIC_SEMANTIC_SEARCH_MAX_DISTANCE=0.85 # Maximum distance for relevance
|
||||
```
|
||||
|
||||
**Deriver (Theory of Mind):**
|
||||
|
||||
The Deriver is a background processing system that extracts facts from messages and builds theory-of-mind representations of peers.
|
||||
|
||||
```bash
|
||||
# LLM settings for deriver
|
||||
DERIVER_PROVIDER=google
|
||||
DERIVER_MODEL=gemini-2.5-flash-lite
|
||||
DERIVER_MAX_OUTPUT_TOKENS=10000
|
||||
DERIVER_THINKING_BUDGET_TOKENS=1024 # Only used with Anthropic provider
|
||||
DERIVER_MAX_INPUT_TOKENS=23000 # Maximum input tokens for deriver
|
||||
|
||||
# Worker settings
|
||||
DERIVER_WORKERS=1 # Number of background worker processes
|
||||
DERIVER_POLLING_SLEEP_INTERVAL_SECONDS=1.0 # Time between queue checks
|
||||
DERIVER_STALE_SESSION_TIMEOUT_MINUTES=5 # Timeout for stale sessions
|
||||
|
||||
# Queue management
|
||||
DERIVER_QUEUE_ERROR_RETENTION_SECONDS=2592000 # Keep errored items for 30 days
|
||||
|
||||
# Working representation settings
|
||||
DERIVER_WORKING_REPRESENTATION_MAX_OBSERVATIONS=50 # Max observations stored
|
||||
DERIVER_REPRESENTATION_BATCH_MAX_TOKENS=4096 # Max tokens per batch
|
||||
```
|
||||
|
||||
**Peer Card:**
|
||||
|
||||
Peer cards are short, structured summaries of peer identity and characteristics.
|
||||
|
||||
```bash
|
||||
# Enable/disable peer card generation
|
||||
PEER_CARD_ENABLED=true
|
||||
|
||||
# LLM settings for peer card generation
|
||||
PEER_CARD_PROVIDER=openai
|
||||
PEER_CARD_MODEL=gpt-5-nano-2025-08-07
|
||||
PEER_CARD_MAX_OUTPUT_TOKENS=4000 # Includes thinking tokens for GPT-5 models
|
||||
```
|
||||
|
||||
**Summary Generation:**
|
||||
|
||||
Session summaries provide compressed context for long conversations. Honcho creates two types: short summaries (frequent) and long summaries (comprehensive).
|
||||
|
||||
```bash
|
||||
# Enable/disable summarization
|
||||
SUMMARY_ENABLED=true
|
||||
|
||||
# LLM settings for summary generation
|
||||
SUMMARY_PROVIDER=openai
|
||||
SUMMARY_MODEL=gpt-4o-mini-2024-07-18
|
||||
SUMMARY_MAX_TOKENS_SHORT=1000 # Max tokens for short summaries
|
||||
SUMMARY_MAX_TOKENS_LONG=4000 # Max tokens for long summaries
|
||||
SUMMARY_THINKING_BUDGET_TOKENS=512 # Only used with Anthropic provider
|
||||
|
||||
# Summary frequency thresholds
|
||||
SUMMARY_MESSAGES_PER_SHORT_SUMMARY=20 # Create short summary every N messages
|
||||
SUMMARY_MESSAGES_PER_LONG_SUMMARY=60 # Create long summary every N messages
|
||||
```
|
||||
|
||||
### Default Provider Usage
|
||||
|
||||
By default, Honcho uses:
|
||||
- **Anthropic** (Claude) for dialectic API responses
|
||||
- **Groq** for query generation (fast, cost-effective)
|
||||
- **Google** (Gemini) for theory of mind derivation
|
||||
- **OpenAI** (GPT) for peer cards and summarization
|
||||
- **OpenAI** for embeddings (if `EMBED_MESSAGES=true`)
|
||||
|
||||
You only need to set the API keys for the providers you plan to use. All providers are configurable per feature.
|
||||
|
||||
## Additional Features Configuration
|
||||
|
||||
### Dream Processing
|
||||
|
||||
Dream processing consolidates and refines peer representations during idle periods, similar to how human memory consolidation works during sleep.
|
||||
|
||||
**Dream Settings:**
|
||||
```bash
|
||||
# Enable/disable dream processing
|
||||
DREAM_ENABLED=true
|
||||
|
||||
# Trigger thresholds
|
||||
DREAM_DOCUMENT_THRESHOLD=50 # Minimum documents to trigger a dream
|
||||
DREAM_IDLE_TIMEOUT_MINUTES=60 # Minutes of inactivity before dream can start
|
||||
DREAM_MIN_HOURS_BETWEEN_DREAMS=8 # Minimum hours between dreams for a peer
|
||||
|
||||
# Dream types to enable
|
||||
DREAM_ENABLED_TYPES=["consolidate"] # Currently supported: consolidate
|
||||
|
||||
# LLM settings for dream processing
|
||||
DREAM_PROVIDER=openai
|
||||
DREAM_MODEL=gpt-4o-mini-2024-07-18
|
||||
DREAM_MAX_OUTPUT_TOKENS=2000
|
||||
```
|
||||
|
||||
### Webhook Configuration
|
||||
|
||||
Webhooks allow you to receive real-time notifications when events occur in Honcho (e.g., new messages, session updates).
|
||||
|
||||
**Webhook Settings:**
|
||||
```bash
|
||||
# Webhook secret for signing payloads (optional but recommended)
|
||||
WEBHOOK_SECRET=your-webhook-signing-secret
|
||||
|
||||
# Limit on webhooks per workspace
|
||||
WEBHOOK_MAX_WORKSPACE_LIMIT=10
|
||||
```
|
||||
|
||||
### Metrics Collection
|
||||
|
||||
Enable metrics collection for monitoring Honcho performance and usage.
|
||||
|
||||
**Metrics Settings:**
|
||||
```bash
|
||||
# Enable/disable metrics collection
|
||||
METRICS_ENABLED=false
|
||||
|
||||
# Namespace for metrics (used in metric names)
|
||||
METRICS_NAMESPACE=honcho
|
||||
```
|
||||
|
||||
## Monitoring Configuration
|
||||
|
||||
### Sentry Error Tracking
|
||||
|
||||
**Sentry Settings:**
|
||||
```bash
|
||||
# Enable/disable Sentry error tracking
|
||||
SENTRY_ENABLED=false
|
||||
|
||||
# Sentry configuration
|
||||
SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
|
||||
SENTRY_RELEASE=2.4.0 # Optional: track which version errors come from
|
||||
SENTRY_ENVIRONMENT=production # Environment name (development, staging, production)
|
||||
|
||||
# Sampling rates (0.0 to 1.0)
|
||||
SENTRY_TRACES_SAMPLE_RATE=0.1 # 10% of transactions tracked
|
||||
SENTRY_PROFILES_SAMPLE_RATE=0.1 # 10% of transactions profiled
|
||||
```
|
||||
|
||||
## Environment-Specific Examples
|
||||
|
||||
### Development Configuration
|
||||
|
||||
**config.toml for development:**
|
||||
```toml
|
||||
[app]
|
||||
LOG_LEVEL = "DEBUG"
|
||||
SESSION_OBSERVERS_LIMIT = 10
|
||||
EMBED_MESSAGES = false
|
||||
|
||||
[db]
|
||||
CONNECTION_URI = "postgresql+psycopg://postgres:postgres@localhost:5432/honcho_dev"
|
||||
POOL_SIZE = 5
|
||||
|
||||
[auth]
|
||||
USE_AUTH = false
|
||||
|
||||
[cache]
|
||||
ENABLED = false
|
||||
|
||||
[dialectic]
|
||||
PROVIDER = "anthropic"
|
||||
MODEL = "claude-sonnet-4-20250514"
|
||||
PERFORM_QUERY_GENERATION = false
|
||||
MAX_OUTPUT_TOKENS = 2500
|
||||
|
||||
[deriver]
|
||||
WORKERS = 1
|
||||
PROVIDER = "google"
|
||||
MODEL = "gemini-2.5-flash-lite"
|
||||
|
||||
[peer_card]
|
||||
ENABLED = true
|
||||
PROVIDER = "openai"
|
||||
MODEL = "gpt-5-nano-2025-08-07"
|
||||
|
||||
[summary]
|
||||
ENABLED = true
|
||||
PROVIDER = "openai"
|
||||
MODEL = "gpt-4o-mini-2024-07-18"
|
||||
MAX_TOKENS_SHORT = 1000
|
||||
MAX_TOKENS_LONG = 4000
|
||||
|
||||
[dream]
|
||||
ENABLED = true
|
||||
|
||||
[webhook]
|
||||
MAX_WORKSPACE_LIMIT = 10
|
||||
|
||||
[metrics]
|
||||
ENABLED = false
|
||||
|
||||
[sentry]
|
||||
ENABLED = false
|
||||
```
|
||||
|
||||
**Environment variables for development:**
|
||||
```bash
|
||||
# .env.development
|
||||
LOG_LEVEL=DEBUG
|
||||
DB_CONNECTION_URI=postgresql+psycopg://postgres:postgres@localhost:5432/honcho_dev
|
||||
AUTH_USE_AUTH=false
|
||||
CACHE_ENABLED=false
|
||||
|
||||
# LLM Provider API Keys
|
||||
LLM_ANTHROPIC_API_KEY=your-dev-anthropic-key
|
||||
LLM_OPENAI_API_KEY=your-dev-openai-key
|
||||
LLM_GEMINI_API_KEY=your-dev-gemini-key
|
||||
```
|
||||
|
||||
### Production Configuration
|
||||
|
||||
**config.toml for production:**
|
||||
```toml
|
||||
[app]
|
||||
LOG_LEVEL = "WARNING"
|
||||
SESSION_OBSERVERS_LIMIT = 10
|
||||
EMBED_MESSAGES = true
|
||||
|
||||
[db]
|
||||
CONNECTION_URI = "postgresql+psycopg://honcho_user:secure_password@prod-db:5432/honcho_prod"
|
||||
POOL_SIZE = 20
|
||||
MAX_OVERFLOW = 40
|
||||
|
||||
[auth]
|
||||
USE_AUTH = true
|
||||
|
||||
[cache]
|
||||
ENABLED = true
|
||||
URL = "redis://redis:6379/0"
|
||||
DEFAULT_TTL_SECONDS = 300
|
||||
|
||||
[dialectic]
|
||||
PROVIDER = "anthropic"
|
||||
MODEL = "claude-sonnet-4-20250514"
|
||||
PERFORM_QUERY_GENERATION = false
|
||||
MAX_OUTPUT_TOKENS = 2500
|
||||
|
||||
[deriver]
|
||||
WORKERS = 4
|
||||
PROVIDER = "google"
|
||||
MODEL = "gemini-2.5-flash-lite"
|
||||
|
||||
[peer_card]
|
||||
ENABLED = true
|
||||
PROVIDER = "openai"
|
||||
MODEL = "gpt-5-nano-2025-08-07"
|
||||
|
||||
[summary]
|
||||
ENABLED = true
|
||||
PROVIDER = "openai"
|
||||
MODEL = "gpt-4o-mini-2024-07-18"
|
||||
MAX_TOKENS_SHORT = 1000
|
||||
MAX_TOKENS_LONG = 4000
|
||||
|
||||
[dream]
|
||||
ENABLED = true
|
||||
PROVIDER = "openai"
|
||||
MODEL = "gpt-4o-mini-2024-07-18"
|
||||
|
||||
[webhook]
|
||||
MAX_WORKSPACE_LIMIT = 10
|
||||
|
||||
[metrics]
|
||||
ENABLED = true
|
||||
|
||||
[sentry]
|
||||
ENABLED = true
|
||||
ENVIRONMENT = "production"
|
||||
TRACES_SAMPLE_RATE = 0.1
|
||||
PROFILES_SAMPLE_RATE = 0.1
|
||||
```
|
||||
|
||||
**Environment variables for production:**
|
||||
```bash
|
||||
# .env.production
|
||||
LOG_LEVEL=WARNING
|
||||
DB_CONNECTION_URI=postgresql+psycopg://honcho_user:secure_password@prod-db:5432/honcho_prod
|
||||
|
||||
# Authentication
|
||||
AUTH_USE_AUTH=true
|
||||
AUTH_JWT_SECRET=your-super-secret-jwt-key
|
||||
|
||||
# Cache
|
||||
CACHE_ENABLED=true
|
||||
CACHE_URL=redis://redis:6379/0
|
||||
|
||||
# LLM Provider API Keys
|
||||
LLM_ANTHROPIC_API_KEY=your-prod-anthropic-key
|
||||
LLM_OPENAI_API_KEY=your-prod-openai-key
|
||||
LLM_GEMINI_API_KEY=your-prod-gemini-key
|
||||
LLM_GROQ_API_KEY=your-prod-groq-key
|
||||
|
||||
# Webhooks
|
||||
WEBHOOK_SECRET=your-webhook-signing-secret
|
||||
|
||||
# Monitoring
|
||||
SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
|
||||
SENTRY_ENVIRONMENT=production
|
||||
```
|
||||
|
||||
## Migration Management
|
||||
|
||||
**Running Database Migrations:**
|
||||
```bash
|
||||
# Check current migration status
|
||||
uv run alembic current
|
||||
|
||||
# Upgrade to latest
|
||||
uv run alembic upgrade head
|
||||
|
||||
# Downgrade to specific revision
|
||||
uv run alembic downgrade revision_id
|
||||
|
||||
# Create new migration
|
||||
uv run alembic revision --autogenerate -m "Description of changes"
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Common Configuration Issues:**
|
||||
|
||||
1. **Database Connection Errors**
|
||||
- Ensure `DB_CONNECTION_URI` uses `postgresql+psycopg://` prefix
|
||||
- Verify database is running and accessible
|
||||
- Check pgvector extension is installed
|
||||
|
||||
2. **Authentication Issues**
|
||||
- Set `AUTH_USE_AUTH=true` for production
|
||||
- Generate and set `AUTH_JWT_SECRET` if authentication is enabled
|
||||
- Use `python scripts/generate_jwt_secret.py` to create a secure secret
|
||||
|
||||
3. **LLM Provider Issues**
|
||||
- Verify API keys are set correctly
|
||||
- Check model names match provider specifications
|
||||
- Ensure provider is enabled in configuration
|
||||
|
||||
4. **Deriver Issues**
|
||||
- Increase `DERIVER_WORKERS` for better performance
|
||||
- Check `DERIVER_STALE_SESSION_TIMEOUT_MINUTES` for session cleanup
|
||||
- Monitor background processing logs
|
||||
|
||||
This configuration guide covers all the settings available in Honcho. Always use environment-specific configuration files and never commit sensitive values like API keys or JWT secrets to version control.
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
---
|
||||
title: 'Contributing Guidelines'
|
||||
icon: 'handshake'
|
||||
---
|
||||
|
||||
Thank you for your interest in contributing to Honcho! This guide outlines the process for contributing to the project and our development conventions.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Before you start contributing, please:
|
||||
|
||||
1. **Set up your development environment** - Follow the [Local Development guide](https://github.com/plastic-labs/honcho/blob/main/CONTRIBUTING.md#local-development) in the Honcho repository to get Honcho running locally.
|
||||
|
||||
2. **Join our community** - Feel free to join us in our [Discord](http://discord.gg/plasticlabs) to discuss your changes, get help, or ask questions.
|
||||
|
||||
3. **Review existing issues** - Check the [issues tab](https://github.com/plastic-labs/honcho/issues) to see what's already being worked on or to find something to contribute to.
|
||||
|
||||
## Contribution Workflow
|
||||
|
||||
### 1. Fork and Clone
|
||||
|
||||
1. Fork the repository on GitHub
|
||||
2. Clone your fork locally:
|
||||
```bash
|
||||
git clone https://github.com/YOUR_USERNAME/honcho.git
|
||||
cd honcho
|
||||
```
|
||||
3. Add the upstream repository as a remote:
|
||||
```bash
|
||||
git remote add upstream https://github.com/plastic-labs/honcho.git
|
||||
```
|
||||
|
||||
### 2. Create a Branch
|
||||
|
||||
Create a new branch for your feature or bug fix:
|
||||
|
||||
```bash
|
||||
git checkout -b feature/your-feature-name
|
||||
# or
|
||||
git checkout -b fix/your-bug-fix-name
|
||||
```
|
||||
|
||||
**Branch naming conventions:**
|
||||
- `feature/description` - for new features
|
||||
- `fix/description` - for bug fixes
|
||||
- `docs/description` - for documentation updates
|
||||
- `refactor/description` - for code refactoring
|
||||
- `test/description` - for adding or updating tests
|
||||
|
||||
### 3. Make Your Changes
|
||||
|
||||
- Write clean, readable code that follows our coding standards (see below)
|
||||
- Add tests for new functionality
|
||||
- Update documentation as needed
|
||||
- Make sure your changes don't break existing functionality
|
||||
|
||||
### 4. Commit Your Changes
|
||||
|
||||
We follow conventional commit standards. Format your commit messages as:
|
||||
|
||||
```
|
||||
type(scope): description
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer]
|
||||
```
|
||||
|
||||
**Types:**
|
||||
- `feat`: A new feature
|
||||
- `fix`: A bug fix
|
||||
- `docs`: Documentation only changes
|
||||
- `style`: Changes that do not affect the meaning of the code
|
||||
- `refactor`: A code change that neither fixes a bug nor adds a feature
|
||||
- `test`: Adding missing tests or correcting existing tests
|
||||
- `chore`: Changes to the build process or auxiliary tools
|
||||
|
||||
**Examples:**
|
||||
```bash
|
||||
git commit -m "feat(api): add new dialectic endpoint for user insights"
|
||||
git commit -m "fix(db): resolve connection pool timeout issue"
|
||||
git commit -m "docs(readme): update installation instructions"
|
||||
```
|
||||
|
||||
### 5. Submit a Pull Request
|
||||
|
||||
1. Push your branch to your fork:
|
||||
```bash
|
||||
git push origin your-branch-name
|
||||
```
|
||||
|
||||
2. Create a pull request on GitHub from your branch to the `main` branch
|
||||
|
||||
3. Fill out the pull request template with:
|
||||
- A clear description of what changes you've made
|
||||
- The motivation for the changes
|
||||
- Any relevant issue numbers (use "Closes #123" to auto-close issues)
|
||||
- Screenshots or examples if applicable
|
||||
|
||||
## Coding Standards
|
||||
|
||||
### Python Code Style
|
||||
|
||||
- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guidelines
|
||||
- Use [Black](https://black.readthedocs.io/) for code formatting (we may add this to CI in the future)
|
||||
- Use type hints where possible
|
||||
- Write docstrings for functions and classes using Google style docstrings
|
||||
|
||||
### Code Organization
|
||||
|
||||
- Keep functions focused and single-purpose
|
||||
- Use meaningful variable and function names
|
||||
- Add comments for complex logic
|
||||
- Follow existing patterns in the codebase
|
||||
|
||||
### Testing
|
||||
|
||||
- Write unit tests for new functionality
|
||||
- Ensure existing tests pass before submitting
|
||||
- Use descriptive test names that explain what is being tested
|
||||
- Mock external dependencies appropriately
|
||||
|
||||
### Documentation
|
||||
|
||||
- Update relevant documentation for new features
|
||||
- Include examples in docstrings where helpful
|
||||
- Keep README and other docs up to date with changes
|
||||
|
||||
## Review Process
|
||||
|
||||
1. **Automated checks** - Your PR will run through automated checks including tests and linting
|
||||
2. **Project maintainer review** - A project maintainer will review your code for:
|
||||
- Code quality and adherence to standards
|
||||
- Functionality and correctness
|
||||
- Test coverage
|
||||
- Documentation completeness
|
||||
3. **Discussion and iteration** - You may be asked to make changes or clarifications
|
||||
4. **Approval and merge** - Once approved, your PR will be merged into `main`
|
||||
|
||||
## Types of Contributions
|
||||
|
||||
We welcome various types of contributions:
|
||||
|
||||
- **Bug fixes** - Help us squash bugs and improve stability
|
||||
- **New features** - Add functionality that benefits the community
|
||||
- **Documentation** - Improve or expand our documentation
|
||||
- **Tests** - Increase test coverage and reliability
|
||||
- **Performance improvements** - Help make Honcho faster and more efficient
|
||||
- **Examples and tutorials** - Help other developers use Honcho
|
||||
|
||||
## Issue Reporting
|
||||
|
||||
When reporting bugs or requesting features:
|
||||
|
||||
1. Check if the issue already exists
|
||||
2. Use the appropriate issue template
|
||||
3. Provide clear reproduction steps for bugs
|
||||
4. Include relevant environment information
|
||||
5. Be specific about expected vs actual behavior
|
||||
|
||||
## Questions and Support
|
||||
|
||||
- **General questions** - Join our [Discord](http://discord.gg/plasticlabs)
|
||||
- **Bug reports** - Use GitHub issues
|
||||
- **Feature requests** - Use GitHub issues with the feature request template
|
||||
- **Security issues** - Please email us privately rather than opening a public issue
|
||||
|
||||
## License
|
||||
|
||||
By contributing to Honcho, you agree that your contributions will be licensed under the same [AGPL-3.0 License](./license) that covers the project.
|
||||
|
||||
Thank you for helping make Honcho better! 🫡
|
||||
|
|
@ -0,0 +1,671 @@
|
|||
---
|
||||
title: 'License'
|
||||
icon: 'scroll'
|
||||
---
|
||||
|
||||
Honcho is licensed under the AGPL-3.0 License. This is copied below for convenience and also present in the
|
||||
[GitHub Repository](https://github.com/plastic-labs/honcho)
|
||||
|
||||
```
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
|
@ -0,0 +1,324 @@
|
|||
---
|
||||
title: 'Local Environment Setup'
|
||||
sidebarTitle: 'Local Environment'
|
||||
description: 'Set up a local environment to run Honcho for development, testing, or self-hosting'
|
||||
icon: 'computer'
|
||||
---
|
||||
|
||||
This guide helps you set up a local environment to run Honcho for development, testing, or self-hosting.
|
||||
|
||||
## Overview
|
||||
|
||||
By the end of this guide, you'll have:
|
||||
- A local Honcho server running on your machine
|
||||
- A PostgreSQL database with pgvector extension
|
||||
- Basic configuration to connect your applications
|
||||
- A working environment for development or testing
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, ensure you have the following installed:
|
||||
|
||||
### Required Software
|
||||
- **uv** - Python package manager: `pip install uv` (manages Python installations automatically)
|
||||
- **Git** - [Download from git-scm.com](https://git-scm.com/downloads)
|
||||
- **Docker** (optional) - [Download from docker.com](https://www.docker.com/products/docker-desktop/)
|
||||
|
||||
### Database Options
|
||||
You'll need a PostgreSQL database with the pgvector extension. Choose one:
|
||||
|
||||
- **Local PostgreSQL** - Install locally or use Docker
|
||||
- **Supabase** - Free cloud PostgreSQL with pgvector
|
||||
- **Railway** - Simple cloud PostgreSQL hosting
|
||||
- **Your own PostgreSQL server**
|
||||
|
||||
## Docker Setup (Recommended)
|
||||
|
||||
The easiest way to get started is using Docker Compose, which handles both the database and Honcho server.
|
||||
|
||||
### 1. Clone the Repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/plastic-labs/honcho.git
|
||||
cd honcho
|
||||
```
|
||||
|
||||
### 2. Set Up Environment Variables
|
||||
|
||||
Copy the example environment file and configure it:
|
||||
|
||||
```bash
|
||||
cp .env.template .env
|
||||
```
|
||||
|
||||
Edit `.env` and set your API keys (if using LLM features):
|
||||
|
||||
```bash
|
||||
# Optional API keys (required for LLM features)
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
ANTHROPIC_API_KEY=your-anthropic-api-key
|
||||
|
||||
# Database will be created automatically by Docker
|
||||
DB_CONNECTION_URI=postgresql+psycopg://postgres:postgres@database:5432/honcho
|
||||
|
||||
# Disable auth for local development
|
||||
AUTH_USE_AUTH=false
|
||||
```
|
||||
|
||||
### 3. Start the Services
|
||||
|
||||
```bash
|
||||
# Copy the example docker-compose file
|
||||
cp docker-compose.yml.example docker-compose.yml
|
||||
|
||||
# Start PostgreSQL and Honcho
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 4. Verify It's Working
|
||||
|
||||
Check that both services are running:
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
```
|
||||
|
||||
Test the Honcho API:
|
||||
|
||||
```bash
|
||||
curl http://localhost:8000/health
|
||||
```
|
||||
|
||||
You should see a response indicating the service is healthy.
|
||||
|
||||
## Manual Setup
|
||||
|
||||
For more control over your environment, you can set up everything manually.
|
||||
|
||||
### 1. Clone and Install Dependencies
|
||||
|
||||
```bash
|
||||
git clone https://github.com/plastic-labs/honcho.git
|
||||
cd honcho
|
||||
|
||||
# Install dependencies using uv (this will also set up Python if needed)
|
||||
uv sync
|
||||
|
||||
# Activate the virtual environment
|
||||
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
||||
```
|
||||
|
||||
### 2. Set Up PostgreSQL
|
||||
|
||||
#### Option A: Local PostgreSQL Installation
|
||||
|
||||
Install PostgreSQL and pgvector on your system:
|
||||
|
||||
**macOS (using Homebrew):**
|
||||
```bash
|
||||
brew install postgresql
|
||||
brew install pgvector
|
||||
```
|
||||
|
||||
**Ubuntu/Debian:**
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install postgresql postgresql-contrib
|
||||
# Install pgvector extension (see pgvector docs for your version)
|
||||
```
|
||||
|
||||
**Windows:**
|
||||
Download from [postgresql.org](https://www.postgresql.org/download/windows/)
|
||||
|
||||
#### Option B: Docker PostgreSQL
|
||||
|
||||
```bash
|
||||
docker run --name honcho-db \
|
||||
-e POSTGRES_DB=honcho \
|
||||
-e POSTGRES_USER=postgres \
|
||||
-e POSTGRES_PASSWORD=postgres \
|
||||
-p 5432:5432 \
|
||||
-d pgvector/pgvector:pg15
|
||||
```
|
||||
|
||||
### 3. Create Database and Enable Extensions
|
||||
|
||||
Connect to PostgreSQL and set up the database:
|
||||
|
||||
```bash
|
||||
# Connect to PostgreSQL
|
||||
psql -U postgres
|
||||
|
||||
# Create database and enable extensions
|
||||
CREATE DATABASE honcho;
|
||||
\c honcho
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
\q
|
||||
```
|
||||
|
||||
### 4. Configure Environment
|
||||
|
||||
Create a `.env` file with your settings:
|
||||
|
||||
```bash
|
||||
cp .env.template .env
|
||||
```
|
||||
|
||||
Edit `.env` with your configuration:
|
||||
|
||||
```bash
|
||||
# Database connection
|
||||
DB_CONNECTION_URI=postgresql+psycopg://postgres:postgres@localhost:5432/honcho
|
||||
|
||||
# Optional API keys (required for LLM features)
|
||||
OPENAI_API_KEY=your-openai-api-key
|
||||
ANTHROPIC_API_KEY=your-anthropic-api-key
|
||||
|
||||
# Development settings
|
||||
AUTH_USE_AUTH=false
|
||||
LOG_LEVEL=DEBUG
|
||||
```
|
||||
|
||||
### 5. Run Database Migrations
|
||||
|
||||
```bash
|
||||
# Run migrations to create tables
|
||||
uv run alembic upgrade head
|
||||
```
|
||||
|
||||
### 6. Start the Server
|
||||
|
||||
```bash
|
||||
# Start the development server
|
||||
fastapi dev src/main.py
|
||||
```
|
||||
|
||||
The server will be available at `http://localhost:8000`.
|
||||
|
||||
## Cloud Database Setup
|
||||
|
||||
If you prefer to use a managed PostgreSQL service:
|
||||
|
||||
### Supabase (Recommended)
|
||||
|
||||
1. **Create a Supabase project** at [supabase.com](https://supabase.com)
|
||||
2. **Enable pgvector extension** in the SQL editor:
|
||||
```sql
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
```
|
||||
3. **Get your connection string** from Settings > Database
|
||||
4. **Update your `.env` file** with the connection string
|
||||
|
||||
### Railway
|
||||
|
||||
1. **Create a Railway project** at [railway.app](https://railway.app)
|
||||
2. **Add a PostgreSQL service**
|
||||
3. **Enable pgvector** in the PostgreSQL console
|
||||
4. **Get your connection string** from the service variables
|
||||
5. **Update your `.env` file**
|
||||
|
||||
## Verify Your Setup
|
||||
|
||||
Once your Honcho server is running, verify everything is working:
|
||||
|
||||
### 1. Health Check
|
||||
|
||||
```bash
|
||||
curl http://localhost:8000/health
|
||||
```
|
||||
|
||||
### 2. API Documentation
|
||||
|
||||
Visit `http://localhost:8000/docs` to see the interactive API documentation.
|
||||
|
||||
### 3. Test with SDK
|
||||
|
||||
Create a simple test script:
|
||||
|
||||
```python
|
||||
from honcho import Honcho
|
||||
|
||||
# Connect to your local instance
|
||||
client = Honcho(base_url="http://localhost:8000")
|
||||
|
||||
# Create a test peer
|
||||
peer = client.peer("test-user")
|
||||
print(f"Created peer: {peer.id}")
|
||||
```
|
||||
|
||||
## Connect Your Application
|
||||
|
||||
Now that Honcho is running locally, you can connect your applications:
|
||||
|
||||
### Update SDK Configuration
|
||||
|
||||
```python
|
||||
# Python SDK
|
||||
from honcho import Honcho
|
||||
|
||||
client = Honcho(
|
||||
base_url="http://localhost:8000", # Your local instance
|
||||
api_key="your-api-key" # If auth is enabled
|
||||
)
|
||||
```
|
||||
|
||||
```typescript
|
||||
// TypeScript SDK
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
const client = new Honcho({
|
||||
baseUrl: 'http://localhost:8000', // Your local instance
|
||||
apiKey: 'your-api-key' // If auth is enabled
|
||||
});
|
||||
```
|
||||
|
||||
### Next Steps
|
||||
|
||||
- **Explore the API**: Check out the [API Reference](/v2.6.0-alpha/api-reference/introduction)
|
||||
- **Try the SDKs**: See our [guides](/v2.6.0-alpha/guides) for examples
|
||||
- **Configure Honcho**: Visit the [Configuration Guide](./configuration) for detailed settings
|
||||
- **Join the community**: [Discord](https://discord.gg/plasticlabs)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Database Connection Errors**
|
||||
- Ensure PostgreSQL is running
|
||||
- Verify the connection string format: `postgresql+psycopg://...`
|
||||
- Check that pgvector extension is installed
|
||||
|
||||
**API Key Issues**
|
||||
- Verify your OpenAI and Anthropic API keys are valid
|
||||
- Check that the keys have sufficient credits/quota
|
||||
|
||||
**Port Already in Use**
|
||||
- Pass a different port to FastAPI or stop other services using port 8000
|
||||
|
||||
**Docker Issues**
|
||||
- Ensure Docker is running
|
||||
- Check container logs: `docker compose logs`
|
||||
- Restart containers: `docker compose down && docker compose up -d`
|
||||
|
||||
**Migration Errors**
|
||||
- Ensure the database exists and pgvector is enabled
|
||||
- Check database permissions
|
||||
- Run migrations manually: `uv run alembic upgrade head`
|
||||
|
||||
### Getting Help
|
||||
|
||||
- **GitHub Issues**: [Report bugs](https://github.com/plastic-labs/honcho/issues)
|
||||
- **Discord**: [Join our community](https://discord.gg/plasticlabs)
|
||||
- **Documentation**: Check the [Configuration Guide](./configuration) for detailed settings
|
||||
|
||||
## Production Considerations
|
||||
|
||||
When self-hosting for production, consider:
|
||||
|
||||
- **Security**: Enable authentication, use HTTPS, secure your database
|
||||
- **Scaling**: Use connection pooling, consider load balancing
|
||||
- **Monitoring**: Set up logging, error tracking, health checks
|
||||
- **Backups**: Regular database backups, disaster recovery plan
|
||||
- **Updates**: Keep Honcho and dependencies updated
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
---
|
||||
title: "Architecture & Intuition"
|
||||
description: "Understanding Honcho's core concepts and data model."
|
||||
icon: "sitemap"
|
||||
sidebarTitle: "Architecture"
|
||||
---
|
||||
|
||||
Honcho is memory infrastructure that continuously [*reasons*](/v2.6.0-alpha/documentation/core-concepts/reasoning) about data to build rich representations of peers (users, agents, or any entity) over time. This document explains the data model, system components, and how data flows through Honcho.
|
||||
|
||||
## Data Model
|
||||
|
||||
Honcho has a hierarchical data model centered around the entities below.
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
W[Workspaces] -->|have| P[Peers]
|
||||
W -->|have| S[Sessions]
|
||||
|
||||
S -->|have| SM[Messages]
|
||||
|
||||
P <-.->|many-to-many| S
|
||||
|
||||
style W fill:#B6DBFF,stroke:#333,color:#000
|
||||
style P fill:#B6DBFF,stroke:#333,color:#000
|
||||
style S fill:#B6DBFF,stroke:#333,color:#000
|
||||
style SM fill:#B6DBFF,stroke:#333,color:#000
|
||||
```
|
||||
|
||||
- A Workspace has Peers & Sessions
|
||||
- A Peer can be in multiple Sessions and can send Messages in a Session
|
||||
- A Session can have many Peers and stores Messages sent by its Peers
|
||||
|
||||
### <Icon icon="building" /> Workspaces
|
||||
|
||||
Workspaces are the top-level containers in Honcho. They provide complete isolation between different applications or environments, essentially serving as a namespace to keep different workloads separate. You might use separate workspaces for development, staging, and production environments, or to isolate different product lines. They also enable multi-tenant SaaS applications where each customer gets their own isolated workspace with complete data separation.
|
||||
|
||||
Authentication is scoped to the workspace level, and configuration settings can be applied workspace-wide to control behavior across all peers and sessions within that workspace.
|
||||
|
||||
---
|
||||
|
||||
### <Icon icon="user" /> Peers
|
||||
|
||||
Peers are the most important entity in Honcho--everything revolves around building and maintaining their [*representations*](/v2.6.0-alpha/documentation/core-concepts/representation). A peer represents any individual user, agent, or entity in a workspace. Treating humans and agents the same way lets you build arbitrary combinations for multi-agent or group chat scenarios.
|
||||
|
||||
Each peer has a unique identifier within a workspace and is a container for reasoning across all their sessions. This cross-session context means conclusions drawn about a peer in one session can inform interactions in completely different sessions. Peers can be configured to control whether Honcho reasons about them.
|
||||
|
||||
You can use peers for any entity that persists over time--individual users in chatbot applications, AI agents interacting with users or other agents, customer profiles in support systems, student profiles in educational platforms, or even NPCs in role-playing games.
|
||||
|
||||
---
|
||||
|
||||
### <Icon icon="message" /> Sessions
|
||||
|
||||
Sessions represent interaction threads or contexts between peers. A session can involve multiple peers and provides temporal boundaries for when a set of interactions starts and ends. This lets you scope context and memory to specific interactions while still maintaining longer-term peer representations that span sessions.
|
||||
|
||||
Use sessions to scope things like support tickets, meeting transcripts, learning sessions, or conversations. You can also use single-peer sessions as a way to import external data--create a session with just one peer and structure emails, documents, or files as messages to enrich that peer's representation.
|
||||
|
||||
Session-level configuration gives you fine-grained control over perspective-taking behavior. You can configure whether a peer should form representations of other peers in the session, and whether other peers should form representations of them.
|
||||
|
||||
---
|
||||
|
||||
### <Icon icon="envelope" /> Messages
|
||||
|
||||
Messages are the fundamental units of interaction within sessions. While they typically represent back-and-forth communication between peers, you can also use messages to ingest any information that provides context--emails, documents, files, user actions, system notifications, or rich media content.
|
||||
|
||||
Every message is attributed to a specific peer and ordered chronologically within its session. When messages are created, they trigger automatic background reasoning that updates peer representations. Messages support rich metadata and structured data through JSONB fields, making them flexible enough to capture whatever information matters for your use case.
|
||||
|
||||
## Data Flow
|
||||
|
||||
Understanding how data moves through Honcho helps clarify the architecture.
|
||||
|
||||
When you create messages, they're immediately written to PostgreSQL and reasoning tasks are added to background queues. Background workers then generate logic, summaries, and new insights to improve representations. These conclusions and insights get stored in vector collections for retrieval. This async approach ensures fast writes while still providing rich reasoning capabilities.
|
||||
|
||||
When you need context from Honcho, you query through the "Chat" endpoint or "Get Context" endpoint. Honcho retrieves relevant conclusions from vector storage along with recent messages, then assembles everything into coherent context ready to inject into agent prompts.
|
||||
|
||||

|
||||
|
||||
The diagram above shows how agents write messages to Honcho, which triggers reasoning that updates peer representations. Agents can then query representations to get additional context for their next response. Black arrows represent read/write of regular data (messages, storage), while red arrows represent read/write of reasoned-over data (logic, peer representations).
|
||||
|
||||
## Configuration & Extensibility
|
||||
|
||||
Honcho is designed to be flexible. Settings cascade hierarchically from workspace to peer to session, so you can set defaults at the workspace level and override them for specific peers or sessions. Feature flags let you enable or disable reasoning modes, perspective tracking, and other capabilities. You can bring your own LLM provider--OpenAI, Anthropic, or custom endpoints--and metadata fields let you extend any primitive with custom JSON data. Batch operations let you create up to 100 messages in a single API call for efficient bulk ingestion.
|
||||
|
||||
## Design Principles
|
||||
|
||||
Honcho's architecture follows a few core principles. Everything revolves around building representations of peers (peer-centric). Memory isn't just storage--it's continual learning (reasoning-first). Long-lived operations happen in the background so they don't block user interactions (async by default). The system works with any LLM provider (provider-agnostic) and is built for isolation and scalability from the ground up (multi-tenant). Users and agents are both represented as peers, which enables flexible scenarios you couldn't easily model with a traditional user-assistant paradigm (unified paradigm).
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Get an API Key" icon="key" href="https://app.honcho.dev">
|
||||
Sign up for the Honcho platform and start building
|
||||
</Card>
|
||||
<Card title="Quickstart" icon="rocket" href="/v2.6.0-alpha/documentation/introduction/quickstart">
|
||||
Get started with your first integration
|
||||
</Card>
|
||||
<Card title="Reasoning" icon="gears" href="/v2.6.0-alpha/documentation/core-concepts/reasoning">
|
||||
Learn how Honcho reasons about messages to build memory
|
||||
</Card>
|
||||
<Card title="Peer Representations" icon="user-magnifying-glass" href="/v2.6.0-alpha/documentation/core-concepts/representation">
|
||||
Understand what peer representations are and how they work
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -84,13 +84,13 @@ Without exhaustive reasoning, you're stuck with surface-level retrieval or someo
|
|||
<Card title="Get an API Key" icon="key" href="https://app.honcho.dev">
|
||||
Sign up for the Honcho platform and start building
|
||||
</Card>
|
||||
<Card title="Quickstart" icon="rocket" href="/v2/documentation/introduction/quickstart">
|
||||
<Card title="Quickstart" icon="rocket" href="/v2.6.0-alpha/documentation/introduction/quickstart">
|
||||
Get started with your first integration
|
||||
</Card>
|
||||
<Card title="Architecture" icon="sitemap" href="/v2/documentation/core-concepts/architecture">
|
||||
<Card title="Architecture" icon="sitemap" href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
See how reasoning fits into Honcho's overall architecture
|
||||
</Card>
|
||||
<Card title="Peer Representations" icon="user-magnifying-glass" href="/v2/documentation/core-concepts/representation">
|
||||
<Card title="Peer Representations" icon="user-magnifying-glass" href="/v2.6.0-alpha/documentation/core-concepts/representation">
|
||||
Learn how reasoning produces peer representations
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -10,7 +10,7 @@ When you write messages to Honcho, the reasoning models extract premises, draw c
|
|||
|
||||
## What's in a Representation?
|
||||
|
||||
A peer representation is made up of several types of artifacts that Honcho generates through [*reasoning*](/v2/documentation/core-concepts/reasoning):
|
||||
A peer representation is made up of several types of artifacts that Honcho generates through [*reasoning*](/v2.6.0-alpha/documentation/core-concepts/reasoning):
|
||||
|
||||
**Conclusions** are insights derived through formal logic. Deductive conclusions are things Honcho can be certain about based on extracted premises. Inductive conclusions identify patterns across multiple messages. Abductive conclusions infer the simplest explanations for observed behavior. For example, if a user frequently mentions work deadlines and rarely mentions hobbies, Honcho might inductively conclude they're time-constrained or career-focused.
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ These enable continuous improvement. Each new message refines conclusions, updat
|
|||
|
||||
Honcho can build different representations based on what each peer observes. This enables sophisticated multi-peer scenarios where understanding is relative to what was actually witnessed.
|
||||
|
||||
There are two observation modes controlled by [configuration](/v2/documentation/features/advanced/configuration):
|
||||
There are two observation modes controlled by [configuration](/v2.6.0-alpha/documentation/features/advanced/configuration):
|
||||
|
||||
**Honcho observing peers** (`observe_me`): When enabled (default), Honcho forms a representation of the peer based on all messages they've sent across all sessions. This is Honcho's understanding of that peer, built from everything they've said and done in your system. Set `observe_me: false` if you don't want Honcho to reason about that peer at all.
|
||||
|
||||
|
|
@ -54,13 +54,13 @@ Humans reconstruct the past from imperfect recollections, then act on those reco
|
|||
<Card title="Get an API Key" icon="key" href="https://app.honcho.dev">
|
||||
Sign up for the Honcho platform and start building
|
||||
</Card>
|
||||
<Card title="Quickstart" icon="rocket" href="/v2/documentation/introduction/quickstart">
|
||||
<Card title="Quickstart" icon="rocket" href="/v2.6.0-alpha/documentation/introduction/quickstart">
|
||||
See representations in action with a working example
|
||||
</Card>
|
||||
<Card title="Architecture" icon="sitemap" href="/v2/documentation/core-concepts/architecture">
|
||||
<Card title="Architecture" icon="sitemap" href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
Understand how representations fit into Honcho's architecture
|
||||
</Card>
|
||||
<Card title="Chat Endpoint" icon="comments" href="/v2/documentation/features/chat">
|
||||
<Card title="Chat Endpoint" icon="comments" href="/v2.6.0-alpha/documentation/features/chat">
|
||||
Learn how to query representations with natural language
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
title: "Advanced Features"
|
||||
icon: "brain"
|
||||
description: "Advanced configuration and monitoring options for Honcho"
|
||||
sidebarTitle: "Overview"
|
||||
---
|
||||
|
||||
Advanced features give you fine-grained control over Honcho's behavior and implementation.
|
||||
|
||||
## Configuration & Monitoring
|
||||
|
||||
- [Queue Status](/v2.6.0-alpha/documentation/features/advanced/queue-status) - Monitor background processing and reasoning tasks
|
||||
- [Configuration](/v2.6.0-alpha/documentation/features/advanced/toggle-reasoning) - Configure reasoning models and behavior
|
||||
- [Summarizer](/v2.6.0-alpha/documentation/features/advanced/summarizer) - Automatic session summarization
|
||||
|
||||
## Querying & Filtering
|
||||
|
||||
- [Search](/v2.6.0-alpha/documentation/features/advanced/search) - Search across peers, sessions, and messages
|
||||
- [Filters](/v2.6.0-alpha/documentation/features/advanced/using-filters) - Filter queries with advanced parameters
|
||||
- [Streaming Responses](/v2.6.0-alpha/documentation/features/advanced/streaming-response) - Stream dialectic responses in real-time
|
||||
|
|
@ -4,7 +4,7 @@ description: Learn how to check the status of Honcho's reasoning
|
|||
icon: "lines-leaning"
|
||||
---
|
||||
|
||||
Whenever messages are stored in Honcho, a background process kicks off to [reason](/v2/documentation/core-concepts/reasoning) about the conversation and generate insights.
|
||||
Whenever messages are stored in Honcho, a background process kicks off to [reason](/v2.6.0-alpha/documentation/core-concepts/reasoning) about the conversation and generate insights.
|
||||
|
||||
Reasoning is an asynchronous process and, depending on load, may not immediately
|
||||
generate insights for the latest message you've sent. To help with this, Honcho
|
||||
|
|
@ -12,13 +12,13 @@ Configuration follows a hierarchy: **message > session > workspace > global defa
|
|||
|
||||
Honcho uses a hierarchical configuration system where more specific settings override more general ones:
|
||||
|
||||
TODO: should peer be included here?
|
||||
|
||||
1. **Global Defaults**: Built-in system defaults
|
||||
2. **Workspace Configuration**: Settings that apply to all sessions in a workspace
|
||||
3. **Session Configuration**: Settings that apply to all messages in a session
|
||||
4. **Message Configuration**: Settings that apply to a specific message
|
||||
|
||||
Separately, you can configure the reasoning status of a peer. This overrides defaults and workspace configuration, but not session or message configuration.
|
||||
|
||||
<Info>
|
||||
All configuration fields are optional. If not specified, the value is inherited from the next level up in the hierarchy.
|
||||
</Info>
|
||||
|
|
@ -60,14 +60,12 @@ const session = await honcho.session("private-session", {
|
|||
|
||||
### Peer Card Configuration
|
||||
|
||||
TODO: is create a catch-all for update?
|
||||
|
||||
Controls how peer cards (containing key biographical information) are generated and used.
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `use` | `bool` | Whether to use peer cards during the reasoning process. |
|
||||
| `create` | `bool` | Whether to generate peer cards based on message content. |
|
||||
| `create` | `bool` | Whether to generate and update peer cards based on message content. |
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
|
|
@ -123,8 +121,6 @@ const session = await honcho.session("verbose-session", {
|
|||
|
||||
### Dream Configuration
|
||||
|
||||
TODO: fill out code blocks? or get rid of them? having them there for comments seems silly
|
||||
|
||||
Controls the "dreaming" process that consolidates and refines representations. Available at workspace and session levels only.
|
||||
|
||||
| Field | Type | Description |
|
||||
|
|
@ -134,11 +130,19 @@ Controls the "dreaming" process that consolidates and refines representations. A
|
|||
<CodeGroup>
|
||||
```python Python
|
||||
# Disable dreams for a workspace
|
||||
# (done via API when creating/updating workspace)
|
||||
honcho.set_config({
|
||||
"dream": {
|
||||
"enabled": False
|
||||
}
|
||||
})
|
||||
```
|
||||
```typescript TypeScript
|
||||
// Disable dreams for a workspace
|
||||
// (done via API when creating/updating workspace)
|
||||
await honcho.setConfig({
|
||||
dream: {
|
||||
enabled: false
|
||||
}
|
||||
});
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
|
@ -153,7 +157,7 @@ You may therefore disable observation of a peer by setting the `observe_me` flag
|
|||
If the peer has a session-level configuration, it will override this configuration. If the flag is not set, or is set to `true`, the peer will be observed.
|
||||
|
||||
<Info>
|
||||
For session-level observation controls and local representations (where peers build separate models of each other), see [Representation Scopes](/v2/documentation/features/advanced/representation-scopes).
|
||||
For session-level observation controls and local representations (where peers build separate models of each other), see [Representation Scopes](/v2.6.0-alpha/documentation/features/advanced/representation-scopes).
|
||||
</Info>
|
||||
|
||||
<CodeGroup>
|
||||
|
|
@ -167,14 +167,12 @@ const goals = await peer.chat("What are the user's main goals or objectives?");
|
|||
|
||||
When you call `peer.chat(query)`:
|
||||
|
||||
TODO: update with agentic approach?
|
||||
|
||||
1. Honcho searches through the peer's representation--conclusions drawn from reasoning over their messages
|
||||
1. Honcho searches through the peer's peer card and representation--conclusions drawn from reasoning over their messages
|
||||
2. Retrieves conclusions semantically relevant to your query
|
||||
3. Synthesizes them into a coherent natural language answer
|
||||
4. Returns the answer to your application
|
||||
3. Combines them with segments of source messages, if needed, to gather more context
|
||||
4. Synthesizes them into a coherent natural language response to your query
|
||||
|
||||
Honcho [reasoning](/v2/documentation/core-concepts/reasoning) runs continuously in the background, processing new messages and updating representations. The chat endpoint always has access to Honcho's latest conclusions about the peer.
|
||||
Honcho [reasoning](/v2.6.0-alpha/documentation/core-concepts/reasoning) runs continuously in the background, processing new messages and updating representations. The chat endpoint always has access to Honcho's latest conclusions about the peer.
|
||||
|
||||
## Best Practices
|
||||
|
||||
|
|
@ -182,7 +180,7 @@ Honcho [reasoning](/v2/documentation/core-concepts/reasoning) runs continuously
|
|||
Instead of "Tell me about the user", ask "What communication style does the user prefer?" You'll get more actionable answers.
|
||||
|
||||
### Let your LLM formulate queries
|
||||
The chat endpoint shines when your LLM decides what it needs to know. This creates dynamic, context-aware personalization.
|
||||
The chat endpoint shines when your LLM decides what it needs to know. This creates dynamic, context-aware personalization. An excellent way to achieve this, if building an agent, is to give access to the Honcho chat endpoint as just another tool.
|
||||
|
||||
### Use for runtime decisions
|
||||
Don't just use chat for LLM prompts - use it to drive application logic, routing, and feature flags based on user behavior.
|
||||
|
|
@ -190,4 +188,4 @@ Don't just use chat for LLM prompts - use it to drive application logic, routing
|
|||
### Combine with get_context()
|
||||
Use `get_context()` for conversation context and `peer.chat()` for specific insights. They complement each other.
|
||||
|
||||
For more ideas on using the chat endpoint, see our blog post on [flexible agent communication](https://blog.plasticlabs.ai/blog/Introducing-Honcho's-chat-API#how-it-works).
|
||||
For more ideas on using the chat endpoint, see our [guides](/v2.6.0-alpha/guides/overview).
|
||||
|
|
@ -0,0 +1,652 @@
|
|||
---
|
||||
title: 'Get Context'
|
||||
description: 'Learn how to use get_context() to retrieve and format conversation context for LLM integration'
|
||||
icon: 'messages'
|
||||
---
|
||||
|
||||
The `get_context()` method is a powerful feature that retrieves formatted conversation context from sessions, making it easy to integrate with LLMs like OpenAI, Anthropic, and others. This guide covers everything you need to know about working with session context.
|
||||
|
||||
|
||||
By default, the context includes a blend of summary and messages which covers the entire history of the session. Summaries are automatically generated at intervals and recent messages are included depending on how many tokens the context is intended to be. You can specify any token limit you want, and can disable summaries to fill that limit entirely with recent messages. To get representation data, you need to specify a target peer.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
The `get_context()` method is available on all Session objects and returns a `SessionContext` that contains the formatted conversation history.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from honcho import Honcho
|
||||
|
||||
# Initialize client and create session
|
||||
honcho = Honcho()
|
||||
session = honcho.session("conversation-1")
|
||||
|
||||
# Get basic context (not very useful before adding any messages!)
|
||||
context = session.get_context()
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Honcho } from "@honcho-ai/sdk";
|
||||
|
||||
(async () => {
|
||||
// Initialize client and create session
|
||||
const honcho = new Honcho({});
|
||||
const session = await honcho.session("conversation-1");
|
||||
|
||||
// Get basic context (not very useful before adding any messages!)
|
||||
const context = await session.getContext();
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Context Parameters
|
||||
|
||||
The `get_context()` method accepts several optional parameters to customize the retrieved context:
|
||||
|
||||
### Token Limits
|
||||
|
||||
Control the size of the context by setting a maximum token count:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Limit context to 1500 tokens
|
||||
context = session.get_context(tokens=1500)
|
||||
|
||||
# Limit context to 3000 tokens for larger conversations
|
||||
context = session.get_context(tokens=3000)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Limit context to 1500 tokens
|
||||
const context = await session.getContext({ tokens: 1500 });
|
||||
|
||||
// Limit context to 3000 tokens for larger conversations
|
||||
const context = await session.getContext({ tokens: 3000 });
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Summary Mode
|
||||
|
||||
Enable summary mode (on by default) to get a condensed version of the conversation:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Get context with summary enabled -- will contain both summary and messages
|
||||
context = session.get_context(summary=True)
|
||||
|
||||
# Combine summary=False with token limits to get more messages
|
||||
context = session.get_context(summary=False, tokens=2000)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Get context with summary enabled -- will contain both summary and messages
|
||||
const context = await session.getContext({ summary: true });
|
||||
|
||||
// Combine summary=False with token limits to get more messages
|
||||
const context = await session.getContext({
|
||||
summary: false,
|
||||
tokens: 2000
|
||||
});
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Peer Representation in Context
|
||||
|
||||
You can include a peer's [representation](/v2.6.0-alpha/documentation/core-concepts/representation) and peer card in the context by specifying `peer_target`. This is useful for providing the LLM with knowledge about a specific peer.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Get context with peer representation included
|
||||
context = session.get_context(
|
||||
tokens=2000,
|
||||
peer_target="user-123" # Include representation of user-123
|
||||
)
|
||||
|
||||
# Access the representation and peer card
|
||||
print(context.peer_representation) # String representation
|
||||
print(context.peer_card) # List of peer card items
|
||||
|
||||
# Get representation from a specific peer's perspective
|
||||
context = session.get_context(
|
||||
tokens=2000,
|
||||
peer_target="user-123",
|
||||
peer_perspective="assistant" # From assistant's viewpoint
|
||||
)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Get context with peer representation included
|
||||
const context = await session.getContext({
|
||||
tokens: 2000,
|
||||
peerTarget: "user-123" // Include representation of user-123
|
||||
});
|
||||
|
||||
// Access the representation and peer card
|
||||
console.log(context.peerRepresentation); // String representation
|
||||
console.log(context.peerCard); // Array of peer card items
|
||||
|
||||
// Get representation from a specific peer's perspective
|
||||
const perspectiveContext = await session.getContext({
|
||||
tokens: 2000,
|
||||
peerTarget: "user-123",
|
||||
peerPerspective: "assistant" // From assistant's viewpoint
|
||||
});
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Semantic Search with Last Message
|
||||
|
||||
Use `last_user_message` to fetch semantically relevant conclusions based on the most recent message (requires `peer_target`):
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
context = session.get_context(
|
||||
tokens=2000,
|
||||
peer_target="user-123",
|
||||
last_user_message="What are my coding preferences?",
|
||||
search_top_k=10, # Number of relevant observations
|
||||
search_max_distance=0.8, # Max semantic distance (0.0-1.0)
|
||||
include_most_derived=True, # Include most recent observations
|
||||
max_observations=25 # Cap total observations
|
||||
)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
const context = await session.getContext({
|
||||
tokens: 2000,
|
||||
peerTarget: "user-123",
|
||||
lastUserMessage: "What are my coding preferences?",
|
||||
representationOptions: {
|
||||
searchTopK: 10, // Number of relevant observations
|
||||
searchMaxDistance: 0.8, // Max semantic distance (0.0-1.0)
|
||||
includeMostDerived: true, // Include most recent observations
|
||||
maxObservations: 25 // Cap total observations
|
||||
}
|
||||
});
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Session-Scoped Representations
|
||||
|
||||
Use `limit_to_session` to only include observations from the current session:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Get context limited to this session's observations only
|
||||
context = session.get_context(
|
||||
tokens=2000,
|
||||
peer_target="user-123",
|
||||
limit_to_session=True # Only observations from this session
|
||||
)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Get context limited to this session's observations only
|
||||
const context = await session.getContext({
|
||||
tokens: 2000,
|
||||
peerTarget: "user-123",
|
||||
limitToSession: true // Only observations from this session
|
||||
});
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### All Parameters Reference
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `summary` | `bool` | Include summary in context (default: true) |
|
||||
| `tokens` | `int` | Maximum tokens to include |
|
||||
| `peer_target` | `str` | Peer ID to include representation for |
|
||||
| `peer_perspective` | `str` | Peer ID for perspective (requires peer_target) |
|
||||
| `last_user_message` | `str` | Message for semantic search (requires peer_target) |
|
||||
| `limit_to_session` | `bool` | Limit to session observations only |
|
||||
| `search_top_k` | `int` | Semantic search results to include (1-100) |
|
||||
| `search_max_distance` | `float` | Max semantic distance (0.0-1.0) |
|
||||
| `include_most_derived` | `bool` | Include most recently derived observations |
|
||||
| `max_observations` | `int` | Maximum observations to include (1-100) |
|
||||
|
||||
## Converting to LLM Formats
|
||||
|
||||
The `SessionContext` object provides methods to convert the context into formats compatible with popular LLM APIs. When converting to OpenAI format, you must specify the assistant peer to format the context in such a way that the LLM can understand it.
|
||||
|
||||
### OpenAI Format
|
||||
|
||||
Convert context to OpenAI's chat completion format:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Create peers
|
||||
alice = honcho.peer("alice")
|
||||
assistant = honcho.peer("assistant")
|
||||
|
||||
# Add some conversation
|
||||
session.add_messages([
|
||||
alice.message("What's the weather like today?"),
|
||||
assistant.message("It's sunny and 75°F outside!")
|
||||
])
|
||||
|
||||
# Get context and convert to OpenAI format
|
||||
context = session.get_context()
|
||||
openai_messages = context.to_openai(assistant=assistant)
|
||||
|
||||
# The messages are now ready for OpenAI API
|
||||
print(openai_messages)
|
||||
# [
|
||||
# {"role": "user", "content": "What's the weather like today?"},
|
||||
# {"role": "assistant", "content": "It's sunny and 75°F outside!"}
|
||||
# ]
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Create peers
|
||||
const alice = await honcho.peer("alice");
|
||||
const assistant = await honcho.peer("assistant");
|
||||
|
||||
// Add some conversation
|
||||
await session.addMessages([
|
||||
alice.message("What's the weather like today?"),
|
||||
assistant.message("It's sunny and 75°F outside!")
|
||||
]);
|
||||
|
||||
// Get context and convert to OpenAI format
|
||||
const context = await session.getContext();
|
||||
const openaiMessages = context.toOpenAI(assistant);
|
||||
|
||||
// The messages are now ready for OpenAI API
|
||||
console.log(openaiMessages);
|
||||
// [
|
||||
// {"role": "user", "content": "What's the weather like today?"},
|
||||
// {"role": "assistant", "content": "It's sunny and 75°F outside!"}
|
||||
// ]
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Anthropic Format
|
||||
|
||||
Convert context to Anthropic's Claude format:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Get context and convert to Anthropic format
|
||||
context = session.get_context()
|
||||
anthropic_messages = context.to_anthropic(assistant=assistant)
|
||||
|
||||
# Ready for Anthropic API
|
||||
print(anthropic_messages)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Get context and convert to Anthropic format
|
||||
const context = await session.getContext();
|
||||
const anthropicMessages = context.toAnthropic(assistant);
|
||||
|
||||
// Ready for Anthropic API
|
||||
console.log(anthropicMessages);
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Complete LLM Integration Examples
|
||||
|
||||
### Using with OpenAI
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import openai
|
||||
from honcho import Honcho
|
||||
|
||||
# Initialize clients
|
||||
honcho = Honcho()
|
||||
openai_client = openai.OpenAI()
|
||||
|
||||
# Set up conversation
|
||||
session = honcho.session("support-chat")
|
||||
user = honcho.peer("user-123")
|
||||
assistant = honcho.peer("support-bot")
|
||||
|
||||
# Add conversation history
|
||||
session.add_messages([
|
||||
user.message("I'm having trouble with my account login"),
|
||||
assistant.message("I can help you with that. What error message are you seeing?"),
|
||||
user.message("It says 'Invalid credentials' but I'm sure my password is correct")
|
||||
])
|
||||
|
||||
# Get context for LLM
|
||||
messages = session.get_context(tokens=2000).to_openai(assistant=assistant)
|
||||
|
||||
# Add new user message and get AI response
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": "Can you reset my password?"
|
||||
})
|
||||
|
||||
response = openai_client.chat.completions.create(
|
||||
model="gpt-4",
|
||||
messages=messages
|
||||
)
|
||||
|
||||
# Add AI response back to session
|
||||
session.add_messages([
|
||||
user.message("Can you reset my password?"),
|
||||
assistant.message(response.choices[0].message.content)
|
||||
])
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import OpenAI from 'openai';
|
||||
import { Honcho } from "@honcho-ai/sdk";
|
||||
|
||||
(async () => {
|
||||
// Initialize clients
|
||||
const honcho = new Honcho({});
|
||||
const openai = new OpenAI();
|
||||
|
||||
// Set up conversation
|
||||
const session = await honcho.session("support-chat");
|
||||
const user = await honcho.peer("user-123");
|
||||
const assistant = await honcho.peer("support-bot");
|
||||
|
||||
// Add conversation history
|
||||
await session.addMessages([
|
||||
user.message("I'm having trouble with my account login"),
|
||||
assistant.message("I can help you with that. What error message are you seeing?"),
|
||||
user.message("It says 'Invalid credentials' but I'm sure my password is correct")
|
||||
]);
|
||||
|
||||
// Get context for LLM
|
||||
const messages = await session.getContext({ tokens: 2000 }).toOpenAI(assistant);
|
||||
|
||||
// Add new user message and get AI response
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4",
|
||||
messages: [
|
||||
...messages,
|
||||
{ role: "user", content: "Can you reset my password?" }
|
||||
]
|
||||
});
|
||||
|
||||
// Add AI response back to session
|
||||
await session.addMessages([
|
||||
user.message("Can you reset my password?"),
|
||||
assistant.message(response.choices[0].message.content)
|
||||
]);
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Multi-Turn Conversation Loop
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
def chat_loop():
|
||||
"""Example of a continuous chat loop using get_context()"""
|
||||
|
||||
session = honcho.session("chat-session")
|
||||
user = honcho.peer("user")
|
||||
assistant = honcho.peer("ai-assistant")
|
||||
|
||||
while True:
|
||||
# Get user input
|
||||
user_input = input("You: ")
|
||||
if user_input.lower() in ['quit', 'exit']:
|
||||
break
|
||||
|
||||
# Add user message to session
|
||||
session.add_messages([user.message(user_input)])
|
||||
|
||||
# Get conversation context
|
||||
context = session.get_context(tokens=2000)
|
||||
messages = context.to_openai(assistant=assistant)
|
||||
|
||||
# Get AI response
|
||||
response = openai_client.chat.completions.create(
|
||||
model="gpt-4",
|
||||
messages=messages
|
||||
)
|
||||
|
||||
ai_response = response.choices[0].message.content
|
||||
print(f"Assistant: {ai_response}")
|
||||
|
||||
# Add AI response to session
|
||||
session.add_messages([assistant.message(ai_response)])
|
||||
|
||||
# Start the chat loop
|
||||
chat_loop()
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
async function chatLoop() {
|
||||
const session = await honcho.session("chat-session");
|
||||
const user = await honcho.peer("user");
|
||||
const assistant = await honcho.peer("ai-assistant");
|
||||
|
||||
// This would be replaced with actual user input handling in a real app
|
||||
const userInputs = [
|
||||
"Hello, how are you?",
|
||||
"What's the weather like?",
|
||||
"Tell me a joke"
|
||||
];
|
||||
|
||||
for (const userInput of userInputs) {
|
||||
console.log(`You: ${userInput}`);
|
||||
|
||||
// Add user message to session
|
||||
await session.addMessages([user.message(userInput)]);
|
||||
|
||||
// Get conversation context
|
||||
const context = await session.getContext({ tokens: 2000 });
|
||||
const messages = context.toOpenAI(assistant);
|
||||
|
||||
// Get AI response
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4",
|
||||
messages: messages
|
||||
});
|
||||
|
||||
const aiResponse = response.choices[0].message.content;
|
||||
console.log(`Assistant: ${aiResponse}`);
|
||||
|
||||
// Add AI response to session
|
||||
await session.addMessages([assistant.message(aiResponse)]);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the chat loop
|
||||
await chatLoop();
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Advanced Context Usage
|
||||
|
||||
### Context with Summaries for Long Conversations
|
||||
|
||||
For very long conversations, use summaries to maintain context while controlling token usage:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# For long conversations, use summary mode
|
||||
long_session = honcho.session("long-conversation")
|
||||
|
||||
# Get summarized context to fit within token limits
|
||||
context = long_session.get_context(summary=True, tokens=1500)
|
||||
messages = context.to_openai(assistant=assistant)
|
||||
|
||||
# This will include a summary of older messages and recent full messages
|
||||
print(f"Context contains {len(messages)} formatted messages")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// For long conversations, use summary mode
|
||||
const longSession = await honcho.session("long-conversation");
|
||||
|
||||
// Get summarized context to fit within token limits
|
||||
const context = await longSession.getContext({
|
||||
summary: true,
|
||||
tokens: 1500
|
||||
});
|
||||
const messages = context.toOpenAI(assistant);
|
||||
|
||||
// This will include a summary of older messages and recent full messages
|
||||
console.log(`Context contains ${messages.length} formatted messages`);
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Context for Different Assistant Types
|
||||
|
||||
You can get context formatted for different types of assistants in the same session:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Create different assistant peers
|
||||
chatbot = honcho.peer("chatbot")
|
||||
analyzer = honcho.peer("data-analyzer")
|
||||
moderator = honcho.peer("moderator")
|
||||
|
||||
# Get context formatted for each assistant type
|
||||
chatbot_context = session.get_context().to_openai(assistant=chatbot)
|
||||
analyzer_context = session.get_context().to_openai(assistant=analyzer)
|
||||
moderator_context = session.get_context().to_openai(assistant=moderator)
|
||||
|
||||
# Each context will format the conversation from that assistant's perspective
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Create different assistant peers
|
||||
const chatbot = await honcho.peer("chatbot");
|
||||
const analyzer = await honcho.peer("data-analyzer");
|
||||
const moderator = await honcho.peer("moderator");
|
||||
|
||||
// Get context formatted for each assistant type
|
||||
const context = await session.getContext();
|
||||
const chatbotContext = context.toOpenAI(chatbot);
|
||||
const analyzerContext = context.toOpenAI(analyzer);
|
||||
const moderatorContext = context.toOpenAI(moderator);
|
||||
|
||||
// Each context will format the conversation from that assistant's perspective
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Token Management
|
||||
|
||||
Always set appropriate token limits to control costs and ensure context fits within LLM limits:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Good: Set reasonable token limits based on your model
|
||||
context = session.get_context(tokens=3000) # For GPT-4
|
||||
context = session.get_context(tokens=1500) # For smaller models
|
||||
|
||||
# Good: Use summaries for very long conversations
|
||||
context = session.get_context(summary=True, tokens=2000)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Good: Set reasonable token limits based on your model
|
||||
const context = await session.getContext({ tokens: 3000 }); // For GPT-4
|
||||
const context = await session.getContext({ tokens: 1500 }); // For smaller models
|
||||
|
||||
// Good: Use summaries for very long conversations
|
||||
const context = await session.getContext({ summary: true, tokens: 2000 });
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### 2. Context Caching
|
||||
|
||||
For applications with frequent context retrieval, consider caching context when appropriate:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Cache context for multiple LLM calls within the same request
|
||||
context = session.get_context(tokens=2000)
|
||||
openai_messages = context.to_openai(assistant=assistant)
|
||||
anthropic_messages = context.to_anthropic(assistant=assistant)
|
||||
|
||||
# Use the same context object for multiple format conversions
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
// Cache context for multiple LLM calls within the same request
|
||||
const context = await session.getContext({ tokens: 2000 });
|
||||
const openaiMessages = context.toOpenAI(assistant);
|
||||
const anthropicMessages = context.toAnthropic(assistant);
|
||||
|
||||
// Use the same context object for multiple format conversions
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### 3. Error Handling
|
||||
|
||||
Always handle potential errors when working with context:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
try:
|
||||
context = session.get_context(tokens=2000)
|
||||
messages = context.to_openai(assistant=assistant)
|
||||
|
||||
# Use messages with LLM API
|
||||
response = openai_client.chat.completions.create(
|
||||
model="gpt-4",
|
||||
messages=messages
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error getting context: {e}")
|
||||
# Handle error appropriately
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
(async () => {
|
||||
try {
|
||||
const context = await session.getContext({ tokens: 2000 });
|
||||
const messages = context.toOpenAI(assistant);
|
||||
|
||||
// Use messages with LLM API
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4",
|
||||
messages: messages
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error getting context: ${error}`);
|
||||
// Handle error appropriately
|
||||
}
|
||||
})();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Conclusion
|
||||
|
||||
The `get_context()` method is essential for integrating Honcho sessions with LLMs. By understanding how to:
|
||||
|
||||
- Retrieve context with appropriate parameters
|
||||
- Convert context to LLM-specific formats
|
||||
- Manage token limits and summaries
|
||||
- Handle multi-turn conversations
|
||||
|
||||
You can build sophisticated AI applications that maintain conversation history and context across interactions while integrating seamlessly with popular LLM providers.
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
---
|
||||
title: "Honcho Overview"
|
||||
icon: "brain"
|
||||
sidebarTitle: "Overview"
|
||||
---
|
||||
|
||||
Honcho is an open source memory library with a managed service for building stateful agents. Use it with any model, framework, or architecture. It enables agents to build and maintain state about any entity--users, agents, groups, ideas, and more. And because it's a continual learning system, it understands entities that change over time. Using Honcho as your memory system will earn your agents higher retention, more trust, and help you build data moats to out-compete incumbents.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Get an API Key" icon="key" href="https://app.honcho.dev">
|
||||
Sign up and start building with Honcho
|
||||
</Card>
|
||||
<Card title="Quickstart" icon="rocket" href="/v2.6.0-alpha/documentation/introduction/quickstart">
|
||||
Build your first stateful agent in minutes
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Note>
|
||||
Honcho is a memory system that reasons. Read more on the approach [here](https://blog.plasticlabs.ai/blog/Memory-as-Reasoning).
|
||||
</Note>
|
||||
|
||||
## Why Use Honcho?
|
||||
|
||||
Honcho streamlines the agent building process by offering elegant, flexible primitives for managing context. It also reasons over that context to give developers access to far richer insights only accessible through reasoning.
|
||||
|
||||
Take the following scenario:
|
||||
|
||||
- You find a use case for LLMs and build an agent around it
|
||||
- It works well initially but can't maintain context across sessions
|
||||
- You spend weeks engineering a RAG solution that seems to help
|
||||
- Then the cycle begins...
|
||||
- Users report the agent forgetting things, contradicting itself, or losing context mid-session
|
||||
- You build evals to quantify the problem
|
||||
- You re-engineer your entire RAG pipeline with better chunking, embeddings, retrieval strategies
|
||||
- The problems shift but don't disappear
|
||||
- Repeat
|
||||
|
||||
Eventually you realize the issue isn't engineering—-it's that you're not extracting all the latent information from your data. You need to reason exhaustively, handle contradictions, track patterns over time, and maintain coherent state. In other words, you'd need to build Honcho.
|
||||
|
||||
Break free from this cycle. Honcho is a general solution to context engineering, memory, and statefulness.
|
||||
|
||||
## How Honcho Works
|
||||
|
||||
Honcho has four storage primitives that work together:
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
W[Workspaces] -->|have| P[Peers]
|
||||
W -->|have| S[Sessions]
|
||||
|
||||
S -->|have| SM[Messages]
|
||||
|
||||
P <-.->|many-to-many| S
|
||||
|
||||
style W fill:#B6DBFF,stroke:#333,color:#000
|
||||
style P fill:#B6DBFF,stroke:#333,color:#000
|
||||
style S fill:#B6DBFF,stroke:#333,color:#000
|
||||
style SM fill:#B6DBFF,stroke:#333,color:#000
|
||||
```
|
||||
|
||||
- **Workspaces** - Top-level containers that isolate different applications or environments
|
||||
- **Peers** - Any entity that persists but changes over time (users, agents, objects, and more)
|
||||
- **Sessions** - Interaction threads between peers with temporal boundaries
|
||||
- **Messages** - Units of data that trigger reasoning (conversations, events, activity, documents, and more)
|
||||
|
||||
When you write messages to Honcho, they're stored and processed in the background. Custom reasoning models perform formal logical [*reasoning*](/v2.6.0-alpha/documentation/core-concepts/reasoning) to generate conclusions about each peer. These conclusions are stored as [*representations*](/v2.6.0-alpha/documentation/core-concepts/representation) that you can query to provide rich context for your agents.
|
||||
|
||||

|
||||
|
||||
The diagram above shows the flow: agents write messages to Honcho, which triggers reasoning that updates what's stored in representations. Developers (or agents) can then query to get additional context for their next response.
|
||||
|
||||
## Why Reasoning?
|
||||
|
||||
Traditional RAG systems retrieve what was explicitly said, but they miss what matters most—the insights only accessible by *rigorously thinking* about your data. Without reasoning, you're leaving latent information on the table. Static retrieval can't surface implicit connections, struggles when new information contradicts old data, and fails when you need to make predictions under uncertainty.
|
||||
|
||||
Honcho uses formal logic to extract all that latent information. This reasoning is AI-native—it performs the rigorous, compute-intensive thinking that humans struggle with, instantly and consistently. The result is memory that goes beyond simple RAG recall to provide exhaustive context for statefulness.
|
||||
|
||||
## Get Started
|
||||
|
||||
Honcho gives you maximum control over your agent's context and memory. The data model is flexible and composable, the reasoning backend is powerful yet cost-effective, and everything is built to give developers levers to manage token usage, latency, and reasoning depth.
|
||||
|
||||
We're just scratching the surface. Dive into the quickstart to see Honcho in action, explore the architecture to understand how it all fits together, or jump straight to building.
|
||||
|
||||
Welcome to Honcho. We're excited to have you at the frontier of AI with us 🫡.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Get an API Key" icon="key" href="https://app.honcho.dev">
|
||||
Sign up for the Honcho platform and get your API key
|
||||
</Card>
|
||||
<Card title="Quickstart" icon="rocket" href="/v2.6.0-alpha/documentation/introduction/quickstart">
|
||||
Build your first stateful agent in minutes
|
||||
</Card>
|
||||
<Card title="Architecture" icon="sitemap" href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
Deep dive into how Honcho's primitives fit together
|
||||
</Card>
|
||||
<Card title="Reasoning" icon="gears" href="/v2.6.0-alpha/documentation/core-concepts/reasoning">
|
||||
Learn how Honcho reasons about data to build memory
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,404 @@
|
|||
---
|
||||
title: "Quickstart"
|
||||
icon: "bolt"
|
||||
sidebarTitle: "Quickstart"
|
||||
---
|
||||
|
||||
Let's get started with Honcho. In this quickstart, you will:
|
||||
|
||||
- Set up a workspace with peers (user and assistant)
|
||||
- Ingest messages from across multiple sessions
|
||||
- Query the reasoning Honcho produces to get synthesized insights about the user
|
||||
|
||||
<Note>
|
||||
Running the code below requires an API key. Create and account and get your API key at [app.honcho.dev](https://app.honcho.dev) under "API KEYS".
|
||||
|
||||
Every new tenant gets \$100.00 in free credits on sign up. The code below costs ~\$0.04 to run, so don't worry--still plenty of free credits for iterating.
|
||||
</Note>
|
||||
|
||||
#### 1. Install the SDK
|
||||
|
||||
<CodeGroup>
|
||||
```bash Python (uv)
|
||||
uv add honcho-ai
|
||||
```
|
||||
|
||||
```bash Python (pip)
|
||||
pip install honcho-ai
|
||||
```
|
||||
|
||||
```bash TypeScript (npm)
|
||||
npm install @honcho-ai/sdk
|
||||
```
|
||||
|
||||
```bash TypeScript (yarn)
|
||||
yarn add @honcho-ai/sdk
|
||||
```
|
||||
|
||||
```bash TypeScript (pnpm)
|
||||
pnpm add @honcho-ai/sdk
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
#### 2. Initialize the Client
|
||||
|
||||
The Honcho client is the main entry point for interacting with Honcho's API. It uses a workspace called `default` unless specified, so let's create a `first-honcho-test` workspace for this quickstart.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from honcho import Honcho
|
||||
|
||||
# Initialize client
|
||||
honcho = Honcho(workspace="first-honcho-test", api_key=HONCHO_API_KEY)
|
||||
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
// Initialize client
|
||||
const honcho = new Honcho({ workspace = "first-honcho-test", apiKey = HONCHO_API_KEY });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
|
||||
#### 3. Create Peers
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
user = honcho.peer("user")
|
||||
assistant = honcho.peer("assistant")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
const user = await honcho.peer("user")
|
||||
const assistant = await honcho.peer("assistant")
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
#### 4. Add Messages to Sessions
|
||||
|
||||
We've generated an example conversation dataset with 14 messages across 4 sessions. At a high level, the conversation contains a user chatting with an assistant to get help debugging software infrastructure problems for work *and* jam strategy on a side project they're working on. Spoiler alert--the user is way more interested in their side project.
|
||||
|
||||
Create a file called `conversation.json` and add the content in the accordion below. Then we'll loop through the sessions and messages in that file and write them to Honcho.
|
||||
|
||||
|
||||
<Accordion title="Example conversation.json">
|
||||
|
||||
```json Example Conversation
|
||||
{
|
||||
"sessions": [
|
||||
{
|
||||
"id": "session_1",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "containers getting OOM killed in CI after someone on my team updated the base image. quick fix?"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "OOM kills after a base image update usually means the new image has higher memory requirements. Quick fix: bump the memory limit in your CI config. If you need to unblock fast, you could also pin back to the previous base image version temporarily."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "session_2",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "hey, been playing with honcho for a side project. do you know if there's a limit on how many users i can have?"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Honcho's free tier is based on context ingested, not number of users - so you can have as many users as you want, you're just limited by how much content you're processing. What are you building?"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "ok so basically it's a personal finance assistant that actually remembers your situation - like it knows you're saving for a house, that you hate subscriptions, that you always regret impulse buys over $50. i've been thinking a lot about the UX, like when should it proactively bring up past context vs wait for you to ask? and how do you balance feeling \"known\" vs feeling surveilled? i have a whole notion doc on this lol"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "That's a really thoughtful approach to the personalization problem! The \"known vs surveilled\" tension is exactly right - the best experiences feel like talking to a friend who remembers, not a system that tracks. Proactive context works best when it's in service of the user's stated goals."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "session_3",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "do i need to update docker-compose too or just the CI yaml for that memory thing"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Just the CI yaml for the memory limit - docker-compose is separate and only matters if you're hitting the same OOM issue locally."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "k. oh btw 3 friends are using the finance app now, they keep asking when they can pay me lol. one of them said it's the first budgeting thing that \"gets\" her"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "That's awesome - \"when can I pay you\" is the best kind of validation. And that quote about it being the first thing that \"gets\" her is exactly the value prop of personalized memory. Sounds like you're onto something real."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "session_4",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "if i wanted to charge like $5/mo for the finance app, would honcho's pricing still make sense at that price point? trying to figure out unit economics early"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "You should be fine at that price point. Unlike other memory frameworks that charge you to access your own data, Honcho only charges for the reasoning layer - ingestion and inference. Storage and retrieval are free. So your unit economics are mostly about how often you're synthesizing insights, not how much history you're keeping."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "ok interesting. wish i had more time to work on this"
|
||||
},
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "Yeah, sounds like you've got something worth making time for. The early traction is real."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import json
|
||||
|
||||
# Load conversation data
|
||||
with open("conversation.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
# Process each session
|
||||
for session_data in data["sessions"]:
|
||||
session = honcho.session(session_data["id"])
|
||||
session.add_peers([user, assistant])
|
||||
|
||||
# Add messages with correct roles
|
||||
messages = []
|
||||
for msg in session_data["messages"]:
|
||||
if msg["role"] == "user":
|
||||
messages.append(user.message(msg["content"]))
|
||||
elif msg["role"] == "assistant":
|
||||
messages.append(assistant.message(msg["content"]))
|
||||
|
||||
session.add_messages(messages)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import * as fs from 'fs';
|
||||
|
||||
const data = JSON.parse(fs.readFileSync("conversation.json", "utf-8"));
|
||||
|
||||
for (const sessionData of data.sessions) {
|
||||
const session = honcho.session(sessionData.id);
|
||||
session.addPeers([user, assistant]);
|
||||
|
||||
const messages = sessionData.messages.map((msg: any) =>
|
||||
msg.role === "user" ? user.message(msg.content) : assistant.message(msg.content)
|
||||
);
|
||||
|
||||
session.addMessages(messages);
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
#### 5. Query for Insights
|
||||
|
||||
Now ask Honcho what it's learned--this is where the magic happens:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
response = user.chat("What should I know about this user? 3 sentences max")
|
||||
print(response)
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
user.chat("What should I know about this user? 3 sentences max").then((response) => {
|
||||
console.log(response);
|
||||
})
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
<Tip>
|
||||
Honcho needs a short amount of time to process messages you write to it. There are several utilities to [check the status](/v2.6.0-alpha/documentation/features/advanced/queue-status) of the queue. Honcho also offers numerous ways to query reasoning to fit latency needs: see the [Get Context](/v2.6.0-alpha/documentation/features/get-context) page.
|
||||
</Tip>
|
||||
|
||||
The response will look something like this:
|
||||
|
||||
> User is a personal finance app developer building a personalized finance assistant that's generating real demand (friends are already asking when they can pay). They're notably thoughtful about product design, carefully considering the UX balance between making users feel "known" versus "surveilled" when their app proactively surfaces remembered context like savings goals and spending regrets. They're business-minded and working through unit economics early, exploring a $5/month subscription model with usage-based cost structure focused on insight generation frequency rather than data storage—though they wish they had more time to dedicate to the project.
|
||||
|
||||
Honcho synthesizes signal by reasoning about the user to draw conclusions beyond what was explicitly stated. It identifies the user as "notably thoughtful about product design", "business-minded" from the discussion of unit economics, and surfaces the signal that they desire to work on the project more.
|
||||
|
||||
This is rich personal context for domain-specific agents to do what they want with.
|
||||
- A life coach agent might see "they wish they had more time to dedicate to the project" and "friends are already asking when they can pay" and ask "have you thought about what it would take to go full-time?"
|
||||
- A productivity agent might see the same pattern and say "let's protect your weekend time for the finance app."
|
||||
- A financial advisor agent might see it and ask "what runway would you need to make the leap?"
|
||||
|
||||
Honcho acts almost like a detective--it reasons about new and existing evidence in order to form conclusions that can be used to make a *case*. These conclusions wait to be composed dynamically based on how you, the ~~judge~~ developer, query it. This approach is what drives our [pareto-frontier](TODO: link to evals page here) performance on memory benchmarks, and our custom models allow us to optimize speed and cost.
|
||||
|
||||
|
||||
## Next Steps
|
||||
|
||||
You just saw how Honcho reasons about data to build rich peer representations. In this quickstart, you:
|
||||
|
||||
- Set up a workspace with peers (user and assistant)
|
||||
- Ingested messages across multiple sessions
|
||||
- Queried the reasoning to get synthesized insights about the user
|
||||
|
||||
Here's the full working code if you want to run it yourself:
|
||||
|
||||
<Accordion title="Full Scripts">
|
||||
|
||||
<CodeGroup>
|
||||
|
||||
```python Python
|
||||
# uv sync
|
||||
# uv run python test.py
|
||||
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from honcho import Honcho
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Initialize Honcho client with a unique workspace
|
||||
workspace_id = f"docs-example-{uuid.uuid4().hex[:8]}"
|
||||
honcho = Honcho(environment="production", workspace_id=workspace_id)
|
||||
|
||||
# Create peers to represent the user and assistant
|
||||
user = honcho.peer("user")
|
||||
assistant = honcho.peer("assistant")
|
||||
|
||||
# Load conversation data from JSON file
|
||||
with open("conversation.json", "r") as f:
|
||||
conversation_data = json.load(f)
|
||||
|
||||
# Import historical conversation sessions
|
||||
for session_data in conversation_data["sessions"]:
|
||||
session = honcho.session(session_data["id"])
|
||||
session.add_peers([user, assistant])
|
||||
|
||||
# Convert messages to peer messages with correct attribution
|
||||
messages = []
|
||||
for msg in session_data["messages"]:
|
||||
if msg["role"] == "user":
|
||||
messages.append(user.message(msg["content"]))
|
||||
elif msg["role"] == "assistant":
|
||||
messages.append(assistant.message(msg["content"]))
|
||||
|
||||
session.add_messages(messages)
|
||||
|
||||
# Wait for Honcho to process the conversation history
|
||||
def wait_for_processing():
|
||||
status = honcho.get_deriver_status()
|
||||
while status.pending_work_units > 0 or status.in_progress_work_units > 0:
|
||||
time.sleep(1)
|
||||
status = honcho.poll_deriver_status()
|
||||
|
||||
print("Processing conversation history...")
|
||||
start_time = time.time()
|
||||
wait_for_processing()
|
||||
elapsed = int(time.time() - start_time)
|
||||
print(f"Done in {elapsed}s! Querying user insights...\n")
|
||||
|
||||
# Query insights about the user based on conversation history
|
||||
response = user.chat("What should I know about this user? 3 sentences max")
|
||||
print(response)
|
||||
```
|
||||
|
||||
```typescript Typescript
|
||||
// npm install
|
||||
// npx ts-node test.ts
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { randomUUID } from 'crypto';
|
||||
import * as dotenv from 'dotenv';
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
// Initialize Honcho client with a unique workspace
|
||||
const workspaceId = `docs-example-${randomUUID().slice(0, 8)}`;
|
||||
const honcho = new Honcho({
|
||||
environment: "production",
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
// Create peers to represent the user and assistant
|
||||
const user = await honcho.peer("user");
|
||||
const assistant = await honcho.peer("assistant");
|
||||
|
||||
// Load conversation data from JSON file
|
||||
const conversationData = JSON.parse(fs.readFileSync("conversation.json", "utf-8"));
|
||||
|
||||
// Import historical conversation sessions
|
||||
for (const sessionData of conversationData.sessions) {
|
||||
const session = await honcho.session(sessionData.id);
|
||||
await session.addPeers([user, assistant]);
|
||||
|
||||
// Convert messages to peer messages with correct attribution
|
||||
const messages = [];
|
||||
for (const msg of sessionData.messages) {
|
||||
if (msg.role === "user") {
|
||||
messages.push(user.message(msg.content));
|
||||
} else if (msg.role === "assistant") {
|
||||
messages.push(assistant.message(msg.content));
|
||||
}
|
||||
}
|
||||
|
||||
await session.addMessages(messages);
|
||||
}
|
||||
|
||||
// Wait for Honcho to process the conversation history
|
||||
async function waitForProcessing() {
|
||||
let status = await honcho.getDeriverStatus();
|
||||
while (status.pendingWorkUnits > 0 || status.inProgressWorkUnits > 0) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
status = await honcho.pollDeriverStatus();
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Processing conversation history...");
|
||||
const startTime = Date.now();
|
||||
await waitForProcessing();
|
||||
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
||||
console.log(`Done in ${elapsed}s! Querying user insights...\n`);
|
||||
|
||||
// Query insights about the user based on conversation history
|
||||
const response = await user.chat("What should I know about this user? 3 sentences max");
|
||||
console.log(response);
|
||||
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
</Accordion>
|
||||
|
||||
From here, you can explore how to use Honcho's features in your own applications:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Get Context" icon="messages" href="/v2.6.0-alpha/documentation/features/get-context">
|
||||
Learn how to fetch the right context for your agent's next response
|
||||
</Card>
|
||||
<Card title="Architecture" icon="sitemap" href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
Deep dive into how Honcho's primitives fit together
|
||||
</Card>
|
||||
<Card title="Chat Endpoint" icon="comments" href="/v2.6.0-alpha/documentation/features/chat">
|
||||
Query representations with natural language
|
||||
</Card>
|
||||
<Card title="Guides" icon="book" href="/v2.6.0-alpha/guides/overview">
|
||||
Integration patterns and advanced use cases
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
title: "AI-Powered Honcho Setup"
|
||||
icon: "wand-magic-sparkles"
|
||||
description: "Universal starter prompt for building with Honcho"
|
||||
sidebarTitle: 'Vibecoding Setup'
|
||||
---
|
||||
|
||||
These docs are designed to be easily consumable by LLMs. Each page has a button that lets you copy the page as Markdown or paste directly into ChatGPT or Claude.
|
||||
|
||||
We follow the llms.txt standard. There are both an llms.txt and llms-full.txt available:
|
||||
|
||||
- [llms.txt](/llms.txt)
|
||||
- [llms-full.txt](/llms-full.txt)
|
||||
|
||||
We also provide a starter prompt to paste into a coding assistant to quickly get started building with Honcho.
|
||||
|
||||
## Universal Starter Prompt
|
||||
|
||||
```
|
||||
I want to start building with Honcho - an open source memory library for building stateful agents.
|
||||
|
||||
## Honcho Resources
|
||||
|
||||
**Documentation:**
|
||||
- Main docs: https://docs.honcho.dev
|
||||
- API Reference: https://docs.honcho.dev/v2.6.0-alpha/api-reference/introduction
|
||||
- Quickstart: https://docs.honcho.dev/v2.6.0-alpha/documentation/introduction/quickstart
|
||||
- Architecture: https://docs.honcho.dev/v2.6.0-alpha/documentation/core-concepts/architecture
|
||||
|
||||
**Code & Examples:**
|
||||
- Core repo: https://github.com/plastic-labs/honcho
|
||||
- Python SDK: https://github.com/plastic-labs/honcho-python
|
||||
- TypeScript SDK: https://github.com/plastic-labs/honcho-node
|
||||
- Discord bot starter: https://github.com/plastic-labs/discord-python-starter
|
||||
- Telegram bot example: https://github.com/plastic-labs/telegram-python-starter
|
||||
|
||||
**What Honcho Does:**
|
||||
Honcho is an open source memory library with a managed service for building stateful agents. It enables agents to build and maintain state about any entity--users, agents, groups, ideas, and more. Because it's a continual learning system, it understands entities that change over time.
|
||||
|
||||
When you write messages to Honcho, they're stored and processed in the background. Custom reasoning models perform formal logical reasoning to generate conclusions about each peer. These conclusions are stored as representations that you can query to provide rich context for your agents.
|
||||
|
||||
**Architecture Overview:**
|
||||
- Core primitives: Workspaces contain Peers (any entity that persists but changes) and Sessions (interaction threads between peers)
|
||||
- Peers can observe other peers in sessions (configurable with observe_me and observe_others)
|
||||
- Background reasoning processes messages to extract premises, draw conclusions, and build representations
|
||||
- Representations enable continuous improvement as new messages refine existing conclusions and scaffold new ones over time
|
||||
- Chat endpoint provides personalized responses based on learned context
|
||||
- Supports any LLM (OpenAI, Anthropic, open source)
|
||||
- Can use managed service or self-host
|
||||
|
||||
Please assess the resources above and ask me relevant questions to help build a well-structured application using Honcho. Consider asking about:
|
||||
- What I'm trying to build
|
||||
- My technical preferences and stack
|
||||
- Whether I want to use the managed service or self-host
|
||||
- My experience level with the technologies involved
|
||||
- Specific features I need (multi-peer sessions, perspective-taking, streaming, etc.)
|
||||
|
||||
Once you understand my needs, help me create a working implementation with proper memory and statefulness.
|
||||
```
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
---
|
||||
title: "The Honcho Dashboard"
|
||||
icon: "rocket"
|
||||
description: "Build socially intelligent agents without worrying about infrastructure"
|
||||
sidebarTitle: "Dashboard Overview"
|
||||
---
|
||||
|
||||
<Card title="Sign up to start using Honcho!" icon="rocket" href="https://app.honcho.dev">
|
||||
Start using the platform to manage Honcho instances for your workspace or app.
|
||||
</Card>
|
||||
|
||||
The quickest way to begin using Honcho in production is with the
|
||||
[Honcho Cloud Platform](https://app.honcho.dev). Sign up, generate an API key,
|
||||
and start building with Honcho.
|
||||
|
||||
## 1. Go to [app.honcho.dev](https://app.honcho.dev)
|
||||
|
||||
Create an account to start using Honcho. If a teammate already uses Honcho, ask
|
||||
them to invite you to their organization. Otherwise, you'll see a banner
|
||||
prompting you to create a new one.
|
||||
|
||||
<div style={{ maxWidth: "400px", margin: "0 auto" }}>
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/welcome-to-honcho.png" alt="Honcho Platform Dashboard" loading="lazy" decoding="async" fetchpriority="low" style={{ width: "100%", height: "auto" }} />
|
||||
</Frame>
|
||||
</div>
|
||||
|
||||
|
||||
Once you've created an organization, you'll be taken to the dashboard and see
|
||||
the Welcome page with integration guidance and links to documentation.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/get-started-copy.png" alt="Honcho Dashboard Getting Started" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Each organization has dedicated infrastructure running to isolate your
|
||||
workloads. Once you add a valid payment method under the
|
||||
[Billing](https://app.honcho.dev/billing) page, your instance will turn on.
|
||||
|
||||
## 2. Activate your Honcho instance
|
||||
|
||||
Navigate to the [Billing](https://app.honcho.dev/billing) page to add a payment method. Your Honcho instance provisions automatically, and you can monitor the deployment on the [Instance Status](https://app.honcho.dev/status) page until all systems show a green check mark.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/status-page.png" alt="Instance Status Page" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
You can also upgrade Honcho when new versions are made available directly from the status page.
|
||||
|
||||
<div style={{ maxWidth: "700px", margin: "0 auto" }}>
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/upgrade-honcho.png" alt="Upgrade Honcho" loading="lazy" decoding="async" fetchpriority="low" style={{ width: "100%", height: "auto" }} />
|
||||
</Frame>
|
||||
</div>
|
||||
|
||||
The **Performance** page provides comprehensive monitoring with usage metrics, health analytics, API response times, and endpoint usage across Honcho.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/performance-analytics.png" alt="Performance Analytics Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 3. Manage API Keys
|
||||
The [API Keys](https://app.honcho.dev/api-keys) page allows you to create and manage authentication tokens for different environments. You can create admin-level keys with full instance access or scope keys to specific `Workspaces`, `Peers`, or `Sessions`.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/api-keys.png" alt="API Key Management Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 4. Test with API Playground
|
||||
The [API Playground](https://app.honcho.dev/playground) provides a Postman-like interface to test queries, explore endpoints, and validate your integration. Authenticate with an API key and send requests directly to your Honcho instance with real-time responses and full request/response logging.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/api-playground.png" alt="API Playground Interface" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 5. Workspaces
|
||||
The [Explore](https://app.honcho.dev/explore) page provides comprehensive `Workspace` management where you can create workspaces and begin exploring the platform. Each `Workspace` serves as a container for organizing your Honcho data.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/explore-honcho.png" alt="Workspace Table" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Click into any workspace to access a general overview of `Peers` and `Sessions`. Here you can quickly create `Peers`, `Sessions`, and add multiple `Peers` to any `Session`. Edit the metadata and configuration for a `Workspace` with the Edit Config button. Click into any entity to navigate to their respective utilities pages or click the expand icon to view Workspace-wide `Peers` and `Sessions` data tables with more details.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/workspace-dash.png" alt="Workspace Dashboard Overview" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 6. Peer Dashboard & Utilities
|
||||
Expand the `Peers` list from the `Workspace` dashboard to see a detailed view of `Peers`.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/peer-dash.png" alt="Peer Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Click into any peer to navigate to their respective utilities page. Next to the `Peer` name you can edit the [Global Peer Configuration](/v2.6.0-alpha/documentation/core-concepts/configuration), and in the tabs below, explore all utilities for the `Peer`.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/peer-utilities.png" alt="Peer Management Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Utilities include:
|
||||
- **Message search** across all sessions for a `Peer`
|
||||
- **Dialectic Chat** to query `Peer` representations globally or session-scoped (results vary dependant on the `Peer`'s configuration)
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/chat-endpoint.png" alt="Chat Endpoint" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
- **Session logs** view which `Sessions` the `Peer` is active
|
||||
- **Peer configuration and metadata management** including [Session-Peer Configuration](/v2.6.0-alpha/documentation/core-concepts/configuration#session-peer-configuration)
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/peer-utilities.png" alt="Peer Management Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 7. Session Dashboard & Utilities
|
||||
Click into the sessions view within a workspace to see a table of all of your `Sessions` data.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/session-dash.png" alt="Sessions Table" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Click into a `Session` to open its utilities page.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/session-utilities.png" alt="Session Utilities" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
Here you can:
|
||||
- **View and add Messages** within the `Session`; filter messages by `Peer`
|
||||
- **Advanced search** across `Session` messages
|
||||
- **Peer management** for adding/removing `Peers` and editing a `Peer`'s Session-level configuration
|
||||
- **Get Context** to generate LLM-ready context with customizable token limits
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/get-context.png" alt="Get Context" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 8. Webhooks Integration
|
||||
The [Webhooks](https://app.honcho.dev/webhooks) page enables Webhook creation and management.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/webhooks-page.png" alt="Webhooks Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## 9. Organization Member Access
|
||||
The [Members](https://app.honcho.dev/members) page provides organization administration to manage your team's access to Honcho with the ability to grant admin permissions.
|
||||
|
||||
<Frame>
|
||||
<img src="/images/app-screenshots/members-dashboard.png" alt="Members Dashboard" width="1200" height="800" loading="lazy" decoding="async" fetchpriority="low" />
|
||||
</Frame>
|
||||
|
||||
## Go Further
|
||||
|
||||
View the [Architecture](/v2.6.0-alpha/documentation/core-concepts/architecture) to see how Honcho works under the hood.
|
||||
|
||||
Dive into our [API Reference](/v2.6.0-alpha/api-reference) to explore all available endpoints.
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Sign up to Honcho Platform" icon="rocket" href="https://app.honcho.dev">
|
||||
Get started with managed Honcho instances
|
||||
</Card>
|
||||
<Card title="Join our Discord" icon="discord" href="http://discord.gg/plasticlabs">
|
||||
Connect with 1000+ developers building with Honcho
|
||||
</Card>
|
||||
<Card title="Contribute to Honcho" icon="code" href="/v2.6.0-alpha/contributing/guidelines">
|
||||
View our guidelines and explore the codebase
|
||||
</Card>
|
||||
<Card title="Explore Examples" icon="book" href="/v2.6.0-alpha/guides">
|
||||
See Honcho in action with real examples
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
We're excited to see what you'll build with Honcho Platform. Let's create smarter, more personalized AI experiences together!
|
||||
|
||||
---
|
||||
|
||||
*Ready to build personally aligned AI? [Get started with Honcho →](https://app.honcho.dev)*
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -150,13 +150,13 @@ for query in user_queries:
|
|||
## Related Features
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Basic Get Context" icon="database" href="/v2/documentation/core-concepts/features/get-context">
|
||||
<Card title="Basic Get Context" icon="database" href="/v2.6.0-alpha/documentation/core-concepts/features/get-context">
|
||||
Learn about basic context retrieval
|
||||
</Card>
|
||||
<Card title="Summaries" icon="align-left" href="/v2/documentation/core-concepts/summarizer">
|
||||
<Card title="Summaries" icon="align-left" href="/v2.6.0-alpha/documentation/core-concepts/summarizer">
|
||||
Understand session summarization
|
||||
</Card>
|
||||
<Card title="Dialectic API" icon="comments" href="/v2/documentation/core-concepts/features/dialectic-endpoint">
|
||||
<Card title="Dialectic API" icon="comments" href="/v2.6.0-alpha/documentation/core-concepts/features/dialectic-endpoint">
|
||||
Chat with Honcho for insights
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -237,19 +237,19 @@ and Bob. We:
|
|||
|
||||
As soon as you save a message in Honcho, it will start to reason about it to
|
||||
pull out insights and develop a profile of the user. This is the default
|
||||
behavior and can be toggled off via [the configuration](/v2/documentation/core-concepts/configuration).
|
||||
behavior and can be toggled off via [the configuration](/v2.6.0-alpha/documentation/core-concepts/configuration).
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Architecture" icon="rocket"
|
||||
href="/v2/documentation/core-concepts/architecture">
|
||||
href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
Learn about the data primitives in Honcho and how they work together
|
||||
</Card>
|
||||
<Card title="Start Building" icon="brain" href="https://app.honcho.dev">
|
||||
Sign up for Managed Honcho and get started building agents now.
|
||||
</Card>
|
||||
<Card title="Guides" icon="book" href="/v2/guides/overview">
|
||||
<Card title="Guides" icon="book" href="/v2.6.0-alpha/guides/overview">
|
||||
Check out spellbooks to see different examples apps built with Honcho
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
title: Local vs Global Representations
|
||||
description: Model directional relationships between Peers in Honcho
|
||||
icon: location-pin
|
||||
---
|
||||
|
||||
One of the unique affordances of Honcho is that it allows developers to model
|
||||
directional relationships between Peers. What I mean by this is you can model
|
||||
how one `Peer` thinks about another `Peer`.
|
||||
|
||||
There are many use cases where you don't want every agent or human to know
|
||||
everything about another user such as games or multi-agent workflows. To
|
||||
illustrate this, the following examples shows 2 conversations.
|
||||
|
||||
Conversation #1 (With Bob and Alice)
|
||||
```
|
||||
Alice: I had a great breakfast today.
|
||||
Bob: What did you eat?
|
||||
Alice: I had pancakes and eggs and bacon
|
||||
```
|
||||
|
||||
Conversation #2 (With Alice and Charlie)
|
||||
```
|
||||
Alice: I actually didn't eat any breakfast today.
|
||||
Charlie: Oh that's too bad.
|
||||
Alice: But I lied to Bob and told him I did, so back me up if you see them.
|
||||
```
|
||||
|
||||
Alice told Bob a lie in this conversation. If we stored both of these
|
||||
conversations in Honcho with Alice, Bob, and Charlie as `Peers` and let them
|
||||
use Honcho to get insights on each other then Bob would immediately know this
|
||||
deception. For example:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Bob could run
|
||||
alice.chat("What did Alice eat today?")
|
||||
# Response: Alice did not eat anything today
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
This is a problem. Bob shouldn't be able to know everything about Alice in this
|
||||
situation. So to support these situations we support what we call **Local
|
||||
Representations**.
|
||||
|
||||
By default insights generated for a `Peer` are scoped globally. This means every
|
||||
message sent by that `Peer` in any conversation updates the same representation
|
||||
of that `Peer`. However, we can enable **Local Representations** so Bob can
|
||||
form a representation Alice based only on what they observe Alice do.
|
||||
|
||||
This feature is illustrated in the graphic below:
|
||||
<img src="/images/local-vs-global-reps.png" alt="Peer Representations" />
|
||||
|
||||
We can enable local representation for a `Peer` by setting `observe_others=True`.
|
||||
This is shown in the [Configure
|
||||
Reasoning](/v2.6.0-alpha/documentation/core-concepts/configuration) page.
|
||||
|
||||
Now if we used Bob's local representation of Alice then Bob would only get
|
||||
insights on what they've seen Alice say to them.
|
||||
|
||||
```python
|
||||
bob.chat(target="alice", query="What did Alice eat today?")
|
||||
# Response: Alice ate pancakes, eggs, and bacon
|
||||
```
|
||||
|
||||
<Note>
|
||||
Local Representations are turned off by default
|
||||
</Note>
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
---
|
||||
title: "Discord Bots with Honcho"
|
||||
icon: 'discord'
|
||||
description: "Use Honcho to build a Discord bot with conversational memory and context management."
|
||||
sidebarTitle: 'Discord Bot'
|
||||
---
|
||||
|
||||
> Example code is available on [GitHub](https://github.com/plastic-labs/discord-python-starter)
|
||||
|
||||
Any application interface that defines logic based on events and supports
|
||||
special commands can work easily with Honcho. Here's how to use Honcho with
|
||||
**Discord** as an interface. If you're not familiar with Discord bot
|
||||
application logic, the [py-cord](https://pycord.dev/) docs would be a good
|
||||
place to start.
|
||||
|
||||
## Events
|
||||
|
||||
Most Discord bots have async functions that listen for specific events, the most common one being messages. We can use Honcho to store messages by user and session based on an interface's event logic. Take the following function definition for example:
|
||||
|
||||
```python
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
"""
|
||||
Receive a message from Discord and respond with a message from our LLM assistant.
|
||||
"""
|
||||
if not validate_message(message):
|
||||
return
|
||||
|
||||
input = sanitize_message(message)
|
||||
|
||||
# If the message is empty after sanitizing, ignore it
|
||||
if not input:
|
||||
return
|
||||
|
||||
peer = honcho_client.peer(id=get_peer_id_from_discord(message))
|
||||
session = honcho_client.session(id=str(message.channel.id))
|
||||
|
||||
async with message.channel.typing():
|
||||
response = llm(session, input)
|
||||
|
||||
await send_discord_message(message, response)
|
||||
|
||||
# Save both the user's message and the bot's response to the session
|
||||
session.add_messages(
|
||||
[
|
||||
peer.message(input),
|
||||
assistant.message(response),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Let's break down what this code is doing...
|
||||
|
||||
```python
|
||||
@bot.event
|
||||
async def on_message(message):
|
||||
if not validate_message(message):
|
||||
return
|
||||
```
|
||||
|
||||
This is how you define an event function in `py-cord` that listens for messages. We use a helper function `validate_message()` to check if the message should be processed.
|
||||
|
||||
## Helper Functions
|
||||
|
||||
The code uses several helper functions to keep the main logic clean and readable. Let's examine each one:
|
||||
|
||||
### Message Validation
|
||||
|
||||
```python
|
||||
def validate_message(message) -> bool:
|
||||
"""
|
||||
Determine if the message is valid for the bot to respond to.
|
||||
Return True if it is, False otherwise. Currently, the bot will
|
||||
only respond to messages that tag it with an @mention in a
|
||||
public channel and are not from the bot itself.
|
||||
"""
|
||||
if message.author == bot.user:
|
||||
# ensure the bot does not reply to itself
|
||||
return False
|
||||
|
||||
if isinstance(message.channel, discord.DMChannel):
|
||||
return False
|
||||
|
||||
if not bot.user.mentioned_in(message):
|
||||
return False
|
||||
|
||||
return True
|
||||
```
|
||||
|
||||
This function centralizes all the logic for determining whether the bot should respond to a message. It checks that:
|
||||
- The message isn't from the bot itself
|
||||
- The message isn't in a DM channel
|
||||
- The bot is mentioned in the message
|
||||
|
||||
### Message Sanitization
|
||||
|
||||
```python
|
||||
def sanitize_message(message) -> str | None:
|
||||
"""Remove the bot's mention from the message content if present"""
|
||||
content = message.content.replace(f"<@{bot.user.id}>", "").strip()
|
||||
if not content:
|
||||
return None
|
||||
return content
|
||||
```
|
||||
|
||||
This helper removes the bot's mention from the message content, leaving just the actual user input.
|
||||
|
||||
### Peer ID Generation
|
||||
|
||||
```python
|
||||
def get_peer_id_from_discord(message):
|
||||
"""Get a Honcho peer ID for the message author"""
|
||||
return f"discord_{str(message.author.id)}"
|
||||
```
|
||||
|
||||
This creates a unique peer identifier for each Discord user by prefixing their Discord ID.
|
||||
|
||||
### LLM Integration
|
||||
|
||||
```python
|
||||
def llm(session, prompt) -> str:
|
||||
"""
|
||||
Call the LLM with the given prompt and chat history.
|
||||
|
||||
You should expand this function with custom logic, prompts, etc.
|
||||
"""
|
||||
messages: list[dict[str, object]] = session.get_context().to_openai(
|
||||
assistant=assistant
|
||||
)
|
||||
messages.append({"role": "user", "content": prompt})
|
||||
|
||||
try:
|
||||
completion = openai.chat.completions.create(
|
||||
model=MODEL_NAME,
|
||||
messages=messages,
|
||||
)
|
||||
return completion.choices[0].message.content
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return f"Error: {e}"
|
||||
```
|
||||
|
||||
This function handles the LLM interaction. It uses Honcho's built-in `to_openai()` method to automatically convert the session context into the format expected by OpenAI's chat completions API.
|
||||
|
||||
### Message Sending
|
||||
|
||||
```python
|
||||
async def send_discord_message(message, response_content: str):
|
||||
"""Send a message to the Discord channel"""
|
||||
if len(response_content) > 1500:
|
||||
# Split response into chunks at newlines, keeping under 1500 chars
|
||||
chunks = []
|
||||
current_chunk = ""
|
||||
for line in response_content.splitlines(keepends=True):
|
||||
if len(current_chunk) + len(line) > 1500:
|
||||
chunks.append(current_chunk)
|
||||
current_chunk = line
|
||||
else:
|
||||
current_chunk += line
|
||||
if current_chunk:
|
||||
chunks.append(current_chunk)
|
||||
|
||||
for chunk in chunks:
|
||||
await message.channel.send(chunk)
|
||||
else:
|
||||
await message.channel.send(response_content)
|
||||
```
|
||||
|
||||
This function handles sending messages to Discord, automatically splitting long responses into multiple messages to stay within Discord's character limits.
|
||||
|
||||
## Honcho Integration
|
||||
|
||||
The new Honcho peer/session API makes integration much simpler:
|
||||
|
||||
```python
|
||||
peer = honcho_client.peer(id=get_peer_id_from_discord(message))
|
||||
session = honcho_client.session(id=str(message.channel.id))
|
||||
```
|
||||
|
||||
Here we create a peer object for the user and a session object using the Discord channel ID. This automatically handles user and session management.
|
||||
|
||||
```python
|
||||
# Save both the user's message and the bot's response to the session
|
||||
session.add_messages(
|
||||
[
|
||||
peer.message(input),
|
||||
assistant.message(response),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
After generating the response, we save both the user's input and the bot's response to the session using the `add_messages()` method. The `peer.message()` creates a message from the user, while `assistant.message()` creates a message from the assistant.
|
||||
|
||||
## Slash Commands
|
||||
|
||||
Discord bots also offer slash command functionality. Here's an example using Honcho's chat endpoint feature:
|
||||
|
||||
```python
|
||||
@bot.slash_command(
|
||||
name="chat",
|
||||
description="Query the peer's representation in natural language.",
|
||||
)
|
||||
async def chat(ctx, query: str):
|
||||
await ctx.defer()
|
||||
|
||||
try:
|
||||
peer = honcho_client.peer(id=get_peer_id_from_discord(ctx))
|
||||
session = honcho_client.session(id=str(ctx.channel.id))
|
||||
|
||||
response = peer.chat(
|
||||
query=query,
|
||||
session_id=session.id,
|
||||
)
|
||||
|
||||
if response:
|
||||
await ctx.followup.send(response)
|
||||
else:
|
||||
await ctx.followup.send(
|
||||
f"I don't know anything about {ctx.author.name} because we haven't talked yet!"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error calling Dialectic API: {e}")
|
||||
await ctx.followup.send(
|
||||
f"Sorry, there was an error processing your request: {str(e)}"
|
||||
)
|
||||
```
|
||||
|
||||
This slash command uses Honcho's chat endpoint functionality to answer questions about the user based on their conversation history.
|
||||
|
||||
## Setup and Configuration
|
||||
|
||||
The bot requires several environment variables and setup:
|
||||
|
||||
```python
|
||||
honcho_client = Honcho()
|
||||
assistant = honcho_client.peer(id="assistant", config={"observe_me": False})
|
||||
openai = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=MODEL_API_KEY)
|
||||
```
|
||||
|
||||
- `honcho_client`: The main Honcho client
|
||||
- `assistant`: A peer representing the bot/assistant
|
||||
- `openai`: OpenAI client configured to use OpenRouter
|
||||
|
||||
## Recap
|
||||
|
||||
The new Honcho peer/session API makes Discord bot integration much simpler and more intuitive. Key patterns we learned:
|
||||
|
||||
- **Peer/Session Model**: Users are represented as peers, conversations as sessions
|
||||
- **Automatic Context Management**: `session.get_context().to_openai()` automatically formats chat history
|
||||
- **Message Storage**: `session.add_messages()` stores both user and assistant messages
|
||||
- **Representation Queries**: `peer.chat()` enables querying conversation history
|
||||
- **Helper Functions**: Clean code organization with focused helper functions
|
||||
|
||||
This approach provides a clean, maintainable structure for building Discord bots with conversational memory and context management.
|
||||
|
|
@ -0,0 +1,294 @@
|
|||
---
|
||||
title: "CrewAI"
|
||||
icon: 'users-gear'
|
||||
description: "Build AI agents with persistent memory using CrewAI and Honcho"
|
||||
sidebarTitle: 'CrewAI'
|
||||
---
|
||||
|
||||
Integrate Honcho with CrewAI to build AI agents that maintain memory across sessions. This guide shows you how to use Honcho's memory layer with CrewAI's agent orchestration framework.
|
||||
|
||||
<Note>
|
||||
The full code is available on [GitHub](https://github.com/plastic-labs/honcho/tree/main/examples/crewai) with examples in [Python](https://github.com/plastic-labs/honcho/tree/main/examples/crewai/python/examples)
|
||||
</Note>
|
||||
|
||||
## What We're Building
|
||||
|
||||
We'll create AI agents that remember and reason over past conversations. Here's how the pieces fit together:
|
||||
|
||||
- **CrewAI** orchestrates agent behavior and task execution
|
||||
- **Honcho** stores messages and retrieves relevant context
|
||||
|
||||
The key benefit: CrewAI automatically retrieves relevant conversation history from Honcho without you needing to manually manage context, token limits, or message formatting.
|
||||
|
||||
<Note>
|
||||
This tutorial demonstrates single-agent setup to show how Honcho integrates with CrewAI. For production applications, you can extend this to multi-agent crews with shared or individual memory using Honcho's `peer` system.
|
||||
</Note>
|
||||
|
||||
## Setup
|
||||
|
||||
Install required packages:
|
||||
|
||||
<CodeGroup>
|
||||
```bash Python (uv)
|
||||
uv add honcho-crewai crewai python-dotenv
|
||||
```
|
||||
|
||||
```bash Python (pip)
|
||||
pip install honcho-crewai crewai python-dotenv
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Use any LLM provider for your Crew. Create a `.env` file with your API keys:
|
||||
|
||||
```bash
|
||||
OPENAI_API_KEY=your_openai_key
|
||||
```
|
||||
|
||||
<Note>
|
||||
This tutorial uses the Honcho demo server at https://demo.honcho.dev which runs a small instance of Honcho on the latest version. For production, get your Honcho API key at [app.honcho.dev](https://app.honcho.dev). For local development, use `environment="local"`.
|
||||
</Note>
|
||||
|
||||
## CrewAI Honcho Storage
|
||||
|
||||
The `honcho_crewai` package provides `HonchoStorage`, a storage provider that implements CrewAI's `Storage` interface using Honcho's session-based memory.
|
||||
|
||||
<Note>
|
||||
Before proceeding, it's important to understand Honcho's core concepts (`Peers` and `Sessions`). Review the [Honcho Architecture](/v2.6.0-alpha/documentation/core-concepts/architecture) to familiarize yourself with these primitives.
|
||||
</Note>
|
||||
|
||||
`HonchoStorage` implements CrewAI's `Storage` interface using Honcho's `peer` and `session` primitives.
|
||||
|
||||
```python
|
||||
storage = HonchoStorage(
|
||||
user_id="demo-user", # Required: Honcho `peer` ID for the user
|
||||
session_id=None, # Optional: Specific `session` ID (auto-generated UUID if None)
|
||||
honcho_client=None, # Optional: Pre-configured Honcho client instance
|
||||
)
|
||||
```
|
||||
|
||||
The `HonchoStorage` class implements three key methods:
|
||||
|
||||
- **`save()`** - Stores messages in Honcho's `session`, associating them with the appropriate `peer` (user or assistant)
|
||||
- **`search()`** - Performs semantic vector search using `session.search()` to find messages most relevant to the query. Supports optional `filters` parameter for fine-grained scoping.
|
||||
- **`reset()`** - Creates a new `session` to start fresh conversations
|
||||
|
||||
CrewAI automatically calls these methods when agents need to store or retrieve memory, creating a seamless integration.
|
||||
|
||||
### Search with Filters
|
||||
|
||||
The `search()` method supports an optional `filters` parameter for fine-grained scoping of search results:
|
||||
|
||||
```python
|
||||
# Search with peer_id filter (only messages from a specific peer)
|
||||
results = storage.search("query", filters={"peer_id": "user123"})
|
||||
|
||||
# Search with metadata filter
|
||||
results = storage.search("query", filters={"metadata": {"priority": "high"}})
|
||||
|
||||
# Search with time range filter
|
||||
results = storage.search("query", filters={"created_at": {"gte": "2024-01-01"}})
|
||||
|
||||
# Complex filter with logical operators
|
||||
results = storage.search("query", filters={
|
||||
"AND": [
|
||||
{"peer_id": "user123"},
|
||||
{"metadata": {"topic": "python"}}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
For the full filter syntax including logical operators (AND, OR, NOT), comparison operators, and metadata filtering, see the [Using Filters](https://docs.honcho.dev/v2.6.0-alpha/documentation/core-concepts/features/using-filters) documentation.
|
||||
|
||||
<Note>
|
||||
For comprehensive details about CrewAI's memory system, see the [official CrewAI Memory documentation](https://docs.crewai.com/en/concepts/memory).
|
||||
</Note>
|
||||
|
||||
Let's create a basic example showing how CrewAI agents use Honcho's memory automatically:
|
||||
|
||||
```python Python
|
||||
from dotenv import load_dotenv
|
||||
from crewai import Agent, Task, Crew, Process
|
||||
from crewai.memory.external.external_memory import ExternalMemory
|
||||
from honcho_crewai import HonchoStorage
|
||||
|
||||
load_dotenv()
|
||||
|
||||
storage = HonchoStorage(user_id="simple-demo-user")
|
||||
external_memory = ExternalMemory(storage=storage)
|
||||
|
||||
messages = [
|
||||
("user", "I'm learning Python programming"),
|
||||
("assistant", "Great! Python is an excellent language to learn."),
|
||||
("user", "I'm particularly interested in web development"),
|
||||
]
|
||||
|
||||
for role, message in messages:
|
||||
external_memory.save(message, metadata={"agent": role})
|
||||
|
||||
agent = Agent(
|
||||
role="Programming Mentor",
|
||||
goal="Help users learn programming by remembering their interests and progress",
|
||||
backstory=(
|
||||
"You are a patient programming mentor who remembers what students "
|
||||
"have told you about their learning journey and interests."
|
||||
),
|
||||
verbose=True,
|
||||
allow_delegation=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
description=(
|
||||
"Based on what you know about the user's interests, "
|
||||
"suggest a simple web development project they could build to practice Python."
|
||||
),
|
||||
expected_output="A specific project suggestion with brief explanation",
|
||||
agent=agent
|
||||
)
|
||||
|
||||
crew = Crew(
|
||||
agents=[agent],
|
||||
tasks=[task],
|
||||
process=Process.sequential,
|
||||
external_memory=external_memory,
|
||||
verbose=True
|
||||
)
|
||||
|
||||
result = crew.kickoff()
|
||||
print(result.raw)
|
||||
```
|
||||
|
||||
## CrewAI Tool Integration
|
||||
|
||||
Honcho provides specialized tools that give CrewAI agents explicit control over memory retrieval:
|
||||
|
||||
- **`HonchoGetContextTool`** - Retrieves comprehensive conversation history with token limits. Use for tasks needing broad conversation understanding.
|
||||
- **`HonchoDialecticTool`** - Queries representations about `peer`s. Use for understanding user preferences and characteristics without full message history.
|
||||
- **`HonchoSearchTool`** - Performs semantic search for specific information. Supports optional `filters` parameter for fine-grained scoping. Use for targeted queries like "what did the user say about budget?"
|
||||
|
||||
<Tip>
|
||||
Agents can use multiple tools in sequence: search for topics, query dialectic for preferences, then get full context for generation.
|
||||
</Tip>
|
||||
|
||||
Here's an example demonstrating all three tools:
|
||||
|
||||
```python Python
|
||||
from dotenv import load_dotenv
|
||||
from crewai import Agent, Task, Crew, Process
|
||||
from honcho import Honcho
|
||||
from honcho_crewai import (
|
||||
HonchoGetContextTool,
|
||||
HonchoDialecticTool,
|
||||
HonchoSearchTool,
|
||||
)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
honcho = Honcho()
|
||||
user_id = "demo-user-45"
|
||||
session_id = "tools-demo-session"
|
||||
|
||||
user = honcho.peer(user_id)
|
||||
session = honcho.session(session_id)
|
||||
|
||||
messages = [
|
||||
"I'm planning a trip to Japan in March",
|
||||
"I love trying authentic local cuisine, especially ramen and sushi",
|
||||
"My budget is around $3000 for a 10-day trip",
|
||||
"I'm interested in visiting both Tokyo and Kyoto",
|
||||
"I prefer staying in traditional ryokans over hotels",
|
||||
]
|
||||
|
||||
for msg in messages:
|
||||
session.add_messages([user.message(msg)])
|
||||
|
||||
context_tool = HonchoGetContextTool(
|
||||
honcho=honcho, session_id=session_id, peer_id=user_id
|
||||
)
|
||||
|
||||
dialectic_tool = HonchoDialecticTool(
|
||||
honcho=honcho, session_id=session_id, peer_id=user_id
|
||||
)
|
||||
|
||||
search_tool = HonchoSearchTool(honcho=honcho, session_id=session_id)
|
||||
|
||||
# Note: The search tool supports optional filters for fine-grained scoping
|
||||
# Agents can use filters like {"peer_id": "user123"} or {"metadata": {"priority": "high"}}
|
||||
|
||||
travel_agent = Agent(
|
||||
role="Travel Planning Specialist",
|
||||
goal="Create personalized travel recommendations using memory tools",
|
||||
backstory=(
|
||||
"You are an expert travel planner with access to conversation memory tools. "
|
||||
"Use the tools to understand the user's preferences before making recommendations."
|
||||
),
|
||||
tools=[context_tool, dialectic_tool, search_tool],
|
||||
verbose=True,
|
||||
allow_delegation=False
|
||||
)
|
||||
|
||||
task = Task(
|
||||
description=(
|
||||
"Create a personalized 3-day Tokyo itinerary. "
|
||||
"Use the memory tools to understand:\n"
|
||||
" • Food preferences (use search_tool for 'cuisine' or 'food')\n"
|
||||
" • Travel style and budget (use dialectic_tool to query user knowledge)\n"
|
||||
" • Recent context (use context_tool to get conversation history)\n"
|
||||
"Then create a detailed plan matching their interests."
|
||||
),
|
||||
expected_output=(
|
||||
"A 3-day Tokyo itinerary with:\n"
|
||||
" • Daily activities matching user interests\n"
|
||||
" • Restaurant recommendations\n"
|
||||
" • Accommodation suggestions\n"
|
||||
" • Budget considerations"
|
||||
),
|
||||
agent=travel_agent
|
||||
)
|
||||
|
||||
crew = Crew(
|
||||
agents=[travel_agent],
|
||||
tasks=[task],
|
||||
process=Process.sequential,
|
||||
verbose=True
|
||||
)
|
||||
|
||||
crew.kickoff()
|
||||
```
|
||||
|
||||
## Tool-Based vs Automatic Memory
|
||||
|
||||
**Use `HonchoStorage`** for automatic memory - CrewAI handles everything transparently. Best for simple conversational flows.
|
||||
|
||||
**Use Honcho Tools** for strategic control - agents decide when and how to query memory. Best for multi-step reasoning, when different query types are needed, or multi-agent systems.
|
||||
|
||||
You can combine both: automatic memory for baseline context, tools for specific queries. See the [hybrid memory example](https://github.com/plastic-labs/honcho/blob/main/examples/crewai/python/examples/hybrid_memory_example.py) for a complete implementation.
|
||||
|
||||
<Note>
|
||||
**Multi-Agent Memory:** Use Honcho tools with different `peer_id` values to give each agent distinct memory and identity.
|
||||
</Note>
|
||||
|
||||
## Next Steps
|
||||
|
||||
Now that you have a working CrewAI integration with Honcho, you can:
|
||||
|
||||
- **Create specialized agents** with domain-specific memory and context
|
||||
- **Use CrewAI's advanced features** like hierarchical processes, tool delegation, and conditional task execution
|
||||
- **Leverage logical reasoning** via the Dialectic API for deep `peer` understanding
|
||||
- **Implement custom tools** to give agents explicit control over memory retrieval
|
||||
|
||||
## Related Resources
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Honcho Architecture" icon="sitemap" href="/v2.6.0-alpha/documentation/core-concepts/architecture">
|
||||
Understand Honcho's peer-based model and core primitives
|
||||
</Card>
|
||||
<Card title="Get Context" icon="messages" href="/v2.6.0-alpha/documentation/core-concepts/features/get-context">
|
||||
Learn about retrieving and formatting conversation context
|
||||
</Card>
|
||||
<Card title="Dialectic API" icon="brain" href="/v2.6.0-alpha/documentation/core-concepts/features/dialectic">
|
||||
Query `peer` representations for deeper understanding
|
||||
</Card>
|
||||
<Card title="LangGraph Integration" icon="diagram-project" href="/v2.6.0-alpha/integrations/langgraph">
|
||||
Build stateful agents with LangGraph and Honcho
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,363 @@
|
|||
---
|
||||
title: "LangGraph"
|
||||
icon: 'diagram-project'
|
||||
description: "Build a stateful conversational AI agent with LangGraph and Honcho"
|
||||
sidebarTitle: 'LangGraph'
|
||||
---
|
||||
|
||||
Integrate Honcho with LangGraph to build a conversational AI agent that maintains memory across sessions. This guide shows you how to use Honcho's memory layer with LangGraph's orchestration.
|
||||
|
||||
<Note>
|
||||
The full code is available on [GitHub](https://github.com/plastic-labs/honcho/tree/main/examples/langgraph) with examples in both [Python](https://github.com/plastic-labs/honcho/blob/main/examples/langgraph/python/main.py) and [TypeScript](https://github.com/plastic-labs/honcho/blob/main/examples/langgraph/typescript/main.ts)
|
||||
</Note>
|
||||
|
||||
## What We're Building
|
||||
|
||||
We'll create a conversational agent that remembers and reasons over past exchanges with the user. Here's how the pieces fit together:
|
||||
|
||||
- **LangGraph** orchestrates the conversation flow
|
||||
- **Honcho** stores messages and retrieves relevant context
|
||||
- **Your LLM** generates responses using Honcho's formatted context
|
||||
|
||||
The key benefit: You don't manually manage conversation history, token limits, or message formatting. Honcho handles memory so you can focus on your agent's logic.
|
||||
|
||||
<Note>
|
||||
This tutorial demonstrates a simple linear conversation flow to show
|
||||
how Honcho integrates with LangGraph. For production applications,
|
||||
you'll likely want to add LangGraph features like conditional routing,
|
||||
tool calling, and multi-agent orchestration.
|
||||
</Note>
|
||||
|
||||
## Setup
|
||||
|
||||
Install required packages:
|
||||
|
||||
<CodeGroup>
|
||||
```bash Python (uv)
|
||||
uv add honcho-ai langgraph langchain-core openai python-dotenv
|
||||
```
|
||||
|
||||
```bash Python (pip)
|
||||
pip install honcho-ai langgraph langchain-core openai python-dotenv
|
||||
```
|
||||
|
||||
```bash TypeScript (npm)
|
||||
npm install @honcho-ai/sdk @langchain/langgraph openai dotenv
|
||||
```
|
||||
|
||||
```bash TypeScript (yarn)
|
||||
yarn add @honcho-ai/sdk @langchain/langgraph openai dotenv
|
||||
```
|
||||
|
||||
```bash TypeScript (pnpm)
|
||||
pnpm add @honcho-ai/sdk @langchain/langgraph openai dotenv
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
This tutorial uses OpenAI, but Honcho works with any LLM provider. Create a `.env` file with your API keys:
|
||||
|
||||
```bash
|
||||
OPENAI_API_KEY=your_openai_key
|
||||
```
|
||||
|
||||
<Note>
|
||||
This tutorial uses the Honcho demo server at https://demo.honcho.dev which runs a small instance of Honcho on the latest version. For production, get your Honcho API key at [app.honcho.dev](https://app.honcho.dev). For local development, use `environment="local"`.
|
||||
</Note>
|
||||
|
||||
## Initialize Clients
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from typing_extensions import TypedDict
|
||||
from honcho import Honcho, Peer, Session
|
||||
from openai import OpenAI
|
||||
from langgraph.graph import StateGraph, START, END
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Initialize Honcho
|
||||
honcho = Honcho()
|
||||
|
||||
# Initialize OpenAI
|
||||
llm = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import * as dotenv from "dotenv";
|
||||
import { Honcho, Peer, Session } from "@honcho-ai/sdk";
|
||||
import OpenAI from "openai";
|
||||
import { Annotation } from "@langchain/langgraph";
|
||||
import { StateGraph, START, END } from "@langchain/langgraph";
|
||||
import * as readline from "readline/promises";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
// Initialize Honcho
|
||||
const honcho = new Honcho({});
|
||||
|
||||
// Initialize OpenAI
|
||||
const llm = new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY
|
||||
});
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Define LangGraph State
|
||||
|
||||
Define your state schema to pass data through the graph. The state stores Honcho objects directly along with the current user message and assistant response.
|
||||
|
||||
<Note>
|
||||
Before proceeding, it's important to understand Honcho's core concepts (`Peers` and `Sessions`). Review the [Honcho Architecture](/v2.6.0-alpha/documentation/core-concepts/architecture) to familiarize yourself with these primitives.
|
||||
</Note>
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
class State(TypedDict):
|
||||
user_message: str
|
||||
assistant_response: str
|
||||
user: Peer
|
||||
assistant: Peer
|
||||
session: Session
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
const StateAnnotation = Annotation.Root({
|
||||
userMessage: Annotation<string>(),
|
||||
assistantResponse: Annotation<string>(),
|
||||
user: Annotation<Peer>(),
|
||||
assistant: Annotation<Peer>(),
|
||||
session: Annotation<Session>(),
|
||||
});
|
||||
|
||||
type State = typeof StateAnnotation.State;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Build the LangGraph
|
||||
|
||||
Define your chatbot logic, using Honcho to retrieve conversation context. This function demonstrates how Honcho can store messages, retrieve context, and generate responses.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
def chatbot(state: State):
|
||||
user_message = state["user_message"]
|
||||
|
||||
# Get objects from state
|
||||
user = state["user"]
|
||||
assistant = state["assistant"]
|
||||
session = state["session"]
|
||||
|
||||
# Step 1: Store the user's message in the session
|
||||
# This adds it to Honcho's memory for future context retrieval
|
||||
session.add_messages([user.message(user_message)])
|
||||
|
||||
# Step 2: Get context in OpenAI format with token limit
|
||||
# get_context() retrieves relevant conversation history
|
||||
# tokens=2000 limits the context to 2000 tokens to manage costs and fit within model limits
|
||||
# to_openai() converts it to the format expected by OpenAI's API
|
||||
messages = session.get_context(tokens=2000).to_openai(assistant=assistant)
|
||||
|
||||
# Step 3: Generate response using the context
|
||||
response = llm.chat.completions.create(
|
||||
model="gpt-5.1",
|
||||
messages=messages
|
||||
)
|
||||
assistant_response = response.choices[0].message.content
|
||||
|
||||
# Step 4: Store assistant response in Honcho for future context
|
||||
session.add_messages([assistant.message(assistant_response)])
|
||||
|
||||
return {"assistant_response": assistant_response}
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
async function chatbot(state: State) {
|
||||
const userMessage = state.userMessage;
|
||||
|
||||
// Get objects from state
|
||||
const user = state.user;
|
||||
const assistant = state.assistant;
|
||||
const session = state.session;
|
||||
|
||||
// Step 1: Store the user's message in the session
|
||||
// This adds it to Honcho's memory for future context retrieval
|
||||
await session.addMessages([user.message(userMessage)]);
|
||||
|
||||
// Step 2: Get context in OpenAI format with token limit
|
||||
// getContext() retrieves relevant conversation history
|
||||
// tokens: 2000 limits the context to 2000 tokens to manage costs and fit within model limits
|
||||
// toOpenAI() converts it to the format expected by OpenAI's API
|
||||
const messages = (await session.getContext({ tokens: 2000 })).toOpenAI(assistant);
|
||||
|
||||
// Step 3: Generate response using the context
|
||||
const response = await llm.chat.completions.create({
|
||||
model: "gpt-5.1",
|
||||
messages: messages
|
||||
});
|
||||
const assistantResponse = response.choices[0].message.content!;
|
||||
|
||||
// Step 4: Store assistant response for future context
|
||||
await session.addMessages([assistant.message(assistantResponse)]);
|
||||
|
||||
return { assistantResponse: assistantResponse };
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Now let's build the LangGraph:
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
graph = StateGraph(State) \
|
||||
.add_node("chatbot", chatbot) \
|
||||
.add_edge(START, "chatbot") \
|
||||
.add_edge("chatbot", END) \
|
||||
.compile()
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
const graph = new StateGraph(StateAnnotation)
|
||||
.addNode("chatbot", chatbot)
|
||||
.addEdge(START, "chatbot")
|
||||
.addEdge("chatbot", END)
|
||||
.compile();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Understanding get_context()
|
||||
|
||||
The [`get_context()`](/v2.6.0-alpha/documentation/core-concepts/features/get-context) method retrieves comprehensive conversation context and formats it for your LLM. It automatically:
|
||||
|
||||
- **Manages conversation history** - Tracks all messages and determines what's relevant
|
||||
- **Respects token limits** - Stays within context window constraints without manual counting
|
||||
- **Handles long conversations** - Combines recent detailed messages with summaries of older exchanges
|
||||
- **Provides `peer` understanding** - Includes representations and `peer` cards when requested
|
||||
|
||||
The `SessionContext` object always includes fields for messages, summaries, `peer` representations, and `peer` cards. By default, only `messages` and `summary` are populated. To populate peer-specific context, pass a `peer_target` parameter:
|
||||
|
||||
**Using `peer_target` for Context:**
|
||||
|
||||
- **Without `peer_perspective`**: Returns Honcho's omniscient view of `peer_target` (all observations and context)
|
||||
- **With `peer_perspective`**: Returns what `peer_perspective` knows about `peer_target` (perspective-based observations and context)
|
||||
|
||||
That's it. Call `session.get_context().to_openai(assistant)` and you get properly formatted context tailored for your assistant.
|
||||
|
||||
<Tip>
|
||||
**Adding System Prompts:** Since `get_context()` returns conversation messages, you can easily prepend custom system instructions. Just add your system prompt to the beginning of the messages array before sending it to your LLM: `[{"role": "system", "content": "..."}, ...context_messages]`.
|
||||
</Tip>
|
||||
|
||||
<Note>
|
||||
For more details on all available parameters, see [`get_context() documentation`](/v2.6.0-alpha/documentation/core-concepts/features/get-context)
|
||||
</Note>
|
||||
|
||||
## Chat Loop
|
||||
|
||||
Now we'll create the main conversation function. To simplify logic, we initialize Honcho objects once per conversation and pass them through the LangGraph state.
|
||||
|
||||
The `run_conversation_turn` function initializes a Honcho `Session` and `Peer` objects, passes them to the LangGraph, and returns the assistant's response. By calling it repeatedly with the same `user_id` and in the same session, the chat builds context over time.
|
||||
|
||||
<Note>
|
||||
**Production Usage:** Honcho accepts any nanoid-compatible string for `user_id` and `session_id`. You can use IDs directly from your authentication system (Auth0, Firebase, Clerk, etc.) and session management without modification.
|
||||
|
||||
This tutorial uses hardcoded values for simplicity.
|
||||
</Note>
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
def run_conversation_turn(user_id: str, user_input: str, session_id: str | None = None):
|
||||
if not session_id:
|
||||
session_id = f"session_{user_id}"
|
||||
|
||||
# Initialize Honcho objects
|
||||
user = honcho.peer(user_id)
|
||||
assistant = honcho.peer("assistant")
|
||||
session = honcho.session(session_id)
|
||||
|
||||
result = graph.invoke({
|
||||
"user_message": user_input,
|
||||
"user": user,
|
||||
"assistant": assistant,
|
||||
"session": session
|
||||
})
|
||||
|
||||
return result["assistant_response"]
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Welcome to the AI Assistant! How can I help you today?")
|
||||
user_id = "test-user-123"
|
||||
while True:
|
||||
user_input = input("You: ")
|
||||
if user_input.lower() in ['quit', 'exit']:
|
||||
break
|
||||
response = run_conversation_turn(user_id, user_input)
|
||||
print(f"Assistant: {response}\n")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
async function runConversationTurn(
|
||||
userId: string,
|
||||
userInput: string,
|
||||
sessionId?: string
|
||||
): Promise<string> {
|
||||
if (!sessionId) {
|
||||
sessionId = `session_${userId}`;
|
||||
}
|
||||
|
||||
// Initialize Honcho objects
|
||||
const user = await honcho.peer(userId);
|
||||
const assistant = await honcho.peer("assistant");
|
||||
const session = await honcho.session(sessionId);
|
||||
|
||||
const result = await graph.invoke({
|
||||
userMessage: userInput,
|
||||
user: user,
|
||||
assistant: assistant,
|
||||
session: session,
|
||||
});
|
||||
|
||||
return result.assistantResponse;
|
||||
}
|
||||
|
||||
// Interactive chat loop
|
||||
async function main() {
|
||||
console.log("Welcome to the AI Assistant! How can I help you today?");
|
||||
const userId = "test-user-123";
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
while (true) {
|
||||
const userInput = await rl.question("You: ");
|
||||
if (userInput.toLowerCase() === "quit" || userInput.toLowerCase() === "exit") {
|
||||
rl.close();
|
||||
break;
|
||||
}
|
||||
const response = await runConversationTurn(userId, userInput);
|
||||
console.log(`Assistant: ${response}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
## Next Steps
|
||||
|
||||
Now that you have a working LangGraph integration with Honcho, you can:
|
||||
|
||||
- **Create custom [LangChain tools](https://docs.langchain.com/oss/python/langchain/tools#customize-tool-properties) for your agent** - to fully utilize Honcho's memory & context management features
|
||||
- **Build a multi-agent LangGraph** where each agent is a Honcho `Peer` with its own memory
|
||||
|
||||
## Related Resources
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Get Context" icon="messages" href="/v2.6.0-alpha/documentation/core-concepts/features/get-context">
|
||||
Learn more about retrieving and formatting conversation context
|
||||
</Card>
|
||||
<Card title="MCP Integration" icon="star-of-life" href="/v2.6.0-alpha/integrations/mcp">
|
||||
Use Honcho in Claude Desktop with MCP
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
title: "Guides, Cookbooks, and Integrations"
|
||||
sidebarTitle: 'Overview'
|
||||
description: 'Helpful guides and design patterns for building with Honcho'
|
||||
icon: 'hat-wizard'
|
||||
---
|
||||
|
||||
<Note> Before you start a guide, follow [Quickstart](/v2.6.0-alpha/documentation/introduction/quickstart) to get up and running with Honcho in your language of choice. </Note>
|
||||
|
||||
These guides provide concrete examples and implementation patterns for building with Honcho. Whether you're integrating Honcho into existing platforms, exploring advanced features, or getting up and running quickly, you'll find working code you can adapt to your needs.
|
||||
|
||||
Each guide focuses on a specific use case with practical examples. The goal is to get you from idea to working prototype as quickly as possible, then provide the depth you need to scale and customize.
|
||||
|
||||
|
||||
## Getting Started
|
||||
Quick integration guides to get up and running:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="MCP Integration" icon="link" href="/v2.6.0-alpha/integrations/mcp">
|
||||
Get Honcho running with a single prompt in Claude Code
|
||||
</Card>
|
||||
<Card title="LangGraph" icon="diagram-project" href="/v2.6.0-alpha/integrations/langgraph">
|
||||
Add persistent memory and theory of mind to your LangGraph agents
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Application Interfaces
|
||||
Ready-to-use integration patterns for popular platforms:
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Discord Bot" icon="discord" href="/v2.6.0-alpha/guides/discord">
|
||||
Build a Discord bot that remembers users across conversations
|
||||
</Card>
|
||||
<Card title="Telegram Bot" icon="telegram" href="/v2.6.0-alpha/guides/telegram">
|
||||
Create a Telegram bot with persistent user understanding
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
title: Storing Data
|
||||
description: "Store Data in Honcho to Generate Memories and Insights"
|
||||
icon: "memory"
|
||||
---
|
||||
|
||||
The most basic building block of Honcho's data model is the `Message` object.
|
||||
A `Message` is sent by a `Peer` and saved in a `Session`
|
||||
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from honcho import Honcho
|
||||
|
||||
honcho = Honcho()
|
||||
|
||||
peer = honcho.peer("sample-peer")
|
||||
|
||||
session = honcho.session("sample-session")
|
||||
|
||||
message = peer.message("Hello, world!")
|
||||
|
||||
session.add_messages([message])
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
const honcho = new Honcho({});
|
||||
|
||||
const peer = await honcho.peer('sample-peer');
|
||||
|
||||
const session = await honcho.session('sample-session');
|
||||
|
||||
const message = peer.message('Hello, world!');
|
||||
|
||||
await session.addMessages([message]);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Once a `Message` is saved in Honcho, it will kick off a background task that
|
||||
looks at the new data to generate insights about the `Peer` that sent the `Message`
|
||||
|
||||
This is the default behavior of Honcho and can be turned off by [configuring the
|
||||
Peer or Session](/v2.6.0-alpha/documentation/core-concepts/configuration)
|
||||
|
||||
This pattern of having a Peer, Session, and Messages is highly flexible and
|
||||
works for many different use cases and agent setups. Some use cases may only
|
||||
need a single Peer, but many Sessions. Others will only use a single `Session`
|
||||
for their entire app. These are flexible components that work in any situation.
|
||||
|
||||
## Chat Bots
|
||||
|
||||
A common use case for Honcho to is to build a chatbot like ChatGPT or Claude.
|
||||
In this case you can simply
|
||||
|
||||
- Make a `Peer` for the User
|
||||
- Make a `Peer` for the AI
|
||||
|
||||
Then you can make a `Session` for each thread of conversation and save
|
||||
`Messages` from the user and assistant in each turn of conversation
|
||||
|
|
@ -0,0 +1,359 @@
|
|||
---
|
||||
title: "Telegram Bots with Honcho"
|
||||
icon: 'telegram'
|
||||
description: "Use Honcho to build a Telegram bot with conversational memory and context management."
|
||||
sidebarTitle: 'Telegram Bot'
|
||||
---
|
||||
|
||||
> Example code is available on [GitHub](https://github.com/plastic-labs/telegram-python-starter)
|
||||
|
||||
Any application interface that defines logic based on events and supports
|
||||
special commands can work easily with Honcho. Here's how to use Honcho with
|
||||
**Telegram** as an interface. If you're not familiar with Telegram bot
|
||||
development, the [python-telegram-bot](https://docs.python-telegram-bot.org/en/stable/) docs would be a good
|
||||
place to start.
|
||||
|
||||
## Message Handling
|
||||
|
||||
Most Telegram bots have async functions that handle incoming messages. We can use Honcho to store messages by user and session based on the chat context. Take the following function definition for example:
|
||||
|
||||
```python
|
||||
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
"""
|
||||
Receive a message from Telegram and respond with a message from our LLM assistant.
|
||||
"""
|
||||
if not validate_message(update, context):
|
||||
return
|
||||
|
||||
message_text = update.effective_message.text
|
||||
input_text = sanitize_message(message_text, context.bot.username)
|
||||
|
||||
# If the message is empty after sanitizing, ignore it
|
||||
if not input_text:
|
||||
return
|
||||
|
||||
peer = honcho_client.peer(id=get_peer_id_from_telegram(update))
|
||||
session = honcho_client.session(id=str(update.effective_chat.id))
|
||||
|
||||
# Send typing indicator
|
||||
await context.bot.send_chat_action(
|
||||
chat_id=update.effective_chat.id, action="typing"
|
||||
)
|
||||
|
||||
response = llm(session, input_text)
|
||||
|
||||
await send_telegram_message(update, context, response)
|
||||
|
||||
# Save both the user's message and the bot's response to the session
|
||||
session.add_messages(
|
||||
[
|
||||
peer.message(input_text),
|
||||
assistant.message(response),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Let's break down what this code is doing...
|
||||
|
||||
```python
|
||||
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
if not validate_message(update, context):
|
||||
return
|
||||
```
|
||||
|
||||
This is how you define a message handler in `python-telegram-bot` that processes incoming messages. We use a helper function `validate_message()` to check if the message should be processed.
|
||||
|
||||
## Helper Functions
|
||||
|
||||
The code uses several helper functions to keep the main logic clean and readable. Let's examine each one:
|
||||
|
||||
### Message Validation
|
||||
|
||||
```python
|
||||
def validate_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> bool:
|
||||
"""
|
||||
Determine if the message is valid for the bot to respond to.
|
||||
Return True if it is, False otherwise. The bot will respond to:
|
||||
- Direct messages (private chats)
|
||||
- Group messages that mention the bot or reply to it
|
||||
- Messages that are not from the bot itself
|
||||
"""
|
||||
message = update.effective_message
|
||||
|
||||
if not message or not message.text:
|
||||
return False
|
||||
|
||||
# Don't respond to our own messages
|
||||
if message.from_user.id == context.bot.id:
|
||||
return False
|
||||
|
||||
# Always respond in private chats
|
||||
if update.effective_chat.type == "private":
|
||||
return True
|
||||
|
||||
# In groups, only respond if mentioned or replied to
|
||||
if (
|
||||
message.reply_to_message
|
||||
and message.reply_to_message.from_user.id == context.bot.id
|
||||
):
|
||||
return True
|
||||
|
||||
# Check if bot is mentioned
|
||||
if message.entities:
|
||||
for entity in message.entities:
|
||||
if entity.type == "mention":
|
||||
username = message.text[entity.offset : entity.offset + entity.length]
|
||||
if username == f"@{context.bot.username}":
|
||||
return True
|
||||
|
||||
return False
|
||||
```
|
||||
|
||||
This function centralizes all the logic for determining whether the bot should respond to a message. It handles different chat types:
|
||||
- **Private chats**: Always respond
|
||||
- **Group chats**: Only respond when mentioned or when replying to the bot's messages
|
||||
- **Bot prevention**: Never respond to the bot's own messages
|
||||
|
||||
### Message Sanitization
|
||||
|
||||
```python
|
||||
def sanitize_message(message_text: str, bot_username: str) -> str | None:
|
||||
"""Remove the bot's mention from the message content if present"""
|
||||
content = message_text.replace(f"@{bot_username}", "").strip()
|
||||
if not content:
|
||||
return None
|
||||
return content
|
||||
```
|
||||
|
||||
This helper removes the bot's mention from the message content, leaving just the actual user input.
|
||||
|
||||
### Peer ID Generation
|
||||
|
||||
```python
|
||||
def get_peer_id_from_telegram(update: Update) -> str:
|
||||
"""Get a Honcho peer ID for the message author"""
|
||||
return f"telegram_{update.effective_user.id}"
|
||||
```
|
||||
|
||||
This creates a unique peer identifier for each Telegram user by prefixing their Telegram user ID.
|
||||
|
||||
### LLM Integration
|
||||
|
||||
```python
|
||||
def llm(session, prompt) -> str:
|
||||
"""
|
||||
Call the LLM with the given prompt and chat history.
|
||||
|
||||
You should expand this function with custom logic, prompts, etc.
|
||||
"""
|
||||
messages: list[dict[str, object]] = session.get_context().to_openai(
|
||||
assistant=assistant
|
||||
)
|
||||
messages.append({"role": "user", "content": prompt})
|
||||
|
||||
try:
|
||||
completion = openai.chat.completions.create(
|
||||
model=MODEL_NAME,
|
||||
messages=messages,
|
||||
)
|
||||
return completion.choices[0].message.content
|
||||
except Exception as e:
|
||||
logger.error(f"LLM error: {e}")
|
||||
return f"Error: {e}"
|
||||
```
|
||||
|
||||
This function handles the LLM interaction. It uses Honcho's built-in `to_openai()` method to automatically convert the session context into the format expected by OpenAI's chat completions API.
|
||||
|
||||
### Message Sending
|
||||
|
||||
```python
|
||||
async def send_telegram_message(
|
||||
update: Update, context: ContextTypes.DEFAULT_TYPE, response_content: str
|
||||
):
|
||||
"""Send a message to the Telegram chat, splitting if necessary"""
|
||||
# Telegram has a 4096 character limit, but we'll use 4000 to be safe
|
||||
max_length = 4000
|
||||
|
||||
if len(response_content) <= max_length:
|
||||
await update.effective_message.reply_text(response_content)
|
||||
else:
|
||||
# Split response into chunks at newlines, keeping under max_length chars
|
||||
chunks = []
|
||||
current_chunk = ""
|
||||
|
||||
for line in response_content.splitlines(keepends=True):
|
||||
if len(current_chunk) + len(line) > max_length:
|
||||
if current_chunk:
|
||||
chunks.append(current_chunk)
|
||||
current_chunk = line
|
||||
else:
|
||||
current_chunk += line
|
||||
|
||||
if current_chunk:
|
||||
chunks.append(current_chunk)
|
||||
|
||||
for chunk in chunks:
|
||||
await update.effective_message.reply_text(chunk)
|
||||
```
|
||||
|
||||
This function handles sending messages to Telegram, automatically splitting long responses into multiple messages to stay within Telegram's 4096 character limit. It also includes a typing indicator to show the bot is processing.
|
||||
|
||||
## Honcho Integration
|
||||
|
||||
The new Honcho peer/session API makes integration much simpler:
|
||||
|
||||
```python
|
||||
peer = honcho_client.peer(id=get_peer_id_from_telegram(update))
|
||||
session = honcho_client.session(id=str(update.effective_chat.id))
|
||||
```
|
||||
|
||||
Here we create a peer object for the user and a session object using the Telegram chat ID. This automatically handles user and session management across both private chats and group conversations.
|
||||
|
||||
```python
|
||||
# Save both the user's message and the bot's response to the session
|
||||
session.add_messages(
|
||||
[
|
||||
peer.message(input_text),
|
||||
assistant.message(response),
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
After generating the response, we save both the user's input and the bot's response to the session using the `add_messages()` method. The `peer.message()` creates a message from the user, while `assistant.message()` creates a message from the assistant.
|
||||
|
||||
## Commands
|
||||
|
||||
Telegram bots support slash commands natively. Here's how to implement the `/dialectic` command using Honcho's dialectic feature:
|
||||
|
||||
```python
|
||||
async def dialectic_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
"""
|
||||
Handle the /dialectic command to query the Honcho Dialectic endpoint.
|
||||
"""
|
||||
if not context.args:
|
||||
await update.message.reply_text(
|
||||
"Please provide a query. Usage: /dialectic <your query>"
|
||||
)
|
||||
return
|
||||
|
||||
query = " ".join(context.args)
|
||||
|
||||
try:
|
||||
peer = honcho_client.peer(id=get_peer_id_from_telegram(update))
|
||||
session = honcho_client.session(id=str(update.effective_chat.id))
|
||||
|
||||
response = peer.chat(
|
||||
query=query,
|
||||
session_id=session.id,
|
||||
)
|
||||
|
||||
if response:
|
||||
await send_telegram_message(update, context, response)
|
||||
else:
|
||||
await update.message.reply_text(
|
||||
f"I don't know anything about {update.effective_user.first_name} because we haven't talked yet!"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error calling Dialectic API: {e}")
|
||||
await update.message.reply_text(
|
||||
f"Sorry, there was an error processing your request: {str(e)}"
|
||||
)
|
||||
```
|
||||
|
||||
You can also add a `/start` command for user onboarding:
|
||||
|
||||
```python
|
||||
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
"""Handle the /start command"""
|
||||
await update.message.reply_text(
|
||||
"Hello! I'm your AI assistant. You can:\n"
|
||||
"• Chat with me directly in private messages\n"
|
||||
"• Mention me (@username) in groups to get my attention\n"
|
||||
"• Use /dialectic <query> to search our conversation history\n\n"
|
||||
"Let's start chatting!"
|
||||
)
|
||||
```
|
||||
|
||||
## Setup and Configuration
|
||||
|
||||
The bot requires several environment variables and setup:
|
||||
|
||||
```python
|
||||
honcho_client = Honcho()
|
||||
assistant = honcho_client.peer(id="assistant", config={"observe_me": False})
|
||||
openai = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=MODEL_API_KEY)
|
||||
```
|
||||
|
||||
- `honcho_client`: The main Honcho client
|
||||
- `assistant`: A peer representing the bot/assistant
|
||||
- `openai`: OpenAI client configured to use OpenRouter
|
||||
|
||||
### Application Setup
|
||||
|
||||
Register your handlers with the Telegram application:
|
||||
|
||||
```python
|
||||
def main():
|
||||
"""Start the bot"""
|
||||
if not BOT_TOKEN:
|
||||
logger.error("BOT_TOKEN not found in environment variables")
|
||||
return
|
||||
|
||||
# Create the Application
|
||||
application = Application.builder().token(BOT_TOKEN).build()
|
||||
|
||||
# Add handlers
|
||||
application.add_handler(CommandHandler("start", start_command))
|
||||
application.add_handler(CommandHandler("dialectic", dialectic_command))
|
||||
application.add_handler(
|
||||
MessageHandler(filters.TEXT & ~filters.COMMAND, handle_message)
|
||||
)
|
||||
|
||||
# Start the bot
|
||||
logger.info("Starting Telegram bot...")
|
||||
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Your bot needs these environment variables:
|
||||
|
||||
```env
|
||||
# Your Telegram bot token from BotFather
|
||||
BOT_TOKEN=<your-token>
|
||||
|
||||
# AI model to use (see OpenRouter for available models)
|
||||
MODEL_NAME=<your-model>
|
||||
|
||||
# Your OpenRouter API key
|
||||
MODEL_API_KEY=<your-openrouter-api-key>
|
||||
```
|
||||
|
||||
## Chat Types and Behavior
|
||||
|
||||
The bot handles different Telegram chat types intelligently:
|
||||
|
||||
### Private Chats
|
||||
- **Behavior**: Responds to all messages
|
||||
- **Session ID**: Uses the private chat ID
|
||||
- **Memory**: Maintains conversation history per user
|
||||
|
||||
### Group Chats
|
||||
- **Behavior**: Only responds when mentioned or replied to
|
||||
- **Session ID**: Uses the group chat ID (shared across all members)
|
||||
- **Memory**: Maintains group conversation context
|
||||
|
||||
## Recap
|
||||
|
||||
The new Honcho peer/session API makes Telegram bot integration much simpler and more intuitive. Key patterns we learned:
|
||||
|
||||
- **Peer/Session Model**: Users are represented as peers, conversations as sessions
|
||||
- **Chat Type Handling**: Different validation logic for private vs group chats
|
||||
- **Automatic Context Management**: `session.get_context().to_openai()` automatically formats chat history
|
||||
- **Message Storage**: `session.add_messages()` stores both user and assistant messages
|
||||
- **Dialectic Queries**: `peer.chat()` enables querying conversation history
|
||||
- **Command System**: Native Telegram command support with `/start` and `/dialectic`
|
||||
- **Message Splitting**: Automatic handling of Telegram's character limits
|
||||
- **Helper Functions**: Clean code organization with focused helper functions
|
||||
|
||||
This approach provides a clean, maintainable structure for building Telegram bots with conversational memory and context management across both private conversations and group chats.
|
||||
|
|
@ -0,0 +1,296 @@
|
|||
---
|
||||
title: 'Migrating from Mem0'
|
||||
description: 'A guide to migrate from Mem0 to Honcho'
|
||||
icon: 'arrow-right-arrow-left'
|
||||
---
|
||||
|
||||
Interested in transferring your data from Mem0 to Honcho? This guide covers why to switch, how to migrate your data, and differences between the two products.
|
||||
|
||||
|
||||
|
||||
## Why Honcho?
|
||||
Mem0 & Honcho both store your data. Only Honcho reasons about it. [Read more about our approach](https://blog.plasticlabs.ai/blog/Memory-as-Reasoning).
|
||||
|
||||
**Compounding Insights** - Honcho extracts insights that build on each other over time. The more your users interact, the richer and more accurate their profiles become.
|
||||
|
||||
**Superior Performance** - Higher accuracy on memory retrieval benchmarks with faster inference times (more details soon!).
|
||||
|
||||
**Competitive Pricing** - Mem0 charges for retrieval, not ingestion. Meaning you pay to access your own data. Honcho offers straightforward pricing with a generous free tier.
|
||||
|
||||
**Advanced Multi-Peer Sessions** - Honcho offers configurable observation settings (who builds memories about whom), representation-based queries between participants, and first-class peer objects.
|
||||
|
||||
<Note>
|
||||
We would love to support the transfer and cost—just [book a call!](https://cal.com/team/plasticlabs/migration-to-honcho)
|
||||
</Note>
|
||||
|
||||
## Quick Migration
|
||||
|
||||
For the best results, we recommend importing your raw messages directly into Honcho. This gives Honcho the full context to build rich, accurate representations and enables features like session summaries.
|
||||
|
||||
However, if you'd like to get started quickly, you can migrate your existing Mem0 memories directly as **observations**.
|
||||
|
||||
<Info>
|
||||
Get your API key at [app.honcho.dev/api-keys](https://app.honcho.dev/api-keys). New accounts start with $100 credits.
|
||||
</Info>
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# pip install mem0ai honcho-ai
|
||||
from mem0 import MemoryClient
|
||||
from honcho import Honcho
|
||||
|
||||
# Export from Mem0
|
||||
mem0 = MemoryClient(api_key="your-mem0-api-key")
|
||||
memories = mem0.get_all(filters={"user_id": "user123"}, page_size=100)
|
||||
|
||||
# Initialize Honcho
|
||||
honcho = Honcho(api_key="your-honcho-api-key")
|
||||
user = honcho.peer("user123")
|
||||
session = honcho.session("imported")
|
||||
session.add_peers([user])
|
||||
|
||||
# Import memories directly as observations
|
||||
observations = []
|
||||
for memory in memories['results']:
|
||||
content = memory.get("memory") or memory.get("messages", [{}])[0].get("content", "")
|
||||
if content:
|
||||
observations.append({"content": content, "session_id": "imported"})
|
||||
|
||||
# Batch create observations (up to 100 at a time)
|
||||
if observations:
|
||||
user.observations.create(observations)
|
||||
|
||||
print(f"Migrated {len(observations)} memories as observations!")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
// npm install mem0ai @honcho-ai/sdk
|
||||
import MemoryClient from "mem0ai";
|
||||
import { Honcho } from "@honcho-ai/sdk";
|
||||
|
||||
// Export from Mem0
|
||||
const mem0 = new MemoryClient({ apiKey: "your-mem0-api-key" });
|
||||
const memories = await mem0.getAll({ filters: { user_id: "user123" }, page_size: 100 });
|
||||
|
||||
// Initialize Honcho
|
||||
const honcho = new Honcho({ apiKey: "your-honcho-api-key" });
|
||||
const user = await honcho.peer("user123");
|
||||
const session = await honcho.session("imported");
|
||||
await session.addPeers([user]);
|
||||
|
||||
// Import memories directly as observations
|
||||
const observations = memories.results
|
||||
.map(memory => ({
|
||||
content: memory.memory || memory.messages?.[0]?.content || "",
|
||||
session_id: "imported"
|
||||
}))
|
||||
.filter(obs => obs.content);
|
||||
|
||||
// Batch create observations (up to 100 at a time)
|
||||
if (observations.length > 0) {
|
||||
await user.observations.create(observations);
|
||||
}
|
||||
|
||||
console.log(`Migrated ${observations.length} memories as observations!`);
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
That's it! The user's Mem0 memories are now searchable in Honcho as observations. For richer representations with deductive reasoning and session summaries, consider importing your raw messages as described in the [Step-by-Step Migration](#step-by-step-migration) section.
|
||||
|
||||
For more details on replacing Mem0 API calls with Honcho equivalents go to [API Comparison](#api-comparison).
|
||||
|
||||
## Step-by-Step Migration
|
||||
|
||||
Prefer a more detailed walkthrough? Follow these steps:
|
||||
|
||||
### 1. Export User Messages
|
||||
|
||||
Importing raw user messages gives Honcho the full conversational context to build the most accurate representations. We recommend using a data structure that preserves the session and peer structure.
|
||||
|
||||
<Note>
|
||||
If you need any help with this transfer or have any questions, please reach out at hello@plasticlabs.ai or [book a call!](https://cal.com/team/plasticlabs/migration-to-honcho)
|
||||
</Note>
|
||||
|
||||
Alternatively, if you want to import the Mem0 memories, follow the example above and find more info in Mem0's [export API documentation](https://docs.mem0.ai/cookbooks/essentials/exporting-memories).
|
||||
|
||||
### 2. Install the Honcho SDK
|
||||
|
||||
<CodeGroup>
|
||||
```bash Python (uv)
|
||||
uv add honcho-ai
|
||||
```
|
||||
|
||||
```bash Python (pip)
|
||||
pip install honcho-ai
|
||||
```
|
||||
|
||||
```bash TypeScript (npm)
|
||||
npm install @honcho-ai/sdk
|
||||
```
|
||||
|
||||
```bash TypeScript (yarn)
|
||||
yarn add @honcho-ai/sdk
|
||||
```
|
||||
|
||||
```bash TypeScript (pnpm)
|
||||
pnpm add @honcho-ai/sdk
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### 3. Initialize the Honcho Client
|
||||
|
||||
<Info>
|
||||
Get your API key at [app.honcho.dev/api-keys](https://app.honcho.dev/api-keys). New accounts start with $100 credits.
|
||||
</Info>
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
from honcho import Honcho
|
||||
|
||||
honcho = Honcho( api_key="your-api-key" )
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Honcho } from '@honcho-ai/sdk';
|
||||
|
||||
const honcho = new Honcho({apiKey: process.env.HONCHO_API_KEY!});
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### 4. Import Your Data
|
||||
This is a possible implementation using raw user messages. Adapt the data structure to match your exported format.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
# Example data structure (preserving message history with timestamps):
|
||||
exported_data = {
|
||||
"session-1": {
|
||||
"user123": [
|
||||
{"content": "I prefer dark mode", "timestamp": "2024-01-15T10:30:00Z"},
|
||||
{"content": "My name is Alex", "timestamp": "2024-01-15T10:31:00Z"},
|
||||
],
|
||||
"user456": [
|
||||
{"content": "I work in finance", "timestamp": "2024-01-15T11:00:00Z"},
|
||||
{"content": "I like concise responses", "timestamp": "2024-01-15T11:02:00Z"},
|
||||
],
|
||||
},
|
||||
"session-2": {
|
||||
"user123": [
|
||||
{"content": "Meeting notes from last week...", "timestamp": "2024-01-16T09:00:00Z"},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
# Import into Honcho
|
||||
for session_name, users in exported_data.items():
|
||||
session = honcho.session(session_name)
|
||||
|
||||
for user_id, messages in users.items():
|
||||
peer = honcho.peer(user_id)
|
||||
session.add_peers([peer])
|
||||
|
||||
# Sort by timestamp to preserve message order
|
||||
sorted_messages = sorted(messages, key=lambda m: m["timestamp"])
|
||||
session.add_messages([peer.message(m["content"]) for m in sorted_messages])
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
// Example data structure (preserving message history with timestamps):
|
||||
interface Message {
|
||||
content: string;
|
||||
timestamp: string;
|
||||
}
|
||||
const exportedData: Record<string, Record<string, Message[]>> = {
|
||||
"session-1": {
|
||||
"user123": [
|
||||
{ content: "I prefer dark mode", timestamp: "2024-01-15T10:30:00Z" },
|
||||
{ content: "My name is Alex", timestamp: "2024-01-15T10:31:00Z" },
|
||||
],
|
||||
"user456": [
|
||||
{ content: "I work in finance", timestamp: "2024-01-15T11:00:00Z" },
|
||||
{ content: "I like concise responses", timestamp: "2024-01-15T11:02:00Z" },
|
||||
],
|
||||
},
|
||||
"session-2": {
|
||||
"user123": [
|
||||
{ content: "Meeting notes from last week...", timestamp: "2024-01-16T09:00:00Z" },
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
// Import into Honcho
|
||||
for (const [sessionName, users] of Object.entries(exportedData)) {
|
||||
const session = await honcho.session(sessionName);
|
||||
|
||||
for (const [userId, messages] of Object.entries(users)) {
|
||||
const peer = await honcho.peer(userId);
|
||||
await session.addPeers([peer]);
|
||||
|
||||
// Sort by timestamp to preserve message order
|
||||
const sortedMessages = messages.sort((a, b) =>
|
||||
new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
||||
);
|
||||
await session.addMessages(sortedMessages.map((m) => peer.message(m.content)));
|
||||
}
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### 5. Update Your Application Code
|
||||
|
||||
Reference the [API Comparison](#api-comparison) to replace your Mem0 API calls with the Honcho equivalents.
|
||||
|
||||
## API Comparison
|
||||
|
||||
### Core Operations
|
||||
|
||||
| Operation | Mem0 | Honcho | Notes |
|
||||
|-----------|------|--------|-------|
|
||||
| **Initialize** | `MemoryClient(api_key=...)` | `Honcho(api_key=...)` | |
|
||||
| **Identity** | `user_id` string param | `peer = honcho.peer("id")` | Peers can be users or AI agents |
|
||||
| **Add messages** | `client.add(messages, user_id=...)` | `session.add_messages([peer.message(...)])` | Session-scoped, triggers reasoning |
|
||||
| **Add observations** | | `peer.observations.create([...])` | Direct observation or "memory" import, no processing |
|
||||
| **Search** | `client.search(query, filters={"user_id": ...})` | `peer.search(query)` or `peer.observations.query(...)` | Scoped to peer or session |
|
||||
| **List all** | `client.get_all(filters={"user_id": ...})` | `session.get_messages()` or `peer.observations.list()` | Messages or observations |
|
||||
| **Update** | `client.update(memory_id, data=...)` | `honcho.update_message(message, metadata=...)` | Metadata updates only |
|
||||
| **Delete** | `client.delete(memory_id)` | `peer.observations.delete(id)` or `session.delete()` | Observation or session-level |
|
||||
|
||||
### Honcho-Only Capabilities
|
||||
|
||||
Mem0 requires manual assembly of context from `search()` results. Honcho's `session.get_context()` returns a ready-to-use `SessionContext` object with built-in token limits, auto-included summaries, and format helpers (`.to_openai()`, `.to_anthropic()`).
|
||||
|
||||
<Card title="Get Context" icon="window-restore" href="../../documentation/core-concepts/features/get-context">
|
||||
Learn more about token-optimized context retrieval
|
||||
</Card>
|
||||
|
||||
|
||||
Mem0's `search()` returns basic vector, semantic, or raw memory matches. Honcho's `peer.chat()` enables your agent to *reason* about what it knows—returning synthesized natural language insights with streaming support and scoped queries.
|
||||
|
||||
<Card title="Dialectic Endpoint" icon="brain" href="../../documentation/core-concepts/features/dialectic-endpoint">
|
||||
Learn more about inference-powered queries
|
||||
</Card>
|
||||
|
||||
Additional features with **no Mem0 equivalent**:
|
||||
|
||||
| Honcho Method | Description | Use Case |
|
||||
|---------------|-------------|----------|
|
||||
| `peer.card()` | Stable biographical facts (name, preferences, background) | User profiles, personalization |
|
||||
| `session.working_rep(peer)` | Cached psychological analysis (mental state, intentions) | Real-time adaptation |
|
||||
| `session.get_summaries()` | Auto-generated short/long session summaries | Conversation continuity |
|
||||
| `SessionPeerConfig` | Configure observation settings (who learns about whom) | Privacy controls, role-based learning |
|
||||
|
||||
## Next Steps
|
||||
|
||||
<CardGroup cols={3}>
|
||||
<Card title="Architecture" icon="rocket" href="../../documentation/core-concepts/architecture">
|
||||
Understand peers and sessions
|
||||
</Card>
|
||||
<Card title="Dialectic API" icon="brain" href="../../documentation/core-concepts/features/dialectic-endpoint">
|
||||
Inference responses
|
||||
</Card>
|
||||
<Card title="Guides" icon="book" href="../../guides/overview">
|
||||
Integration examples
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Questions? Join our [Discord](https://discord.gg/honcho) or open an issue on [GitHub](https://github.com/plastic-labs/honcho/issues).
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2/workspaces/{workspace_id}/observations
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: delete /v2/workspaces/{workspace_id}/observations/{observation_id}
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2/workspaces/{workspace_id}/observations/list
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: post /v2/workspaces/{workspace_id}/observations/query
|
||||
---
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
openapi: get /v2/workspaces/{workspace_id}/peers/{peer_id}/context
|
||||
---
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue