Skip to main content

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() returns Token

Interaction Management

  • publish_interaction() returns PublishUserInteractionResponse
  • search_interactions() returns SearchInteractionResponse
  • get_interactions() returns GetInteractionsResponse
  • delete_interaction() returns DeleteUserInteractionResponse

Profile Management

  • search_profiles() returns SearchUserProfileResponse
  • get_profiles() returns GetUserProfilesResponse
  • delete_profile() returns DeleteUserProfileResponse
  • get_profile_change_log() returns ProfileChangeLogResponse

Configuration Management

  • get_config() returns Config
  • set_config() returns dict

Feedback Management

  • get_raw_feedbacks() returns GetRawFeedbacksResponse
  • get_feedbacks() returns GetFeedbacksResponse

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenticmem-0.1.3.7.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenticmem-0.1.3.7-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for agenticmem-0.1.3.7.tar.gz
Algorithm Hash digest
SHA256 9d020d391987eaf8836efe0a08d4371e882b6015ee7a7f18c92a708f836c0a69
MD5 2d9f7959b1b332fb8e42d7aea81dd53a
BLAKE2b-256 589488a29c29d371a94589f5fecb58a2e4789f7ac64345b2a45ec553658a5751

See more details on using hashes here.

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

Hashes for agenticmem-0.1.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 57ee3a7c045b23b64f44bda153d72a50164eb74b37d0dc9c09ec94154f43930e
MD5 61ab8ff4b761592d2605c8e145949911
BLAKE2b-256 82e7c540452dee0349a74fa24f2033522664f9b0c36bd412561eb0fa805ded77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page