mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
baseline setup of agent abstract
This commit is contained in:
1
experiments/agents/__init__.py
Normal file
1
experiments/agents/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Agentic behavior runner for PHANTOM research platform."""
|
||||
26
experiments/agents/agent.py
Normal file
26
experiments/agents/agent.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from base import Agent
|
||||
|
||||
|
||||
class GenericComputerUseAgent(Agent):
|
||||
# TODO: implement code using computer-use library
|
||||
"""
|
||||
async def do_job(jtbd):
|
||||
browser = Browser(headless=True)
|
||||
llm = ChatOpenAI(model="gpt-5-mini")
|
||||
task = "You are an agent for doing anything on http://localhost:3000 (wait for the website to load) for the user. The user wants you to do the following job: "+jtbd + ". Use the browser to do it. Be careful to follow all instructions and complete the job fully. You have the power to purchase or to do anything."
|
||||
agent = Agent(task=task, llm=llm, browser=browser)
|
||||
return await agent.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
JTBD= "Book the best room"
|
||||
R=asyncio.run(do_job(JTBD))
|
||||
print(R.final_result())
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
def get_agent():
|
||||
# construct
|
||||
pass
|
||||
27
experiments/agents/base.py
Normal file
27
experiments/agents/base.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
|
||||
class Agent:
|
||||
def __init__(self,
|
||||
goal : str = "Get Information on All Prices",
|
||||
environment_url : str = "https://www.example.com",
|
||||
timeout : int = 60 * 5):
|
||||
self.goal = goal
|
||||
self.environment_url = environment_url
|
||||
self.timeout = timeout
|
||||
self.result = None
|
||||
# TODO: implement agent initialization
|
||||
pass
|
||||
async def act(self):
|
||||
# set the self.result to whatever text result the agents returns
|
||||
pass # return await _async_method()
|
||||
|
||||
def final_result(self) -> str|None:
|
||||
return self.result
|
||||
|
||||
|
||||
# asyncio.run(Agent(...).act())
|
||||
if __name__ == "__main__":
|
||||
print("Testing Agent...")
|
||||
agent = Agent(goal="Find the best price for a laptop", environment_url="https://www.example.com")
|
||||
asyncio.run(agent.act())
|
||||
print(f"Agent Result: {agent.final_result()}")
|
||||
3
experiments/agents/test.py
Normal file
3
experiments/agents/test.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import pytest
|
||||
|
||||
from agent import get_agent
|
||||
Reference in New Issue
Block a user