A Python client for the AgenticMem API
Project description
AgenticMem Python Client
A Python client library for interacting with the AgenticMem API. This client provides easy-to-use interfaces for managing user interactions, profiles, configuration, and agent feedback.
Installation
pip install agenticmem
Quick Start
import agenticmem
from agenticmem import (
InteractionRequest,
SearchUserProfileRequest,
SearchInteractionRequest,
UserActionType
)
from datetime import datetime
# Initialize the client
client = agenticmem.AgenticMemClient(url_endpoint="http://127.0.0.1:8081/")
# Login with email/password (async)
token = await client.login("user@example.com", "password")
client.api_key = token.api_key
# Publish a user interaction (async)
response = await client.publish_interaction(
request_id="your_request_id",
user_id="your_user_id",
interaction_requests=[
InteractionRequest(
role="User",
content="Hey, this is John. How can I help you today?",
user_action=UserActionType.NONE,
user_action_description="",
interacted_image_url=""
)
],
source="conversation"
)
print(f"Published interaction: {response.success} - {response.message}")
# Search user profiles (async)
profiles = await client.search_profiles(
request=SearchUserProfileRequest(
user_id="your_user_id",
query="john",
threshold=0.7
)
)
for profile in profiles.user_profiles:
print(f"Profile {profile.profile_id}: {profile.profile_content}")
# Search interactions (async)
interactions = await client.search_interactions(
request=SearchInteractionRequest(
user_id="your_user_id",
query="name is john"
)
)
for interaction in interactions.interactions:
print(f"Interaction {interaction.interaction_id}: {interaction.content}")
# Get all interactions (async)
all_interactions = await client.get_interactions(
request={"user_id": "your_user_id", "top_k": 10}
)
for interaction in all_interactions.interactions:
print(f"Interaction: {interaction.content}")
# Get all profiles (async)
all_profiles = await client.get_profiles(
request={"user_id": "your_user_id", "top_k": 10}
)
for profile in all_profiles.user_profiles:
print(f"Profile: {profile.profile_content}")
# Get profile change log (async)
change_log = await client.get_profile_change_log()
print(f"Profile changes: {len(change_log.profile_change_logs)} logs")
Features
Authentication
- Email/password login (async)
- API key authentication
- Custom endpoint configuration
User Interaction Management
- Publish user interactions (text, images, actions)
- Search interactions with semantic queries
- Get direct list of interactions
- Delete specific interactions
- Support for various interaction types (text, visual, click events)
User Profile Management
- Search user profiles with semantic queries
- Get direct list of user profiles
- Delete specific profiles or profiles matching search queries
- View profile change log history
- Filter by source and custom features
Configuration Management
- Get and set AgenticMem configuration
- Configure profile extractors
- Configure agent feedback systems
- Storage configuration (Supabase, S3, Local)
Agent Feedback System
- Get raw feedbacks from user interactions
- Get aggregated feedbacks
- Automatic feedback generation based on conversations
- Configurable feedback thresholds
API Response Types
All API methods return strongly-typed responses:
Authentication
login()returnsToken
Interaction Management
publish_interaction()returnsPublishUserInteractionResponsesearch_interactions()returnsSearchInteractionResponseget_interactions()returnsGetInteractionsResponsedelete_interaction()returnsDeleteUserInteractionResponse
Profile Management
search_profiles()returnsSearchUserProfileResponseget_profiles()returnsGetUserProfilesResponsedelete_profile()returnsDeleteUserProfileResponseget_profile_change_log()returnsProfileChangeLogResponse
Configuration Management
get_config()returnsConfigset_config()returnsdict
Feedback Management
get_raw_feedbacks()returnsGetRawFeedbacksResponseget_feedbacks()returnsGetFeedbacksResponse
Advanced Usage Examples
Visual Interactions with Images
import base64
# Function to encode the image
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")
# Publish image interaction
base64_image = encode_image("./path/to/image.png")
await client.publish_interaction(
request_id="your_request_id",
user_id="your_user_id",
interaction_requests=[
InteractionRequest(
content="I like this",
image_encoding=base64_image,
)
]
)
Configuration Management
from agenticmem import ProfileExtractorConfig, AgentFeedbackConfig, FeedbackAggregatorConfig
# Get current configuration
config = await client.get_config()
print(f"Current config: {config}")
# Update configuration
feedback_config = AgentFeedbackConfig(
feedback_name="sales_feedback",
feedback_definition_prompt="Extract actionable feedback for sales representatives",
feedback_aggregator_config=FeedbackAggregatorConfig()
)
config.agent_feedback_configs = [feedback_config]
await client.set_config(config)
Feedback Management
# Get raw feedbacks
raw_feedbacks = await client.get_raw_feedbacks()
for feedback in raw_feedbacks.raw_feedbacks:
print(f"Feedback: {feedback.feedback_content}")
# Get aggregated feedbacks
feedbacks = await client.get_feedbacks()
for feedback in feedbacks.feedbacks:
print(f"Aggregated feedback: {feedback}")
Documentation
For detailed documentation, please visit the docs/ directory in this repository.
Important Notes
- All client methods are async and require
await - Image interactions support base64 encoded images
- The client supports flexible request types (dict or typed objects)
- Configuration changes affect the entire organization
- Feedback generation is automatic based on configured prompts
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agenticmem-0.1.3.7.tar.gz.
File metadata
- Download URL: agenticmem-0.1.3.7.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.11 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d020d391987eaf8836efe0a08d4371e882b6015ee7a7f18c92a708f836c0a69
|
|
| MD5 |
2d9f7959b1b332fb8e42d7aea81dd53a
|
|
| BLAKE2b-256 |
589488a29c29d371a94589f5fecb58a2e4789f7ac64345b2a45ec553658a5751
|
File details
Details for the file agenticmem-0.1.3.7-py3-none-any.whl.
File metadata
- Download URL: agenticmem-0.1.3.7-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.11 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57ee3a7c045b23b64f44bda153d72a50164eb74b37d0dc9c09ec94154f43930e
|
|
| MD5 |
61ab8ff4b761592d2605c8e145949911
|
|
| BLAKE2b-256 |
82e7c540452dee0349a74fa24f2033522664f9b0c36bd412561eb0fa805ded77
|