Skip to content

Commit 1c35a00

Browse files
committed
Merge branch 'main' of github.com:tinyhumansai/neocortex
2 parents eaeac8d + 5cf8d74 commit 1c35a00

95 files changed

Lines changed: 27371 additions & 2 deletions

File tree

Some content is hidden

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

.github/workflows/publish-python-sdk.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
environment: Production
1414
permissions:
1515
id-token: write
16+
defaults:
17+
run:
18+
working-directory: packages/sdk-python
1619
steps:
1720
- uses: actions/checkout@v4
1821

@@ -25,6 +28,7 @@ jobs:
2528
run: uv build
2629

2730
- name: Publish to PyPI
31+
working-directory: packages/sdk-python
2832
uses: pypa/gh-action-pypi-publish@release/v1
2933
with:
3034
password: ${{ secrets.PYPI_API_TOKEN }}

packages/plugin-agno/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Neocortex Agno Plugin
2+
3+
Agno plugin for **Neocortex-powered memories** in Agno agents. Gives your agents persistent memory (save, recall, delete) via the Neocortex/TinyHumans API, with credentials kept out of tool parameters.
4+
5+
## Requirements
6+
7+
- Python 3.9+
8+
- [Agno](https://pypi.org/project/agno/) ≥ 2.0
9+
- [httpx](https://www.python-httpx.org/) (brought in as a dependency) for talking to the Alphahuman backend.
10+
11+
## Install
12+
13+
```bash
14+
pip install neocortex-agno
15+
```
16+
17+
Or from the repo:
18+
19+
```bash
20+
pip install -e ./neocortex/packages/plugin-agno
21+
```
22+
23+
## Quick start
24+
25+
```python
26+
from agno.agent import Agent
27+
from agno.models.openai import OpenAIResponses
28+
from neocortex_agno import NeocortexTools
29+
30+
agent = Agent(
31+
model=OpenAIResponses(id="gpt-4o-mini"),
32+
tools=[NeocortexTools(token="YOUR_ALPHAHUMAN_API_KEY")],
33+
instructions="Use the memory tools to remember and recall user preferences and context.",
34+
markdown=True,
35+
)
36+
37+
# Agent can now save and recall memories
38+
agent.print_response("Remember that I prefer dark mode and my name is Alex.", stream=True)
39+
agent.print_response("What theme do I prefer?", stream=True)
40+
```
41+
42+
## Available tools
43+
44+
The `NeocortexTools` toolkit exposes three tools to the agent:
45+
46+
47+
| Tool | Description |
48+
| --------------- | --------------------------------------------------------------------- |
49+
| `save_memory` | Save or update a memory (key, content, namespace, optional metadata). |
50+
| `recall_memory` | Recall relevant memories for a natural-language query in a namespace. |
51+
| `delete_memory` | Delete one or more memories by key/keys or delete all in a namespace. |
52+
53+
54+
Credentials (`token`, `model_id`, `base_url`) are set when constructing `NeocortexTools` and are **never** passed as tool arguments, so the LLM cannot see or override them.
55+
56+
## Configuration
57+
58+
- **token** (required): Alphahuman / Neocortex memory API token (e.g. `ALPHAHUMAN_API_KEY`).
59+
- **base_url** (optional): Alphahuman API base URL. If omitted, uses the `ALPHAHUMAN_BASE_URL` env var or the default `https://staging-api.alphahuman.xyz`.
60+
61+
## Error handling
62+
63+
On API failures, the underlying client raises `TinyHumanError`. You can catch it for logging or user-facing messages:
64+
65+
```python
66+
from neocortex_agno import NeocortexTools, AlphahumanError
67+
68+
try:
69+
agent.print_response("Remember that I like Python.", stream=True)
70+
except AlphahumanError as e:
71+
print(f"Memory API error: {e} (status={e.status})")
72+
```
73+
74+
## Example
75+
76+
An example script is included. Set `ALPHAHUMAN_API_KEY`, `ALPHAHUMAN_BASE_URL`, and `OPENAI_API_KEY`, then:
77+
78+
```bash
79+
python example.py
80+
```
81+

packages/plugin-agno/example.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Example: Agno agent with Neocortex (Alphahuman) memory tools.
2+
3+
Run with:
4+
export ALPHAHUMAN_API_KEY=""
5+
export ALPHAHUMAN_BASE_URL=""
6+
export OPENAI_API_KEY=""
7+
python example.py
8+
"""
9+
10+
import os
11+
12+
from agno.agent import Agent
13+
from agno.models.openai import OpenAIResponses
14+
from neocortex_agno import NeocortexTools
15+
16+
17+
def main() -> None:
18+
token = os.environ.get("ALPHAHUMAN_API_KEY")
19+
if not token:
20+
print("Set ALPHAHUMAN_API_KEY to run this example.")
21+
return
22+
23+
agent = Agent(
24+
model=OpenAIResponses(id="gpt-4o-mini"),
25+
tools=[
26+
NeocortexTools(
27+
token=token,
28+
base_url=os.environ.get("ALPHAHUMAN_BASE_URL"),
29+
)
30+
],
31+
instructions=(
32+
"Use the memory tools to remember and recall user preferences and context. "
33+
"When the user tells you something to remember, use save_memory. "
34+
"When answering questions that might use stored context, use recall_memory first."
35+
),
36+
markdown=True,
37+
)
38+
39+
print("Agent with Neocortex memory ready. Try:")
40+
print(' agent.print_response("Remember that I prefer dark mode.", stream=True)')
41+
print(' agent.print_response("What theme do I prefer?", stream=True)')
42+
print()
43+
44+
agent.print_response(
45+
"Remember that I prefer dark mode and my name is Alex.",
46+
stream=True,
47+
)
48+
agent.print_response("What theme do I prefer?", stream=True)
49+
50+
51+
if __name__ == "__main__":
52+
main()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Neocortex plugin for Agno — Neocortex-powered memories in Agno agents."""
2+
3+
from .tools import NeocortexTools, AlphahumanError
4+
5+
__all__ = ["NeocortexTools", "AlphahumanError"]
6+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)