cte 10 месяцев назад
Родитель
Сommit
22391e5011

+ 3 - 1
src/api/transform/bedrock-converse-format.ts

@@ -193,6 +193,8 @@ export function convertToAnthropicMessage(
 			usage: {
 				input_tokens: streamEvent.metadata.usage.inputTokens || 0,
 				output_tokens: streamEvent.metadata.usage.outputTokens || 0,
+				cache_creation_input_tokens: null,
+				cache_read_input_tokens: null,
 			},
 		}
 	}
@@ -203,7 +205,7 @@ export function convertToAnthropicMessage(
 		return {
 			type: "message",
 			role: "assistant",
-			content: [{ type: "text", text: text }],
+			content: [{ type: "text", text: text, citations: null }],
 			model: modelId,
 		}
 	}

+ 4 - 11
src/api/transform/gemini-format.ts

@@ -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: Anthropic.Messages.MessageParam["content"]): Part[] {
 	if (typeof content === "string") {
 		return [{ text: content } as TextPart]
 	}
@@ -140,7 +131,7 @@ export function convertGeminiResponseToAnthropic(
 	// 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
@@ -190,6 +181,8 @@ export function convertGeminiResponseToAnthropic(
 		usage: {
 			input_tokens: response.usageMetadata?.promptTokenCount ?? 0,
 			output_tokens: response.usageMetadata?.candidatesTokenCount ?? 0,
+			cache_creation_input_tokens: null,
+			cache_read_input_tokens: null,
 		},
 	}
 }

+ 3 - 0
src/api/transform/openai-format.ts

@@ -158,6 +158,7 @@ export function convertToAnthropicMessage(
 			{
 				type: "text",
 				text: openAiMessage.content || "",
+				citations: null,
 			},
 		],
 		model: completion.model,
@@ -178,6 +179,8 @@ export function convertToAnthropicMessage(
 		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,
 		},
 	}
 

+ 1 - 10
src/api/transform/simple-format.ts

@@ -3,16 +3,7 @@ import { Anthropic } from "@anthropic-ai/sdk"
 /**
  * Convert complex content blocks to simple string content
  */
-export function convertToSimpleContent(
-	content:
-		| string
-		| Array<
-				| Anthropic.Messages.TextBlockParam
-				| Anthropic.Messages.ImageBlockParam
-				| Anthropic.Messages.ToolUseBlockParam
-				| Anthropic.Messages.ToolResultBlockParam
-		  >,
-): string {
+export function convertToSimpleContent(content: Anthropic.Messages.MessageParam["content"]): string {
 	if (typeof content === "string") {
 		return content
 	}

+ 3 - 0
src/api/transform/vscode-lm-format.ts

@@ -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
src/core/Cline.ts

@@ -69,9 +69,7 @@ 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.Messages.ContentBlockParam>
 
 export type ClineOptions = {
 	provider: ClineProvider

+ 1 - 8
src/integrations/misc/export-markdown.ts

@@ -41,14 +41,7 @@ export async function downloadTask(dateTs: number, conversationHistory: Anthropi
 	}
 }
 
-export function formatContentBlockToMarkdown(
-	block:
-		| Anthropic.TextBlockParam
-		| Anthropic.ImageBlockParam
-		| Anthropic.ToolUseBlockParam
-		| Anthropic.ToolResultBlockParam,
-	// messages: Anthropic.MessageParam[]
-): string {
+export function formatContentBlockToMarkdown(block: Anthropic.Messages.ContentBlockParam): string {
 	switch (block.type) {
 		case "text":
 			return block.text