Skip to content

Commit 45512b6

Browse files
committed
Pass image through FunctionResponse.data field. This will fix the token issue.
1 parent 9c0d750 commit 45512b6

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

agent.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ def multiply_numbers(x: float, y: float) -> dict:
4444

4545

4646
class BrowserAgent:
47-
def __init__(
48-
self,
49-
browser_computer: Computer,
50-
query: str,
51-
model_name: str
52-
):
47+
def __init__(self, browser_computer: Computer, query: str, model_name: str):
5348
self._browser_computer = browser_computer
5449
self._query = query
5550
self._model_name = model_name
@@ -283,15 +278,14 @@ def run_one_iteration(self) -> Literal["COMPLETE", "CONTINUE"]:
283278
function_responses.append(
284279
FunctionResponse(
285280
name=function_call.name,
286-
response={
287-
"image": {
288-
"mimetype": "image/png",
289-
"data": base64.b64encode(fc_result.screenshot).decode(
290-
"utf-8"
291-
),
292-
},
293-
"url": fc_result.url,
294-
},
281+
response={"url": fc_result.url},
282+
data=[
283+
types.Part(
284+
inline_data=types.Blob(
285+
mime_type="image/png", data=fc_result.screenshot
286+
)
287+
)
288+
],
295289
)
296290
)
297291
elif isinstance(fc_result, dict):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
termcolor==3.1.0
22
pydantic==2.11.4
3-
./sdk/google_genai-1.25.0-py3-none-any.whl
3+
./sdk/google_genai-1.27.0-py3-none-any.whl
44
playwright==1.52.0
55
browserbase==1.3.0
66
rich
-204 KB
Binary file not shown.
205 KB
Binary file not shown.

0 commit comments

Comments
 (0)