Python SDK
Give your AI agent persistent memory. Simple Python SDK for natural language ingestion and querying.
Installation
pip install antonlyticsQuick Start
from antonlytics import Agent
# Initialize agent
agent = Agent(
api_key="your-api-key",
project_id="your-project-id"
)
# Ingest data - agent learns
agent.ingest("""
Had a call with Sarah Johnson from TechCorp today.
She's interested in our Enterprise plan for 50 users.
Follow up next Tuesday to discuss pricing.
""")
# Chat with agent - agent remembers
response = agent.chat("Who should I follow up with?")
print(response["response"])
# => "You should follow up with Sarah Johnson from TechCorp.
# She expressed strong interest in the Enterprise plan..."
# Access relevant entities
for entity in response["relevant_entities"]:
print(f"{entity['name']} - {entity['type']}")Two Usage Options
Option 1: Use Our Model
We handle everything. System prompt + memory + AI response.
# Full-service
response = agent.chat(
"Who to follow up?"
)
print(response["response"])Option 2: Use Your Model
Get memory context. Feed to your own model.
# Just memory
memory = agent.get_memory()
# Your model
your_model.chat(
context=memory,
message="Who to follow up?"
)Core Methods
agent.ingest(text)
Ingest natural language text. Automatically extracts entities and relationships.
# Ingest meeting notes
result = agent.ingest("""
Meeting with Alice Johnson from DataCorp.
She's the CTO and wants Pro plan for 20 engineers.
Budget approved for Q2. Integrate with Slack required.
""")
print(result["created"])
# => {"entities": 3, "relationships": 2}
print(result["extracted"]["entities"])
# => [
# {"name": "Alice Johnson", "type": "Person"},
# {"name": "DataCorp", "type": "Company"},
# ...
# ]agent.chat(message)
Chat with your agent. Uses system prompt + full memory context.
# Ask questions
response = agent.chat("What deals are in progress?")
print(response["response"])
# Access entities mentioned
for entity in response["relevant_entities"]:
print(entity["name"], entity["properties"])agent.get_memory(query=None)
Get structured memory for your own model. Returns entities and relationships.
# Get all memory
memory = agent.get_memory()
# Get filtered memory
memory = agent.get_memory("Enterprise deals")
# Use with your model
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a sales assistant"},
{"role": "system", "content": f"Memory: {memory}"},
{"role": "user", "content": "Who to follow up?"}
]
)
print(response.choices[0].message.content)agent.set_system_prompt(prompt)
Configure agent behavior and personality.
agent.set_system_prompt("""
You are a helpful sales assistant.
Your role is to:
- Track leads and their interests
- Identify follow-up opportunities
- Provide context on past conversations
- Suggest next steps for deals
Be professional, concise, and action-oriented.
""")Complete Example
from antonlytics import Agent
# Initialize
agent = Agent(
api_key="your-api-key",
project_id="your-project-id"
)
# Set behavior
agent.set_system_prompt("""
You are a sales assistant.
Focus on follow-ups and next steps.
""")
# Ingest conversation
agent.ingest("""
Call with Mike Rodriguez from StartupXYZ.
He's the founder. Looking at our API for their mobile app.
Has 100K users. Wants custom pricing.
Send proposal by Friday.
""")
agent.ingest("""
Email from Sarah Chen at BigCorp.
VP of Engineering. Interested in Enterprise.
Team of 200 developers. Budget discussion next week.
""")
# Query memory
response = agent.chat("What are my top priorities this week?")
print(response["response"])
# => "Your top priorities:
# 1. Send proposal to Mike at StartupXYZ by Friday
# 2. Prepare for budget discussion with Sarah at BigCorp next week"
# Get all contacts
response = agent.chat("List all people I've talked to")
for entity in response["relevant_entities"]:
if entity["type"] == "Person":
print(f"- {entity['name']}")
# => - Mike Rodriguez
# - Sarah ChenUsing Your Own Model
You can use Antonlytics just for memory and bring your own model:
from antonlytics import Agent
from your_model import YourAgent
# Antonlytics for memory
memory_agent = Agent(api_key="...", project_id="...")
# Ingest data
memory_agent.ingest("Call with Sarah from TechCorp...")
# Get memory context
memory = memory_agent.get_memory()
# Your agent with memory
your_agent = YourAgent()
response = your_agent.query(
context=memory,
prompt="Who should I follow up with?"
)
print(response)
# Your model has access to structured memory!API Reference
| Method | Description |
|---|---|
| ingest(text) | Extract and store entities/relationships |
| chat(message) | Chat with agent (uses our model) |
| get_memory(query?) | Get memory context for your model |
| set_system_prompt(prompt) | Configure agent behavior |
| get_system_prompt() | Get current system prompt |