d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import {
|
|
ADD_MEMORY_OUTPUT_PROPERTIES,
|
|
type Mem0AddMemoriesParams,
|
|
type Mem0AddMemoriesResponse,
|
|
} from '@/tools/mem0/types'
|
|
import { parseMem0Messages } from '@/tools/mem0/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
/**
|
|
* Add Memories Tool
|
|
* @see https://docs.mem0.ai/api-reference/memory/add-memories
|
|
*/
|
|
export const mem0AddMemoriesTool: ToolConfig<Mem0AddMemoriesParams, Mem0AddMemoriesResponse> = {
|
|
id: 'mem0_add_memories',
|
|
name: 'Add Memories',
|
|
description: 'Add memories to Mem0 for persistent storage and retrieval',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
userId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'User ID associated with the memory (e.g., "user_123", "alice@example.com")',
|
|
},
|
|
messages: {
|
|
type: 'json',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Array of message objects with role and content (e.g., [{"role": "user", "content": "Hello"}])',
|
|
},
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Your Mem0 API key',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: 'https://api.mem0.ai/v3/memories/add/',
|
|
method: 'POST',
|
|
headers: (params) => ({
|
|
Authorization: `Token ${params.apiKey}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params) => {
|
|
const messages = parseMem0Messages(params.messages)
|
|
return {
|
|
messages,
|
|
user_id: params.userId.trim(),
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response): Promise<Mem0AddMemoriesResponse> => {
|
|
const data = await response.json()
|
|
return {
|
|
success: true,
|
|
output: {
|
|
message: data.message ?? '',
|
|
status: data.status ?? '',
|
|
event_id: data.event_id ?? '',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
message: ADD_MEMORY_OUTPUT_PROPERTIES.message,
|
|
status: ADD_MEMORY_OUTPUT_PROPERTIES.status,
|
|
event_id: ADD_MEMORY_OUTPUT_PROPERTIES.event_id,
|
|
},
|
|
}
|