MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / toAnthropicAssistantContent

Function toAnthropicAssistantContent

src/ifcchat/api_anthropic.js:20–41  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

18}
19
20function toAnthropicAssistantContent(message) {
21 const content = [];
22
23 if (message.content) {
24 content.push({ type: "text", text: message.content });
25 }
26
27 for (const toolCall of message.tool_calls ?? []) {
28 content.push({
29 type: "tool_use",
30 id: toolCall.id,
31 name: toolCall.function.name,
32 input: parseArguments(toolCall.function.arguments),
33 });
34 }
35
36 if (content.length === 0) {
37 return "";
38 }
39
40 return content.length === 1 && content[0].type === "text" ? content[0].text : content;
41}
42
43function toAnthropicUserContent(message) {
44 return typeof message.content === "string" ? message.content : JSON.stringify(message.content ?? "");

Callers 1

splitSystemAndMessagesFunction · 0.85

Calls 2

parseArgumentsFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected