File size: 1,037 Bytes
dbaa85f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from langchain_openai import ChatOpenAI
from browser_use import Agent
import asyncio
from dotenv import load_dotenv
load_dotenv()
from langchain.tools import BaseTool

class SMILES2Weight(BaseTool):
    name: str = "webuse"
    description: str = ("Calling the browser to search for information "
                        "input query, return the searching results")

    def __init__(

        self,

    ):
        super().__init__()

    async def _run(self, task: str) -> str:
        agent = Agent(
            task="Go to Reddit, search for 'browser-use', click on the first post and return the first comment.",
            llm = ChatOpenAI(model="gpt-4o-2024-11-20",api_key='sk-itPrztYm9F6XZZpsBMJB9O7Vq0pYUABVVBSoThuBxEGTnDik',
                 base_url="https://www.dmxapi.com/v1"),
        )
        result = await agent.run()
        return result
    
    async def _arun(self, smiles: str) -> str:
        """Use the tool asynchronously."""
        raise NotImplementedError()