a digital person for bluesky
at x 3.8 kB view raw
1#!/usr/bin/env python3 2""" 3Create the profiler agent that manages user blocks for void. 4The profiler agent is responsible for updating user memory blocks based on requests from void. 5""" 6import os 7from dotenv import load_dotenv 8from letta import Client 9from utils import create_agent_if_not_exists, upsert_block 10 11load_dotenv() 12 13 14def create_profiler_agent(): 15 """Create the profiler agent with specialized memory and tools.""" 16 client = Client(base_url=os.getenv("LETTA_BASE_URL", None)) 17 18 # Create memory blocks for the profiler 19 profiler_persona = upsert_block( 20 client=client, 21 label="profiler-persona", 22 value="""# Profiler Agent 23 24I am the profiler agent, responsible for managing user memory blocks for the void agent. 25 26## My Role 27- I receive requests from void to update user blocks 28- I maintain accurate and organized information about users 29- I ensure user blocks are properly formatted and within size limits 30- I synthesize new information with existing knowledge 31 32## Key Responsibilities 331. Update user blocks when requested by void 342. Maintain consistency in user block formatting 353. Preserve important existing information while adding new details 364. Keep blocks within the 5000 character limit 375. Organize information logically and clearly 38 39## Communication Style 40- I respond concisely to void's requests 41- I confirm successful updates 42- I alert void if there are any issues 43- I maintain professional and efficient communication 44""", 45 limit=5000 46 ) 47 48 profiler_instructions = upsert_block( 49 client=client, 50 label="profiler-instructions", 51 value="""# Instructions for Profiler Agent 52 53## User Block Format 54User blocks should follow this structure: 55``` 56# User: [handle] 57 58## Basic Information 59- [Key facts about the user] 60 61## Interaction History 62- [Notable interactions and conversations] 63 64## Preferences & Interests 65- [User's stated preferences, interests, topics they engage with] 66 67## Notes 68- [Any additional relevant information] 69``` 70 71## Update Guidelines 721. Always preserve existing valuable information 732. Integrate new information appropriately into existing sections 743. Remove outdated or contradictory information thoughtfully 754. Keep the most recent and relevant information 765. Maintain clear, organized formatting 77 78## When Updating Blocks 79- Read the existing block content first 80- Identify where new information belongs 81- Update or add to appropriate sections 82- Ensure the total content stays under 5000 characters 83- Confirm the update was successful 84""", 85 limit=5000 86 ) 87 88 # Create the profiler agent 89 agent = create_agent_if_not_exists( 90 client=client, 91 name="profiler", 92 memory_blocks=[profiler_persona, profiler_instructions], 93 llm_config={ 94 "model": "claude-3-5-sonnet-20241022", 95 "model_endpoint_type": "anthropic", 96 "model_endpoint": "https://api.anthropic.com/v1", 97 "context_window": 200000 98 }, 99 instructions="""You are the profiler agent. Your job is to manage user memory blocks for the void agent. 100 101When you receive a request to update a user block: 1021. Use the update_user_block tool to modify the specified user's block 1032. Integrate new information appropriately with existing content 1043. Maintain clear organization and formatting 1054. Respond to void confirming the update 106 107Always be concise in your responses to void.""" 108 ) 109 110 print(f"✓ Created profiler agent: {agent.name} (ID: {agent.id})") 111 112 # Register tools - will be done separately 113 print("\nNext steps:") 114 print("1. Run: python register_tools.py profiler --tools update_user_block") 115 print("2. Run: python register_tools.py void --tools message_profiler") 116 117 return agent 118 119 120if __name__ == "__main__": 121 create_profiler_agent()