Mpalo API Tutorials
Learn by doing! These tutorials provide step-by-step guidance on integrating Mpalo's Palo AI memory into various applications. Follow along to see how you can leverage episodic memory in your projects.
Tutorial: Adding Episodic Memory to a Chatbot
Enhance your chatbot's conversational ability by enabling it to remember past interactions using the Mpalo API and a Palo engine.
Step 1: Prerequisites
Ensure you have:
- Completed the API Quickstart.
- A basic chatbot framework (e.g., using Python with Flask/FastAPI, or Node.js with Express).
- Your Mpalo API Key.
Step 2: Choose a Palo Engine
Select an appropriate engine based on your needs. For basic chat memory, palo-lite
or palo
are good starting points. Note the API name.
See Engines Overview for details.
Step 3: Modify Chatbot Logic
In your chatbot's request handling function:
- Retrieve the incoming user message.
- Identify the unique conversation (e.g., by user ID or session ID). This will serve as your
memory_id
. - Construct the message history, including past user and assistant messages for this conversation.
- Include the current user message in the history.
Step 4: Call the Mpalo API
Make a POST request to the Mpalo chat completions endpoint (e.g., /v1/chat/completions
), sending:
{
"model": " palo", // Your chosen engine
"messages": [
// Your constructed message history array...
{"role": "user", "content": "What was the topic we discussed earlier?"}
],
"memory_id": "unique_conversation_id_123" // Unique ID for this conversation
}
Include your API key in the Authorization: Bearer YOUR_API_KEY
header.
Step 5: Process and Display Response
Parse the JSON response from the Mpalo API. Extract the assistant's reply from the choices[0].message.content
field.
Display this reply to the user in your chatbot interface.
Append both the user's last message and the assistant's reply to your stored conversation history for the next turn.
Step 6: Test
Have a conversation with your chatbot. Mention specific details (e.g., "My dog's name is Fido"). Later, ask about that detail ("What is my dog's name?"). The chatbot should now be able to recall it using the Palo memory engine.
Tutorial: Contextual Awareness for Robotics
Enable a robot to remember objects, locations, or past tasks using Mpalo AI memory for more context-aware behavior. (Conceptual Example)
Step 1: Setup
Assume a robot operating system (e.g., ROS) with sensor integration (camera, LIDAR) and access to the Mpalo API (via Python script, etc.). Obtain your API key.
Step 2: Identify Memory Needs
Decide what the robot needs to remember: object locations ("Cup is on the kitchen table"), task status ("Task 'deliver package' completed at 10:00 AM"), user preferences ("User prefers coffee").
Step 3: Structure Memory Inputs
Convert robot observations and actions into structured messages suitable for the API. Use a consistent memory_id
for the robot or specific operational context.
// Example: Robot observes an object
{
"role": "system", // Or a custom role like 'observation'
"content": "Observed object 'red_cup' at coordinates [1.5, 2.0, 0.8] in frame 'kitchen_map'."
}
// Example: Robot completes a task
{
"role": "system",
"content": "Completed task 'fetch_water'. Current location: 'kitchen'."
}
Step 4: Store Memories
Periodically, or after significant events, send these structured messages to the Mpalo API using a suitable Palo engine (e.g., palo-large
for richer context) and the robot's memory_id
.
# Conceptual API call
curl -X POST ... -d '{
"model": "palo-large",
"messages": [ /* Array containing observation/action messages */ ],
"memory_id": "robot_alpha_memory"
}'
Note: You might only send updates, or potentially send a summary query to store the new info within a retrieved context.
Step 5: Query Memory for Context
When the robot needs context (e.g., "Where is the red cup?", "What was my last task?"), formulate a query message:
{ "role": "user", "content": "Query: Location of 'red_cup'?" }
Send this query along with relevant recent history (if any) to the API, using the same memory_id
.
Step 6: Use Retrieved Information
Parse the API response. The assistant's reply should contain the relevant remembered information. Use this information to guide the robot's planning and actions (e.g., navigate to the remembered cup location).
Tutorial: Using the Browser Extension for Enhanced Chat
Leverage Mpalo's AI memory directly within your favorite web-based chatbots using the Mpalo Browser Extension.
Step 1: Installation & Setup
Follow the detailed steps in the Browser Extension Setup Guide to install the extension and link it to your Mpalo account using your API key.
Step 2: Activate on a Chatbot Site
Navigate to a supported chatbot website (e.g., ChatGPT, Claude). The Mpalo extension icon should indicate activation, or you may need to click it to enable it for the site.
Configure the desired Palo engine (e.g., Lite, Palo) and memory settings within the extension's popup options.
Step 3: Initiate Conversation
Start chatting with the website's chatbot as you normally would. The extension works in the background.
Step 4: Automatic Memory Integration
As you converse, the Mpalo extension intercepts messages (your input and the bot's replies) and sends them to the selected Palo engine with a unique memory context for that chat session.
When you ask follow-up questions that rely on previous parts of the conversation, the extension uses the stored memory context via the Mpalo API to help the underlying chatbot provide more relevant and informed responses.
Example:
- You tell the chatbot via the extension-enabled interface: "My project deadline is next Friday."
- Later, you ask: "When is my deadline again?"
- The extension leverages Palo's memory of the first statement to help the chatbot answer correctly: "You mentioned your project deadline is next Friday."
Step 5: Manage Memory (Optional)
Use the extension's options (if available) to potentially clear the memory for the current session or adjust personalization/forgetting settings based on the chosen Palo engine's capabilities.
Next Steps
You've learned the basics! Now you can:
- Explore advanced features like multi-modal memory (vision, image generation) with engines like
palo-large
orpalo-deep
. - Experiment with different Memory Templates for specific use cases.
- Consult the full API Documentation for detailed endpoint information.
- Build more complex applications combining AI memory with other services.