Skip to content

Commit 131b245

Browse files
committed
Revert "Anthropic: Bump it up! (RooCodeInc#1938)"
This reverts commit c280949.
1 parent c280949 commit 131b245

File tree

10 files changed

+33
-48
lines changed

10 files changed

+33
-48
lines changed

.changeset/silver-hotels-reflect.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@
237237
"typescript": "^5.4.5"
238238
},
239239
"dependencies": {
240-
"@anthropic-ai/bedrock-sdk": "^0.12.4",
241-
"@anthropic-ai/sdk": "^0.37.0",
240+
"@anthropic-ai/bedrock-sdk": "^0.10.2",
241+
"@anthropic-ai/sdk": "^0.26.0",
242242
"@anthropic-ai/vertex-sdk": "^0.4.1",
243243
"@google/generative-ai": "^0.18.0",
244244
"@mistralai/mistralai": "^1.5.0",

src/api/providers/anthropic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class AnthropicHandler implements ApiHandler {
2020
@withRetry()
2121
async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
2222
const model = this.getModel()
23-
let stream: AnthropicStream<Anthropic.RawMessageStreamEvent>
23+
let stream: AnthropicStream<Anthropic.Beta.PromptCaching.Messages.RawPromptCachingBetaMessageStreamEvent>
2424
const modelId = model.id
2525
switch (modelId) {
2626
// 'latest' alias does not support cache_control
@@ -38,7 +38,7 @@ export class AnthropicHandler implements ApiHandler {
3838
)
3939
const lastUserMsgIndex = userMsgIndices[userMsgIndices.length - 1] ?? -1
4040
const secondLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 2] ?? -1
41-
stream = await this.client.messages.create(
41+
stream = await this.client.beta.promptCaching.messages.create(
4242
{
4343
model: modelId,
4444
max_tokens: model.info.maxTokens || 8192,

src/api/transform/gemini-format.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ import {
1111
TextPart,
1212
} from "@google/generative-ai"
1313

14-
export function convertAnthropicContentToGemini(content: string | Anthropic.ContentBlockParam[]): Part[] {
14+
export function convertAnthropicContentToGemini(
15+
content:
16+
| string
17+
| Array<
18+
| Anthropic.Messages.TextBlockParam
19+
| Anthropic.Messages.ImageBlockParam
20+
| Anthropic.Messages.ToolUseBlockParam
21+
| Anthropic.Messages.ToolResultBlockParam
22+
>,
23+
): Part[] {
1524
if (typeof content === "string") {
1625
return [{ text: content } as TextPart]
1726
}
@@ -124,7 +133,7 @@ export function convertGeminiResponseToAnthropic(response: EnhancedGenerateConte
124133
// Add the main text response
125134
const text = response.text()
126135
if (text) {
127-
content.push({ type: "text", text, citations: null })
136+
content.push({ type: "text", text })
128137
}
129138

130139
// Add function calls as tool_use blocks
@@ -174,8 +183,6 @@ export function convertGeminiResponseToAnthropic(response: EnhancedGenerateConte
174183
usage: {
175184
input_tokens: response.usageMetadata?.promptTokenCount ?? 0,
176185
output_tokens: response.usageMetadata?.candidatesTokenCount ?? 0,
177-
cache_creation_input_tokens: null,
178-
cache_read_input_tokens: null,
179186
},
180187
}
181188
}

src/api/transform/o1-format.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ export function convertO1ResponseToAnthropicMessage(
376376
{
377377
type: "text",
378378
text: normalText,
379-
citations: null,
380379
},
381380
],
382381
model: completion.model,
@@ -397,8 +396,6 @@ export function convertO1ResponseToAnthropicMessage(
397396
usage: {
398397
input_tokens: completion.usage?.prompt_tokens || 0,
399398
output_tokens: completion.usage?.completion_tokens || 0,
400-
cache_creation_input_tokens: null,
401-
cache_read_input_tokens: null,
402399
},
403400
}
404401

src/api/transform/openai-format.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ export function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.Ch
161161
{
162162
type: "text",
163163
text: openAiMessage.content || "",
164-
citations: null,
165164
},
166165
],
167166
model: completion.model,
@@ -182,8 +181,6 @@ export function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.Ch
182181
usage: {
183182
input_tokens: completion.usage?.prompt_tokens || 0,
184183
output_tokens: completion.usage?.completion_tokens || 0,
185-
cache_creation_input_tokens: null,
186-
cache_read_input_tokens: null,
187184
},
188185
}
189186

src/api/transform/vscode-lm-format.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export async function convertToAnthropicMessage(
175175
return {
176176
type: "text",
177177
text: part.value,
178-
citations: null,
179178
}
180179
}
181180

@@ -196,8 +195,6 @@ export async function convertToAnthropicMessage(
196195
usage: {
197196
input_tokens: 0,
198197
output_tokens: 0,
199-
cache_creation_input_tokens: null,
200-
cache_read_input_tokens: null,
201198
},
202199
}
203200
}

src/core/Cline.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ import { ClineProvider, GlobalFileNames } from "./webview/ClineProvider"
6363
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution
6464

6565
type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>
66-
type UserContent = Array<Anthropic.ContentBlockParam>
66+
type UserContent = Array<
67+
Anthropic.TextBlockParam | Anthropic.ImageBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ToolResultBlockParam
68+
>
6769

6870
export class Cline {
6971
readonly taskId: string

src/integrations/misc/export-markdown.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,21 @@ export async function downloadTask(dateTs: number, conversationHistory: Anthropi
3535
})
3636

3737
if (saveUri) {
38-
try {
39-
// Write content to the selected location
40-
await vscode.workspace.fs.writeFile(saveUri, new TextEncoder().encode(markdownContent))
41-
vscode.window.showTextDocument(saveUri, { preview: true })
42-
} catch (error) {
43-
vscode.window.showErrorMessage(
44-
`Failed to save markdown file: ${error instanceof Error ? error.message : String(error)}`,
45-
)
46-
}
38+
// Write content to the selected location
39+
await vscode.workspace.fs.writeFile(saveUri, Buffer.from(markdownContent))
40+
vscode.window.showTextDocument(saveUri, { preview: true })
4741
}
4842
}
4943

5044
export function formatContentBlockToMarkdown(
51-
block: Anthropic.ContentBlockParam,
45+
block: Anthropic.TextBlockParam | Anthropic.ImageBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ToolResultBlockParam,
5246
// messages: Anthropic.MessageParam[]
5347
): string {
5448
switch (block.type) {
5549
case "text":
5650
return block.text
5751
case "image":
5852
return `[Image]`
59-
case "document":
60-
return `[Document]`
6153
case "tool_use":
6254
let input: string
6355
if (typeof block.input === "object" && block.input !== null) {

0 commit comments

Comments
 (0)