mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-07 08:26:15 +00:00
perf: Execute Claude memory tool calls concurrently (#824)
This commit is contained in:
parent
7fd36eaebc
commit
c7b841798f
1 changed files with 27 additions and 25 deletions
|
|
@ -119,25 +119,25 @@ export async function realClaudeMemoryExample() {
|
|||
const toolResults = []
|
||||
|
||||
if (responseData.content) {
|
||||
for (const block of responseData.content) {
|
||||
if (block.type === "tool_use" && block.name === "memory") {
|
||||
console.log("\\n🔧 Processing memory tool call:")
|
||||
const memoryToolCalls = responseData.content.filter(
|
||||
(block: any): block is { type: 'tool_use'; id: string; name: 'memory'; input: { command: MemoryCommand; path: string } } =>
|
||||
block.type === "tool_use" && block.name === "memory",
|
||||
)
|
||||
|
||||
const results = await Promise.all(
|
||||
memoryToolCalls.map((block: any) => {
|
||||
console.log("\n🔧 Processing memory tool call:")
|
||||
console.log(`Command: ${block.input.command}`)
|
||||
console.log(`Path: ${block.input.path}`)
|
||||
|
||||
// Handle the memory tool call
|
||||
const toolResult = await handleClaudeMemoryToolCall(
|
||||
block,
|
||||
SUPERMEMORY_API_KEY,
|
||||
{
|
||||
projectId: "python-scraper-help",
|
||||
memoryContainerTag: "claude_memory_debug",
|
||||
},
|
||||
)
|
||||
return handleClaudeMemoryToolCall(block, SUPERMEMORY_API_KEY, {
|
||||
projectId: "python-scraper-help",
|
||||
memoryContainerTag: "claude_memory_debug",
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
toolResults.push(toolResult)
|
||||
}
|
||||
}
|
||||
toolResults.push(...results)
|
||||
}
|
||||
|
||||
// Step 3: Send tool results back to Claude if there were any
|
||||
|
|
@ -196,16 +196,18 @@ export async function processClaudeResponse(
|
|||
const toolResults = []
|
||||
|
||||
if (claudeResponseData.content) {
|
||||
for (const block of claudeResponseData.content) {
|
||||
if (block.type === "tool_use" && block.name === "memory") {
|
||||
const toolResult = await handleClaudeMemoryToolCall(
|
||||
block,
|
||||
supermemoryApiKey,
|
||||
config,
|
||||
)
|
||||
toolResults.push(toolResult)
|
||||
}
|
||||
}
|
||||
const memoryToolCalls = claudeResponseData.content.filter(
|
||||
(block: any): block is { type: 'tool_use'; id: string; name: 'memory'; input: { command: MemoryCommand; path: string } } =>
|
||||
block.type === "tool_use" && block.name === "memory",
|
||||
)
|
||||
|
||||
const results = await Promise.all(
|
||||
memoryToolCalls.map((block: any) =>
|
||||
handleClaudeMemoryToolCall(block, supermemoryApiKey, config),
|
||||
),
|
||||
)
|
||||
|
||||
toolResults.push(...results)
|
||||
}
|
||||
|
||||
return toolResults
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue