Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/puny-garlics-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fix the open operator handler to work with anthropic
18 changes: 14 additions & 4 deletions lib/handlers/operatorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,20 @@ export class StagehandOperatorHandler {
type: "text",
text: messageText,
},
{
type: "image_url",
image_url: { url: `data:image/png;base64,${base64Image}` },
},
this.llmClient.type === "anthropic"
? {
type: "image",
source: {
type: "base64",
media_type: "image/png",
data: base64Image,
},
text: "the screenshot of the current page",
}
: {
type: "image_url",
image_url: { url: `data:image/png;base64,${base64Image}` },
},
],
});
}
Expand Down
9 changes: 7 additions & 2 deletions lib/llm/LLMClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ export type ChatMessageContent =
| (ChatMessageImageContent | ChatMessageTextContent)[];

export interface ChatMessageImageContent {
type: "image_url";
image_url: { url: string };
type: string;
image_url?: { url: string };
text?: string;
source?: {
type: string;
media_type: string;
data: string;
};
}

export interface ChatMessageTextContent {
Expand Down