Compare commits

...

7 Commits

Author SHA1 Message Date
celestial-vault bec4f5f332 merge conflicts 2025-02-28 13:07:15 -08:00
celestial-vault ccd9b275f3 remove comment 2025-02-28 13:02:40 -08:00
celestial-vault c4609696e4 re-open PR 2025-02-28 13:02:25 -08:00
celestial-vault 56ff98ad2c added changeset 2025-02-24 16:48:07 -08:00
celestial-vault a245d311e1 adjust export markdown handling 2025-02-24 16:45:16 -08:00
celestial-vault d4770994b9 adjust export markdown handling 2025-02-24 16:45:00 -08:00
celestial-vault cb5c333a04 Updated Anthropic SDK and fixed types 2025-02-24 16:33:22 -08:00
9 changed files with 39 additions and 24 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
Update anthropic SDK to the latest version
+5 -4
View File
@@ -10,8 +10,9 @@
"license": "Apache-2.0",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.12.4",
"@anthropic-ai/sdk": "^0.36.3",
"@anthropic-ai/sdk": "^0.37.0",
"@anthropic-ai/vertex-sdk": "^0.6.4",
"@google/generative-ai": "^0.18.0",
"@mistralai/mistralai": "^1.5.0",
"@modelcontextprotocol/sdk": "^1.0.1",
"@types/clone-deep": "^4.0.4",
@@ -96,9 +97,9 @@
}
},
"node_modules/@anthropic-ai/sdk": {
"version": "0.36.3",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.36.3.tgz",
"integrity": "sha512-+c0mMLxL/17yFZ4P5+U6bTWiCSFZUKJddrv01ud2aFBWnTPLdRncYV76D3q1tqfnL7aCnhRtykFnoCFzvr4U3Q==",
"version": "0.37.0",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.37.0.tgz",
"integrity": "sha512-tHjX2YbkUBwEgg0JZU3EFSSAQPoK4qQR/NFYa8Vtzd5UAyXzZksCw2In69Rml4R/TyHPBfRYaLK35XiOe33pjw==",
"license": "MIT",
"dependencies": {
"@types/node": "^18.11.18",
+3 -2
View File
@@ -262,9 +262,10 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@anthropic-ai/vertex-sdk": "^0.6.4",
"@anthropic-ai/bedrock-sdk": "^0.12.4",
"@anthropic-ai/sdk": "^0.36.3",
"@anthropic-ai/sdk": "^0.37.0",
"@anthropic-ai/vertex-sdk": "^0.6.4",
"@google/generative-ai": "^0.18.0",
"@mistralai/mistralai": "^1.5.0",
"@modelcontextprotocol/sdk": "^1.0.1",
"@types/clone-deep": "^4.0.4",
+4 -11
View File
@@ -11,16 +11,7 @@ import {
TextPart,
} from "@google/generative-ai"
export function convertAnthropicContentToGemini(
content:
| string
| Array<
| Anthropic.Messages.TextBlockParam
| Anthropic.Messages.ImageBlockParam
| Anthropic.Messages.ToolUseBlockParam
| Anthropic.Messages.ToolResultBlockParam
>,
): Part[] {
export function convertAnthropicContentToGemini(content: string | Anthropic.ContentBlockParam[]): Part[] {
if (typeof content === "string") {
return [{ text: content } as TextPart]
}
@@ -133,7 +124,7 @@ export function convertGeminiResponseToAnthropic(response: EnhancedGenerateConte
// Add the main text response
const text = response.text()
if (text) {
content.push({ type: "text", text })
content.push({ type: "text", text, citations: null })
}
// Add function calls as tool_use blocks
@@ -183,6 +174,8 @@ export function convertGeminiResponseToAnthropic(response: EnhancedGenerateConte
usage: {
input_tokens: response.usageMetadata?.promptTokenCount ?? 0,
output_tokens: response.usageMetadata?.candidatesTokenCount ?? 0,
cache_creation_input_tokens: null,
cache_read_input_tokens: null,
},
}
}
+3
View File
@@ -376,6 +376,7 @@ export function convertO1ResponseToAnthropicMessage(
{
type: "text",
text: normalText,
citations: null,
},
],
model: completion.model,
@@ -396,6 +397,8 @@ export function convertO1ResponseToAnthropicMessage(
usage: {
input_tokens: completion.usage?.prompt_tokens || 0,
output_tokens: completion.usage?.completion_tokens || 0,
cache_creation_input_tokens: null,
cache_read_input_tokens: null,
},
}
+3
View File
@@ -161,6 +161,7 @@ export function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.Ch
{
type: "text",
text: openAiMessage.content || "",
citations: null,
},
],
model: completion.model,
@@ -181,6 +182,8 @@ export function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.Ch
usage: {
input_tokens: completion.usage?.prompt_tokens || 0,
output_tokens: completion.usage?.completion_tokens || 0,
cache_creation_input_tokens: null,
cache_read_input_tokens: null,
},
}
+3
View File
@@ -175,6 +175,7 @@ export async function convertToAnthropicMessage(
return {
type: "text",
text: part.value,
citations: null,
}
}
@@ -195,6 +196,8 @@ export async function convertToAnthropicMessage(
usage: {
input_tokens: 0,
output_tokens: 0,
cache_creation_input_tokens: null,
cache_read_input_tokens: null,
},
}
}
+1 -3
View File
@@ -65,9 +65,7 @@ import { telemetryService } from "../services/telemetry/TelemetryService"
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
type ToolResponse = string | Array<Anthropic.TextBlockParam | Anthropic.ImageBlockParam>
type UserContent = Array<
Anthropic.TextBlockParam | Anthropic.ImageBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ToolResultBlockParam
>
type UserContent = Array<Anthropic.ContentBlockParam>
export class Cline {
readonly taskId: string
+12 -4
View File
@@ -35,14 +35,20 @@ export async function downloadTask(dateTs: number, conversationHistory: Anthropi
})
if (saveUri) {
// Write content to the selected location
await vscode.workspace.fs.writeFile(saveUri, Buffer.from(markdownContent))
vscode.window.showTextDocument(saveUri, { preview: true })
try {
// Write content to the selected location
await vscode.workspace.fs.writeFile(saveUri, new TextEncoder().encode(markdownContent))
vscode.window.showTextDocument(saveUri, { preview: true })
} catch (error) {
vscode.window.showErrorMessage(
`Failed to save markdown file: ${error instanceof Error ? error.message : String(error)}`,
)
}
}
}
export function formatContentBlockToMarkdown(
block: Anthropic.TextBlockParam | Anthropic.ImageBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ToolResultBlockParam,
block: Anthropic.ContentBlockParam,
// messages: Anthropic.MessageParam[]
): string {
switch (block.type) {
@@ -50,6 +56,8 @@ export function formatContentBlockToMarkdown(
return block.text
case "image":
return `[Image]`
case "document":
return `[Document]`
case "tool_use":
let input: string
if (typeof block.input === "object" && block.input !== null) {