Skip to content

Commit b0def5c

Browse files
authored
Fix browser use to adapt new runtime version
Fix browser use to adapt new runtime version
2 parents b498677 + 2a4aeee commit b0def5c

File tree

6 files changed

+19
-1052
lines changed

6 files changed

+19
-1052
lines changed

browser_use/browser_use_fullstack_runtime/backend/agentscope_browseruse_agent.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
run_shell_command,
5050
)
5151

52-
from .prompts import SYSTEM_PROMPT
52+
from prompts import SYSTEM_PROMPT
5353

5454
if os.path.exists(".env"):
5555
from dotenv import load_dotenv
@@ -130,11 +130,9 @@ async def connect(self) -> None:
130130

131131
if len(sandboxes) > 0:
132132
sandbox = sandboxes[0]
133-
js = sandbox.get_info()
134-
ws = js["front_browser_ws"]
135-
self.ws = ws
133+
self.desktop_url = sandbox.desktop_url
136134
else:
137-
self.ws = ""
135+
self.desktop_url = ""
138136

139137
runner = Runner(
140138
agent=self.agent,

browser_use/browser_use_fullstack_runtime/backend/async_quart_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ async def stream():
9696

9797
@app.route("/env_info", methods=["GET"])
9898
async def get_env_info():
99-
if agent.ws is not None:
100-
url = agent.ws
99+
if agent.desktop_url is not None:
100+
url = agent.desktop_url
101101
logger.info(url)
102102
return jsonify({"url": url})
103103
else:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pyyaml>=6.0.2
22
quart>=0.8.0
33
quart-cors>=0.8.0
4-
agentscope-runtime>=0.1.5
4+
agentscope-runtime>=0.1.6
55
agentscope[full]>=1.0.5

browser_use/browser_use_fullstack_runtime/frontend/src/App.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import type { InputRef } from "antd";
66

77
import { Image, Avatar, Spin } from "antd";
88
import { Flex } from "antd";
9-
import Browser from "./Browser";
109

1110
const { Content, Footer } = Layout;
1211

1312
const REACT_APP_API_URL =
1413
process.env.REACT_APP_API_URL || "http://localhost:9000";
1514
const BACKEND_URL = REACT_APP_API_URL + "/v1/chat/completions";
16-
const BACKEND_WS_URL = REACT_APP_API_URL + "/env_info";
15+
const BACKEND_DESLKTOP_URL = REACT_APP_API_URL + "/env_info";
1716
const DEFAULT_MODEL = "qwen-max";
1817
const systemMessage = {
1918
role: "system",
@@ -37,7 +36,7 @@ const { Search } = Input;
3736
const App: React.FC = () => {
3837
const inputRef = useRef<InputRef>(null);
3938
const listRef = useRef<HTMLDivElement>(null);
40-
const [webSocketUrl, setWebSocketUrl] = useState("");
39+
const [desktopUrl, setDesktopUrl] = useState("");
4140
const handleFocus = () => {
4241
if (inputRef.current) {
4342
inputRef.current.select();
@@ -57,8 +56,8 @@ const App: React.FC = () => {
5756
]);
5857
const [isTyping, setIsTyping] = useState(false);
5958

60-
async function get_ws() {
61-
const response = await fetch(BACKEND_WS_URL, {
59+
async function get_desktop_url() {
60+
const response = await fetch(BACKEND_DESLKTOP_URL, {
6261
method: "GET",
6362
headers: {
6463
"Content-Type": "application/json",
@@ -74,11 +73,11 @@ const App: React.FC = () => {
7473

7574
const data = await response.json();
7675
console.log(data);
77-
setWebSocketUrl(data.url);
76+
setDesktopUrl(data.url);
7877
}
7978

8079
const handleSend = async (message: string) => {
81-
await get_ws();
80+
await get_desktop_url();
8281
setCollapsed(true);
8382
if (message.trim() === "") {
8483
return;
@@ -254,7 +253,13 @@ const App: React.FC = () => {
254253
)}
255254
</Flex>
256255

257-
<Browser webSocketUrl={webSocketUrl} activeKey={"3"} />
256+
{desktopUrl && (
257+
<iframe
258+
src={desktopUrl}
259+
style={{ width: '1280px', height: '800px', border: 'none' }}
260+
title="DesktopPage"
261+
/>
262+
)}
258263
</Flex>
259264
</Flex>
260265
</div>

0 commit comments

Comments
 (0)