AI agents frequently lose context between sessions—forgetting user preferences, past instructions, and conversation history. The PolarSearch Memory Container solves this by providing long-term and short-term memory management built into PolarDB for MySQL. Agents automatically structure and persist conversation data, then retrieve relevant memories using semantic search to deliver continuous, personalized service.
The PolarSearch Memory Container feature is in canary release. To request access, submit a ticket.
How it works
The Memory Container converts unstructured conversation data into searchable structured memory using a three-tier storage architecture and an automated processing pipeline.
Three-tier storage architecture
| Memory type | Index type | Best for | Trade-offs |
|---|---|---|---|
| Short-term memory (Working Memory) | Inverted index | Fast retrieval of recent turns; keyword-based search within the current session | Not suited for semantic queries or long-term retention across sessions |
| Long-term memory (Long-Term Memory) | Vector index + inverted index | Deep knowledge retrieval across sessions; personalization using semantic search (KNN) | Higher write latency due to LLM fact extraction and embedding generation |
| Memory history (Memory History) | Inverted index | Compliance and traceability; debugging memory changes over time | Read-only; not used in retrieval |
Memory processing flow
When an agent receives input, the Memory Container runs three phases automatically:
Key benefits
| Capability | Traditional approach | PolarSearch solution |
|---|---|---|
| Memory utilization | Less than 30% of historical data is retained | Increases effective information utilization to over 85% through LLM fact extraction and semantic indexing |
| Search efficiency | Keyword matching, accuracy of 60% or less | Hybrid vector and inverted indexing with reranking achieves semantic search accuracy of over 95% |
| Enterprise compliance | Multi-tenant isolation and permission control are complex to implement | Native multi-tenant isolation, role-based access control (RBAC), and operation audit trail |
| System scalability | Single-point storage capped at the terabyte level | Cloud-native distributed storage scales to the petabyte level |
| Development cost | Custom development with long implementation time | Out-of-the-box APIs and SDKs for rapid integration |
Prerequisites
Before you begin, make sure you have:
A PolarSearch search node added to your cluster. See Add a PolarSearch search node.
A search node administrator account. See Create a search node administrator account.
Get started
This guide walks you through the complete setup: configuring your environment, enabling the plugin, registering models, creating a memory container, and storing and verifying your first memory.
Workflow: Configure environment → Enable plugin → Register models → Create memory container → Store and verify memory
Step 1: Configure access credentials
Set the following environment variables before running any commands. This avoids repeating credentials in each request.
| Variable | Description | Example |
|---|---|---|
POLARSEARCH_HOST_PORT | Connection address and port of the PolarSearch node | pc-xxx.polardbsearch.rds.aliyuncs.com:3001 |
USER_PASSWORD | Administrator account for the PolarSearch node | polarsearch_user:your_password |
YOUR_API_KEY | API key for Alibaba Cloud Model Studio | sk-xxxxxxxxxxxxxxxxxxxxxxxx |
Run the following commands in your terminal. Replace the example values with your actual values.
export POLARSEARCH_HOST_PORT="pc-xxx.polardbsearch.rds.aliyuncs.com:3001"
export USER_PASSWORD="polarsearch_user:your_password"
export YOUR_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxx"Step 2: Enable the Memory Container plugin
Run the following command to enable the Memory Container feature.
Command line
curl -XPUT "http://${POLARSEARCH_HOST_PORT}/_cluster/settings" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"persistent": {
"plugins.ml_commons.agentic_memory_enabled": true
}
}'Dashboard
PUT _cluster/settings
{
"persistent": {
"plugins.ml_commons.agentic_memory_enabled": true
}
}Step 3: Register models
The Memory Container requires two models: an embedding model for semantic search and a large language model (LLM) for fact extraction. Register both with PolarSearch before creating a container.
Register an embedding model
The embedding model converts text into vectors for semantic search. This example uses the text-embedding-v4 model from Alibaba Cloud Model Studio.
1. Add the model endpoint to the trusted list.
Command line
curl -XPUT "http://${POLARSEARCH_HOST_PORT}/_cluster/settings" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"persistent": {
"plugins.ml_commons.trusted_connector_endpoints_regex": [
"^https://dashscope.aliyuncs.com/compatible-mode/v1/.*$"
]
}
}'Dashboard
PUT _cluster/settings
{
"persistent": {
"plugins.ml_commons.trusted_connector_endpoints_regex": [
"^https://dashscope.aliyuncs.com/compatible-mode/v1/.*$"
]
}
}2. Create a model connector.
Thepre_process_functionandpost_process_functionparameters adapt request and response formats for different model services. This example uses the built-inopenai.embeddingformat converter, which matches the format of Alibaba Cloud Model Studio in compatible mode.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/connectors/_create" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"name": "qwen embedding connector",
"description": "The connector to qwen embedding model",
"version": 1,
"protocol": "http",
"parameters": {
"model": "text-embedding-v4",
"endpoint": "dashscope.aliyuncs.com/compatible-mode"
},
"credential": {
"api_key": "${YOUR_API_KEY}"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"headers": {
"Authorization": "Bearer ${credential.api_key}",
"content-type": "application/json"
},
"url": "https://${parameters.endpoint}/v1/embeddings",
"request_body": "{ \"model\": \"${parameters.model}\", \"input\": ${parameters.input} }",
"pre_process_function": "connector.pre_process.openai.embedding",
"post_process_function": "connector.post_process.openai.embedding"
}
]
}'Dashboard
Replace <YOUR_API_KEY> with your actual API key for Alibaba Cloud Model Studio.
POST _plugins/_ml/connectors/_create
{
"name": "qwen embedding connector",
"description": "The connector to qwen embedding model",
"version": 1,
"protocol": "http",
"parameters": {
"model": "text-embedding-v4",
"endpoint": "dashscope.aliyuncs.com/compatible-mode"
},
"credential": {
"api_key": "<YOUR_API_KEY>"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"headers": {
"Authorization": "Bearer ${credential.api_key}",
"content-type": "application/json"
},
"url": "https://${parameters.endpoint}/v1/embeddings",
"request_body": "{ \"model\": \"${parameters.model}\", \"input\": ${parameters.input} }",
"pre_process_function": "connector.pre_process.openai.embedding",
"post_process_function": "connector.post_process.openai.embedding"
}
]
}The response returns a connector_id. Record it for the next step.
{"connector_id": "LBFt6ZsBk04xxx"}3. Register the connector as a model.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/models/_register" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"name": "qwen embedding model",
"function_name": "remote",
"description": "Embedding model for memory",
"connector_id": "LBFt6ZsBk04xxx"
}'Dashboard
POST _plugins/_ml/models/_register
{
"name": "qwen embedding model",
"function_name": "remote",
"description": "Embedding model for memory",
"connector_id": "LBFt6ZsBk04xxx"
}The response returns a model_id. Record it—you will need it when creating the memory container.
{"task_id": "LRFx6ZsBk04ixxx", "status": "CREATED", "model_id": "LhFx6ZsBk04xxx"}When creating a memory container, always use the model_id, not the connector_id. The connector_id points to the external model service. The model_id is the internal ID that PolarSearch assigns after you register the connector.
4. Test the embedding model.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/_predict/text_embedding/<model ID from previous step>" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"text_docs": ["Bob likes swimming. Context: He expressed his interest in swimming."],
"return_number": true,
"target_response": ["sentence_embedding"]
}'Dashboard
POST _plugins/_ml/_predict/text_embedding/<model ID from previous step>
{
"text_docs": ["Bob likes swimming. Context: He expressed his interest in swimming."],
"return_number": true,
"target_response": ["sentence_embedding"]
}A successful response returns a 1024-dimensional vector in the sentence_embedding field with a status_code of 200.
{
"inference_results": [
{
"output": [
{
"name": "sentence_embedding",
"data_type": "FLOAT32",
"shape": [1024],
"data": [0.019752666354179382, -0.03468115255236626, 0.05591931194067001, ...]
}
],
"status_code": 200
}
]
}Register a text generation model (LLM)
The LLM extracts structured facts from conversations before storing them as long-term memory. This example uses the qwen-plus model.
1. Create a model connector.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/connectors/_create" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"name": "QWen LLM Connector",
"description": "The connector to qwen LLM",
"version": 1,
"protocol": "http",
"parameters": {
"model": "qwen-plus",
"endpoint": "dashscope.aliyuncs.com/compatible-mode"
},
"credential": {
"api_key": "${YOUR_API_KEY}"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"headers": {
"Authorization": "Bearer ${credential.api_key}",
"content-type": "application/json"
},
"url": "https://${parameters.endpoint}/v1/chat/completions",
"request_body": "{ \"model\":\"${parameters.model}\", \"system\": \"${parameters.system_prompt}\", \"messages\": [ { \"role\": \"system\", \"content\": \"${parameters.system_prompt}\" }, { \"role\": \"user\", \"content\": \"${parameters.user_prompt}\" } ], \"response_format\": { \"type\": \"json_object\" } }"
}
]
}'Dashboard
Replace <YOUR_API_KEY> with your actual API key for Alibaba Cloud Model Studio.
POST /_plugins/_ml/connectors/_create
{
"name": "QWen LLM Connector",
"description": "The connector to qwen LLM",
"version": 1,
"protocol": "http",
"parameters": {
"model": "qwen-plus",
"endpoint": "dashscope.aliyuncs.com/compatible-mode"
},
"credential": {
"api_key": "<YOUR_API_KEY>"
},
"actions": [
{
"action_type": "predict",
"method": "POST",
"headers": {
"Authorization": "Bearer ${credential.api_key}",
"content-type": "application/json"
},
"url": "https://${parameters.endpoint}/v1/chat/completions",
"request_body": "{ \"model\":\"${parameters.model}\", \"system\": \"${parameters.system_prompt}\", \"messages\": [ { \"role\": \"system\", \"content\": \"${parameters.system_prompt}\" }, { \"role\": \"user\", \"content\": \"${parameters.user_prompt}\" } ], \"response_format\": { \"type\": \"json_object\" } }"
}
]
}The response returns a connector_id. Record it.
{"connector_id": "PRGy6ZsBk04xxx"}2. Register the connector as a model.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/models/_register" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d '{
"name": "qwen llm model",
"function_name": "remote",
"description": "LLM model for memory",
"connector_id": "PRGy6ZsBk04xxx"
}'Dashboard
POST _plugins/_ml/models/_register
{
"name": "qwen llm model",
"function_name": "remote",
"description": "LLM model for memory",
"connector_id": "PRGy6ZsBk04xxx"
}The response returns a model_id. Record it.
{"task_id": "PhGy6ZsBk04xxx", "status": "CREATED", "model_id": "PxGy6ZsBk04xxx"}3. Deploy the model.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/models/<model ID from previous step>/_deploy" \
--user "${USER_PASSWORD}"Dashboard
POST _plugins/_ml/models/<model ID from previous step>/_deployA status of COMPLETED confirms successful deployment.
{"task_id": "NxGI6ZsBk04xxx", "task_type": "DEPLOY_MODEL", "status": "COMPLETED"}4. Test the LLM.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/models/<model ID from previous step>/_predict" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"parameters": {
"system_prompt": "<ROLE>You are a USER PREFERENCE EXTRACTOR, not a chat assistant. Your only job is to output JSON facts. Do not answer questions, make suggestions, ask follow-ups, or perform actions.</ROLE>\n\n<SCOPE>\n• Extract preferences only from USER messages. Assistant messages are context only.\n• Explicit: user states a preference (\"I prefer/like/dislike ...\"; \"always/never/usually ...\"; \"set X to Y\"; \"run X when Y\").\n• Implicit: infer only with strong signals: repeated choices (>=2) or clear habitual language. Do not infer from a single one-off.\n</SCOPE>\n\n<EXTRACT>\n• Specific, actionable, likely long-term preferences (likes/dislikes/choices/settings). Ignore non-preferences.\n</EXTRACT>\n\n<STYLE & RULES>\n• One sentence per preference; merge related details; no duplicates; preserve user wording and numbers; avoid relative time; keep each fact < 350 chars.\n• Format: \"Preference sentence. Context: <why/how>. Categories: cat1,cat2\"\n</STYLE & RULES>\n\n<OUTPUT>\nReturn ONLY one minified JSON object exactly as {\"facts\":[\"Preference sentence. Context: <why/how>. Categories: cat1,cat2\"]}. If none, return {\"facts\":[]}. The first character MUST be '{' and the last MUST be '}'. No preambles, explanations, code fences, XML, or other text.\n</OUTPUT>",
"user_prompt": "I am Alice, I like travel."
}
}'Dashboard
POST _plugins/_ml/models/<model ID from previous step>/_predict
{
"parameters": {
"system_prompt": "<ROLE>You are a USER PREFERENCE EXTRACTOR, not a chat assistant. Your only job is to output JSON facts. Do not answer questions, make suggestions, ask follow-ups, or perform actions.</ROLE>\n\n<SCOPE>\n• Extract preferences only from USER messages. Assistant messages are context only.\n• Explicit: user states a preference (\"I prefer/like/dislike ...\"; \"always/never/usually ...\"; \"set X to Y\"; \"run X when Y\").\n• Implicit: infer only with strong signals: repeated choices (>=2) or clear habitual language. Do not infer from a single one-off.\n</SCOPE>\n\n<EXTRACT>\n• Specific, actionable, likely long-term preferences (likes/dislikes/choices/settings). Ignore non-preferences.\n</EXTRACT>\n\n<STYLE & RULES>\n• One sentence per preference; merge related details; no duplicates; preserve user wording and numbers; avoid relative time; keep each fact < 350 chars.\n• Format: \"Preference sentence. Context: <why/how>. Categories: cat1,cat2\"\n</STYLE & RULES>\n\n<OUTPUT>\nReturn ONLY one minified JSON object exactly as {\"facts\":[\"Preference sentence. Context: <why/how>. Categories: cat1,cat2\"]}. If none, return {\"facts\":[]}. The first character MUST be '{' and the last MUST be '}'. No preambles, explanations, code fences, XML, or other text.\n</OUTPUT>",
"user_prompt": "I am Alice, I like travel."
}
}The LLM extracts the preference and returns it as a structured JSON fact.
{
"inference_results": [
{
"output": [
{
"name": "response",
"dataAsMap": {
"choices": [
{
"message": {
"role": "assistant",
"content": "{\"facts\":[\"I like travel. Context: Stated preference. Categories: interest\"]}"
},
"finish_reason": "stop",
"index": 0,
"logprobs": null
}
],
"object": "chat.completion",
"usage": {
"prompt_tokens": 325,
"completion_tokens": 17,
"total_tokens": 342,
"prompt_tokens_details": {"cached_tokens": 0}
},
"created": 1769152651,
"system_fingerprint": null,
"model": "qwen-plus",
"id": "chatcmpl-50c6bfc9-xxx-xxx-xxx-1a39cfe080f5"
}
}
],
"status_code": 200
}
]
}Step 5: Store and verify memory
Add a conversation to the memory container and confirm it is stored in both short-term and long-term memory.
1. Store memory.
Send a conversation from a user named Bob. The "infer": true parameter triggers the SEMANTIC strategy—the Memory Container calls the LLM to extract facts before storing them.
If you set "infer": false, the Memory Container stores the raw payload without fact extraction or conflict detection. A later request with "infer": true for the same content creates a new memory entry instead of updating the existing one, which can cause duplicate memories. Keep infer consistent across requests for the same user.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/memory_containers/<memory container ID from previous step>/memories" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"messages": [
{
"role": "user",
"content": [{"text": "I am Bob, I really like swimming.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Cool, nice. Hope you enjoy your life.", "type": "text"}]
}
],
"namespace": {"user_id": "bob"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}'Dashboard
POST _plugins/_ml/memory_containers/<memory_container_id>/memories
{
"messages": [
{
"role": "user",
"content": [{"text": "I am Bob, I really like swimming.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Cool, nice. Hope you enjoy your life.", "type": "text"}]
}
],
"namespace": {"user_id": "bob"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}2. Verify short-term memory.
Query the short-term (working) memory index to view the raw conversation.
Command line
curl -XGET "http://${POLARSEARCH_HOST_PORT}/.plugins-ml-am-<index_prefix from previous step>-memory-working/_search?pretty" \
--user "${USER_PASSWORD}"Dashboard
GET .plugins-ml-am-<index_prefix from previous step>-memory-working/_search?prettyThe response shows the original conversation stored under the bob namespace.
{
"_source": {
"memory_container_id": "QRHF6ZsBk04xxx",
"payload_type": "conversational",
"messages": [
{"role": "user", "content": [{"text": "I am Bob, I really like swimming.", "type": "text"}]},
{"role": "assistant", "content": [{"text": "Cool, nice. Hope you enjoy your life.", "type": "text"}]}
],
"namespace": {"user_id": "bob"}
}
}3. Verify long-term memory.
Query the long-term memory index to confirm the LLM extracted the fact "Bob likes swimming." and the embedding model generated the memory_embedding vector.
Command line
curl -XGET "http://${POLARSEARCH_HOST_PORT}/.plugins-ml-am-<index_prefix from previous step>-memory-long-term/_search?pretty" \
--user "${USER_PASSWORD}"Dashboard
GET .plugins-ml-am-<index_prefix from previous step>-memory-long-term/_search?pretty{
"_source": {
"created_time": 1769155210918,
"memory": "Bob likes swimming.",
"memory_container_id": "QRHF6ZsBk04xxx",
"tags": {"topic": "personal info"},
"last_updated_time": 1769155210918,
"memory_embedding": [0.0195, -0.0387, ...],
"namespace": {"user_id": "bob"}
}
}4. View memory history.
The history index records all operations with timestamps. In this case, it shows two ADD records.
Command line
curl -XGET "http://${POLARSEARCH_HOST_PORT}/.plugins-ml-am-<index_prefix from previous step>-memory-history/_search?pretty" \
--user "${USER_PASSWORD}"Dashboard
GET .plugins-ml-am-<index_prefix from previous step>-memory-history/_search?pretty{
"_source": {
"created_time": 1769155211164,
"memory_id": "TBHe6ZsBk04xxx",
"namespace_size": 1,
"namespace": {"user_id": "bob"},
"action": "ADD",
"memory_container_id": "QRHF6ZsBk04xxx",
"after": {"memory": "Bob likes swimming."},
"tags": {"topic": "personal info"}
}
}You have stored a memory for your AI agent that supports long-term retrieval.
Step 6: (Optional) Update memory
The Memory Container automatically detects conflicting facts and updates existing long-term memory instead of creating duplicates.
1. Store an initial memory.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/memory_containers/<memory container ID from previous step>/memories" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"messages": [
{
"role": "user",
"content": [{"text": "My name is NameA. I am from AreaA. I currently live in AreaB.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Hello, NameA! Nice to meet you.", "type": "text"}]
}
],
"namespace": {"user_id": "NameA"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}'Dashboard
POST _plugins/_ml/memory_containers/<memory_container_id>/memories
{
"messages": [
{
"role": "user",
"content": [{"text": "My name is NameA. I am from AreaA. I currently live in AreaB.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Hello, NameA! Nice to meet you.", "type": "text"}]
}
],
"namespace": {"user_id": "NameA"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}2. Query the long-term memory index.
Command line
curl -XGET "http://${POLARSEARCH_HOST_PORT}/.plugins-ml-am-<index_prefix from previous step>-memory-long-term/_search" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"_source": {"excludes": ["memory_embedding"]},
"query": {"match_all": {}}
}'Dashboard
GET .plugins-ml-am-<index_prefix from previous step>-memory-long-term/_search
{
"_source": {"excludes": ["memory_embedding"]},
"query": {"match_all": {}}
}The LLM extracted two separate facts:
{
"hits": [
{
"_source": {
"created_time": 1769156096335,
"memory": "NameA is from AreaA.",
"last_updated_time": 1769156096335,
"namespace": {"user_id": "NameA"},
"memory_container_id": "QRHF6ZsBk04xxx",
"tags": {"topic": "personal info"}
}
},
{
"_source": {
"created_time": 1769156096335,
"memory": "NameA currently resides in AreaB.",
"last_updated_time": 1769156096335,
"namespace": {"user_id": "NameA"},
"memory_container_id": "QRHF6ZsBk04xxx",
"tags": {"topic": "personal info"}
}
}
]
}3. Store a conflicting memory.
NameA's current city has changed. Send the updated information.
Command line
curl -XPOST "http://${POLARSEARCH_HOST_PORT}/_plugins/_ml/memory_containers/<memory container ID from previous step>/memories" \
--user "${USER_PASSWORD}" \
-H 'Content-Type: application/json' \
-d'{
"messages": [
{
"role": "user",
"content": [{"text": "My name is NameA. I currently live in AreaC.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Hello, NameA! Nice to meet you.", "type": "text"}]
}
],
"namespace": {"user_id": "NameA"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}'Dashboard
POST _plugins/_ml/memory_containers/<memory_container_id>/memories
{
"messages": [
{
"role": "user",
"content": [{"text": "My name is NameA. I currently live in AreaC.", "type": "text"}]
},
{
"role": "assistant",
"content": [{"text": "Hello, NameA! Nice to meet you.", "type": "text"}]
}
],
"namespace": {"user_id": "NameA"},
"tags": {"topic": "personal info"},
"infer": true,
"memory_type": "conversation"
}4. Query the long-term memory index again.
The Memory Router detected the conflict and updated the existing fact. The last_updated_time is newer than created_time, confirming an update rather than a new entry.
{
"hits": [
{
"_source": {
"created_time": 1769156096335,
"memory": "NameA resides in AreaC.",
"last_updated_time": 1769156493970,
"namespace": {"user_id": "NameA"},
"memory_container_id": "QRHF6ZsBk04xxx",
"tags": {"topic": "personal info"}
}
}
]
}Use case: Build a travel memory agent
This section shows how to use the Memory Container API to build a Python agent that remembers user travel preferences and provides personalized recommendations.
Preparations
Install the required Python libraries. Add the following to your requirements.txt file and run pip install -r requirements.txt.
requests
openaiCore functions
All interactions with the Memory Container go through four functions:
| Function | Purpose |
|---|---|
opensearch_request() | Wraps HTTP requests to the PolarSearch API; handles authentication and errors |
add_memory() | Calls the Memory Container's memories API to store new conversation data |
search_memories() | Retrieves memories relevant to a user query from long-term and short-term memory |
generate_response_with_memories() | Sends retrieved memories as context to the LLM to generate personalized replies |
API reference
This guide uses the following APIs. For the full API reference, see the OpenSearch documentation:
Create Memory Container API: Creates and configures a memory container.
Agentic memory APIs: Full CRUD operations for memory create, read, update, and delete.
Billing
Using the PolarSearch Memory Container incurs the following costs:
Compute node fees: PolarSearch nodes incur compute node fees as part of PolarDB.
Model service fees: Calling external models from Alibaba Cloud Model Studio for fact extraction and vectorization incurs API call fees.
Review these costs before using the feature in a production environment.