From c12bc10b8d81c05304b3eb28968aa92c2340d7fa Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 26 Mar 2025 17:11:19 -0700 Subject: [PATCH] tweaks --- core/llm/llms/Anthropic.ts | 62 ++++++++++++------- .../definitions/readCurrentlyOpenFile.ts | 2 +- core/tools/definitions/readFile.ts | 2 +- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 2 +- .../openai-adapters/src/apis/Anthropic.ts | 1 - 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/core/llm/llms/Anthropic.ts b/core/llm/llms/Anthropic.ts index cd48ef41b..b9e51fd28 100644 --- a/core/llm/llms/Anthropic.ts +++ b/core/llm/llms/Anthropic.ts @@ -30,15 +30,17 @@ class Anthropic extends BaseLLM { description: tool.function.description, input_schema: tool.function.parameters, })), - thinking: options.reasoning ? { - type: "enabled", - budget_tokens: options.reasoningBudgetTokens, - } : undefined, + thinking: options.reasoning + ? { + type: "enabled", + budget_tokens: options.reasoningBudgetTokens, + } + : undefined, tool_choice: options.toolChoice ? { - type: "tool", - name: options.toolChoice.function.name, - } + type: "tool", + name: options.toolChoice.function.name, + } : undefined, }; @@ -70,19 +72,23 @@ class Anthropic extends BaseLLM { } else if (message.role === "thinking" && !message.redactedThinking) { return { role: "assistant", - content: [{ - type: "thinking", - thinking: message.content, - signature: message.signature - }] + content: [ + { + type: "thinking", + thinking: message.content, + signature: message.signature, + }, + ], }; } else if (message.role === "thinking" && message.redactedThinking) { return { role: "assistant", - content: [{ - type: "redacted_thinking", - data: message.redactedThinking - }] + content: [ + { + type: "redacted_thinking", + data: message.redactedThinking, + }, + ], }; } @@ -195,12 +201,12 @@ class Anthropic extends BaseLLM { messages: msgs, system: shouldCacheSystemMessage ? [ - { - type: "text", - text: this.systemMessage, - cache_control: { type: "ephemeral" }, - }, - ] + { + type: "text", + text: this.systemMessage, + cache_control: { type: "ephemeral" }, + }, + ] : systemMessage, }), signal, @@ -240,7 +246,11 @@ class Anthropic extends BaseLLM { // handle redacted thinking if (value.content_block.type === "redacted_thinking") { console.log("redacted thinking", value.content_block.data); - yield { role: "thinking", content: "", redactedThinking: value.content_block.data }; + yield { + role: "thinking", + content: "", + redactedThinking: value.content_block.data, + }; } break; case "content_block_delta": @@ -253,7 +263,11 @@ class Anthropic extends BaseLLM { yield { role: "thinking", content: value.delta.thinking }; break; case "signature_delta": - yield { role: "thinking", content: "", signature: value.delta.signature }; + yield { + role: "thinking", + content: "", + signature: value.delta.signature, + }; break; case "input_json_delta": if (!lastToolUseId || !lastToolUseName) { diff --git a/core/tools/definitions/readCurrentlyOpenFile.ts b/core/tools/definitions/readCurrentlyOpenFile.ts index f4df8e1e5..eacaab70d 100644 --- a/core/tools/definitions/readCurrentlyOpenFile.ts +++ b/core/tools/definitions/readCurrentlyOpenFile.ts @@ -6,7 +6,7 @@ export const readCurrentlyOpenFileTool: Tool = { displayTitle: "Read Currently Open File", wouldLikeTo: "read the current file", isCurrently: "reading the current file", - hasAlready: "read the current file", + hasAlready: "viewed the current file", readonly: true, group: BUILT_IN_GROUP_NAME, function: { diff --git a/core/tools/definitions/readFile.ts b/core/tools/definitions/readFile.ts index 0133b54b0..ff5d58a31 100644 --- a/core/tools/definitions/readFile.ts +++ b/core/tools/definitions/readFile.ts @@ -6,7 +6,7 @@ export const readFileTool: Tool = { displayTitle: "Read File", wouldLikeTo: "read {{{ filepath }}}", isCurrently: "reading {{{ filepath }}}", - hasAlready: "read {{{ filepath }}}", + hasAlready: "viewed {{{ filepath }}}", readonly: true, group: BUILT_IN_GROUP_NAME, function: { diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx index 47868cfc8..24a131440 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx @@ -54,7 +54,7 @@ export function ToolCallDisplay(props: ToolCallDisplayProps) { Mustache.render(tool.isCurrently, props.toolCallState.parsedArgs) ) : ( <> - using the {defaultToolDescription} + calling the {defaultToolDescription} ); } else if (props.toolCallState.status === "done") { diff --git a/packages/openai-adapters/src/apis/Anthropic.ts b/packages/openai-adapters/src/apis/Anthropic.ts index 04b0fbce9..36c33e550 100644 --- a/packages/openai-adapters/src/apis/Anthropic.ts +++ b/packages/openai-adapters/src/apis/Anthropic.ts @@ -175,7 +175,6 @@ export class AnthropicApi implements BaseLlmApi { body: ChatCompletionCreateParamsStreaming, signal: AbortSignal, ): AsyncGenerator { - body.messages; const response = await customFetch(this.config.requestOptions)( new URL("messages", this.apiBase), {