diff options
| author | Dhravya Shah <[email protected]> | 2025-09-18 20:34:18 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-09-18 21:03:49 -0700 |
| commit | 1fcb56908920da386900abb4ce2383374a625c72 (patch) | |
| tree | 0f9d7f695d4c9b1b85be3950fc869e0061dff3ed /packages/tools/src/ai-sdk.ts | |
| parent | refetching logic change (diff) | |
| download | supermemory-09-18-formatting.tar.xz supermemory-09-18-formatting.zip | |
formatting09-18-formatting
Diffstat (limited to 'packages/tools/src/ai-sdk.ts')
| -rw-r--r-- | packages/tools/src/ai-sdk.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/packages/tools/src/ai-sdk.ts b/packages/tools/src/ai-sdk.ts index 703175e7..37f346c2 100644 --- a/packages/tools/src/ai-sdk.ts +++ b/packages/tools/src/ai-sdk.ts @@ -1,13 +1,13 @@ -import Supermemory from "supermemory" -import { tool } from "ai" -import { z } from "zod" +import { tool } from "ai"; +import Supermemory from "supermemory"; +import { z } from "zod"; import { DEFAULT_VALUES, + getContainerTags, PARAMETER_DESCRIPTIONS, TOOL_DESCRIPTIONS, - getContainerTags, -} from "./shared" -import type { SupermemoryToolsConfig } from "./types" +} from "./shared"; +import type { SupermemoryToolsConfig } from "./types"; // Export individual tool creators export const searchMemoriesTool = ( @@ -17,9 +17,9 @@ export const searchMemoriesTool = ( const client = new Supermemory({ apiKey, ...(config?.baseUrl ? { baseURL: config.baseUrl } : {}), - }) + }); - const containerTags = getContainerTags(config) + const containerTags = getContainerTags(config); return tool({ description: TOOL_DESCRIPTIONS.searchMemories, @@ -50,22 +50,22 @@ export const searchMemoriesTool = ( limit, chunkThreshold: DEFAULT_VALUES.chunkThreshold, includeFullDocs, - }) + }); return { success: true, results: response.results, count: response.results?.length || 0, - } + }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "Unknown error", - } + }; } }, - }) -} + }); +}; export const addMemoryTool = ( apiKey: string, @@ -74,9 +74,9 @@ export const addMemoryTool = ( const client = new Supermemory({ apiKey, ...(config?.baseUrl ? { baseURL: config.baseUrl } : {}), - }) + }); - const containerTags = getContainerTags(config) + const containerTags = getContainerTags(config); return tool({ description: TOOL_DESCRIPTIONS.addMemory, @@ -85,27 +85,27 @@ export const addMemoryTool = ( }), execute: async ({ memory }) => { try { - const metadata: Record<string, string | number | boolean> = {} + const metadata: Record<string, string | number | boolean> = {}; const response = await client.memories.add({ content: memory, containerTags, ...(Object.keys(metadata).length > 0 && { metadata }), - }) + }); return { success: true, memory: response, - } + }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "Unknown error", - } + }; } }, - }) -} + }); +}; /** * Create Supermemory tools for AI SDK @@ -117,5 +117,5 @@ export function supermemoryTools( return { searchMemories: searchMemoriesTool(apiKey, config), addMemory: addMemoryTool(apiKey, config), - } + }; } |