Created
January 22, 2025 21:55
-
-
Save jerpint/24ed3dbfa9a85ee64b34499100b4ac6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
import asyncio | |
from langchain_openai import ChatOpenAI | |
from langchain_anthropic import ChatAnthropic | |
from langchain_google_genai import ChatGoogleGenerativeAI | |
from langchain_ollama import ChatOllama | |
from browser_use import Agent | |
from datetime import datetime | |
TASK = """ | |
Go to https://neal.fun/password-game/ and find an appropriate password that satisfies the criteria. | |
Keep track of the highest rule number that has been satisfied explicitly in a variable in memory, e.g. MAX_RULE=1. | |
""" | |
MAX_STEPS = 30 | |
# For saving logs | |
current_time = datetime.now().strftime("%Y_%m_%d_%H_%M_%S") | |
models = { | |
'gemini-1.5-flash': ChatGoogleGenerativeAI(model='gemini-1.5-flash'), | |
'claude-3-5-sonnet-20241022': ChatAnthropic(model='claude-3-5-sonnet-20241022'), | |
'gpt-4o': ChatOpenAI(model='gpt-4o'), | |
'gpt-4o-mini': ChatOpenAI(model='gpt-4o-mini'), | |
'gemini-1.5-pro': ChatGoogleGenerativeAI(model='gemini-1.5-pro'), | |
} | |
for model in models: | |
print("*" * 100) | |
print(f"---Running model: {model}---") | |
print("*" * 100) | |
# Set up agent | |
llm = models[model] | |
agent = Agent( | |
task=TASK, | |
llm=llm, | |
save_conversation_path=f"logs/{model}/{current_time}/conversation.json" # Save chat logs | |
) | |
async def main(): | |
history = await agent.run(max_steps=MAX_STEPS) | |
history.save_to_file(f"history/{model}/{current_time}/history.json") | |
# Run experiment | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment