Fix OpenRouter calls by mapping openai sdk messages to and from anthropic sdk messages

This commit is contained in:
Saoud Rizwan
2024-08-03 18:06:33 -04:00
parent fa1068d92d
commit d7ee0c0161
5 changed files with 210 additions and 64 deletions

View File

@@ -36,4 +36,22 @@ export class AwsBedrockHandler implements ApiHandler {
tool_choice: { type: "auto" },
})
}
createUserReadableRequest(
userContent: Array<
| Anthropic.TextBlockParam
| Anthropic.ImageBlockParam
| Anthropic.ToolUseBlockParam
| Anthropic.ToolResultBlockParam
>
): any {
return {
model: "anthropic.claude-3-5-sonnet-20240620-v1:0",
max_tokens: 4096,
system: "(see SYSTEM_PROMPT in src/ClaudeDev.ts)",
messages: [{ conversation_history: "..." }, { role: "user", content: userContent }],
tools: "(see tools in src/ClaudeDev.ts)",
tool_choice: { type: "auto" },
}
}
}