docker 运行claude 的computer use

需要注意的是:这里claude操纵的是docker的虚拟服务器,不能访问本地url,需要进行端口转发 

export ANTHROPIC_API_KEY=%your_api_key%
docker run \
    -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
    -v $HOME/.anthropic:/home/computeruse/.anthropic \
    -p 5900:5900 \
    -p 8501:8501 \
    -p 6080:6080 \
    -p 8080:8080 \
    -it ghcr.io/anthropics/anthropic-quickstarts:computer-use-demo-latest

 也可以用browser use 操纵自己的本地浏览器,步骤如下

conda create -n browse python=3.11  
conda activate browse
git clone https://github.com/browser-use/web-ui.git

cd web-ui

pip install -r requirements.txt

python webui.py --ip 127.0.0.1 --port 7788
记得填写.env对应的key

Output Format - Browser Use

调用qwen模型

import os
from langchain_openai import ChatOpenAI
from langchain_openai.chat_models.base import BaseChatOpenAI
from browser_use import Agent, Browser, BrowserConfig
import asyncio

# 无头模式
browser = Browser(
    config=BrowserConfig(
        headless=False,
        disable_security=True
    )
)

os.environ['OPENAI_API_KEY'] = "your_openai_api_key"

async def main():
    agent = Agent(
        task="Visit URL: http://localhost:3000 And test the form submission function of this website to see if the successful submission prompt pop-up window is displayed. Finally, it is essential to provide an accurate conclusion on whether the function is effective or ineffective",
      
        llm=BaseChatOpenAI(model="qwen-max-2025-01-25",
                           base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"),
        browser=browser
    )

    result = await agent.run()
    print(result)

asyncio.run(main())

阿里云调用vl模型

如何使用Qwen-VL模型_大模型服务平台百炼(Model Studio)-阿里云帮助中心

browse use 的一些输出

  history = await agent.run()

        if history.has_errors():
            print("执行过程中的错误:", history.errors())
        result = history.final_result()
        if result:
            with open('results.txt', 'a') as f:
                f.write(f"第{i}次测试结果:\n")
                f.write(result + '\n')
                history.number_of_steps()        # 获取总步数
# history.total_duration_seconds() # 获取总执行时间
# history.total_input_tokens()     # 获取总token使用量
# history.is_done()         # 检查任务是否完成
# history.is_successful()   # 检查任务是否成功完成
# history.has_errors()      # 检查是否有错误发生
# history.urls()           # 获取访问过的所有URL
# history.screenshots()    # 获取所有截图路径
# history.action_names()   # 获取执行的所有动作名称
# history.model_actions()  # 获取所有动作及其参数
# history.final_result()      # 获取最终结果
# history.extracted_content() # 获取提取的内容
# history.errors()           # 获取所有错误信息
# history.model_thoughts()  # 获取代理的推理过程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值