Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anthropic[minor]: Implement actual anthropic tool call streaming #6056

Merged
merged 18 commits into from
Jul 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tool call type field
  • Loading branch information
bracesproul committed Jul 15, 2024
commit 854c7ffb7242ca328e68f28e576be6261d206bb6
3 changes: 3 additions & 0 deletions libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
@@ -570,6 +570,7 @@ function extractToolCallChunk(
id: toolUseChunks.id,
name: toolUseChunks.name,
index: toolUseChunks.index,
type: "tool_call_chunk",
};
}

@@ -586,11 +587,13 @@ function extractToolCallChunk(
newToolCallChunk = {
args: inputJsonDeltaChunks.input,
index: inputJsonDeltaChunks.index,
type: "tool_call_chunk",
};
} else {
newToolCallChunk = {
args: JSON.stringify(inputJsonDeltaChunks.input, null, 2),
index: inputJsonDeltaChunks.index,
type: "tool_call_chunk",
};
}
}
7 changes: 6 additions & 1 deletion libs/langchain-anthropic/src/output_parsers.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,12 @@ export function extractToolCalls(content: Record<string, any>[]) {
const toolCalls: ToolCall[] = [];
for (const block of content) {
if (block.type === "tool_use") {
toolCalls.push({ name: block.name, args: block.input, id: block.id });
toolCalls.push({
name: block.name,
args: block.input,
id: block.id,
type: "tool_call",
});
}
}
return toolCalls;
Loading