Skip to content

Commit 3f2a925

Browse files
committed
Structured web browser content
1 parent d34e2d0 commit 3f2a925

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

llmstack/processors/providers/promptly/static_web_browser.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class StaticWebBrowserConfiguration(ApiProcessorSchema):
6666
default=[],
6767
json_schema_extra={"advanced_parameter": True},
6868
)
69+
extract_html: bool = Field(
70+
description="Extract HTML",
71+
default=False,
72+
)
73+
capture_screenshot: bool = Field(
74+
description="Capture screenshot",
75+
default=True,
76+
)
6977

7078

7179
class StaticWebBrowserInput(ApiProcessorSchema):
@@ -144,8 +152,8 @@ def process(self) -> dict:
144152
with WebBrowser(
145153
f"{settings.RUNNER_HOST}:{settings.RUNNER_PORT}",
146154
interactive=self._config.stream_video,
147-
capture_screenshot=True,
148-
html=True,
155+
capture_screenshot=self._config.capture_screenshot,
156+
html=self._config.extract_html,
149157
tags_to_extract=self._config.tags_to_extract,
150158
session_data=(
151159
self._env["connections"][self._config.connection_id]["configuration"]["_storage_state"]
@@ -181,15 +189,11 @@ def process(self) -> dict:
181189
mime_type="image/png",
182190
)
183191

184-
browser_response = browser_response.model_dump()
185-
browser_response["screenshot"] = screenshot_asset.objref if screenshot_asset else None
192+
browser_response.screenshot = screenshot_asset.objref if screenshot_asset else None
186193

187194
async_to_sync(output_stream.write)(
188195
WebBrowserOutput(
189-
text=browser_response.get(
190-
"text",
191-
"".join(list(map(lambda x: x.get("output", ""), browser_response.get("command_outputs", [])))),
192-
),
196+
text=browser_response.text or "".join(list(map(lambda x: x.output, browser_response.command_outputs))),
193197
content=browser_response,
194198
),
195199
)

llmstack/processors/providers/promptly/web_browser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from asgiref.sync import async_to_sync
88
from django.conf import settings
99
from langrocks.client import WebBrowser as WebBrowserClient
10-
from langrocks.common.models.web_browser import WebBrowserCommand, WebBrowserCommandType
10+
from langrocks.common.models.web_browser import (
11+
WebBrowserCommand,
12+
WebBrowserCommandType,
13+
WebBrowserContent,
14+
)
1115
from pydantic import BaseModel, Field
1216

1317
from llmstack.apps.schemas import OutputTemplate
@@ -284,7 +288,7 @@ class WebBrowserOutput(ApiProcessorSchema):
284288
default=None,
285289
description="Video of the result",
286290
)
287-
content: Optional[dict] = Field(
291+
content: Optional[WebBrowserContent] = Field(
288292
default=None,
289293
description="Content of the result including text, buttons, links, inputs, textareas and selects",
290294
)
@@ -318,7 +322,7 @@ class WebBrowser(
318322

319323
@staticmethod
320324
def name() -> str:
321-
return "Web Browser"
325+
return "Web Browser Agent"
322326

323327
@staticmethod
324328
def slug() -> str:

0 commit comments

Comments
 (0)