mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 04:01:51 +09:00
Gemini로 바꾸고 오류 발생률이 심각하게 줄었어요. 이건 OpenAI의 문제!
This commit is contained in:
parent
96837ed01d
commit
ba02e8ea21
2 changed files with 28 additions and 10 deletions
|
|
@ -1,8 +1,8 @@
|
|||
ANONYMIZED_TELEMETRY=false
|
||||
|
||||
OPENAI_API_KEY=your_openai_api_key_here
|
||||
OPENAI_BASE_URL=https://models.github.ai/inference # 선택
|
||||
OPENAI_MODEL=openai/gpt-4o-mini # Github Models가 아닐시 gpt-4.1
|
||||
GOOGLE_API_KEY=
|
||||
GOOGLE_MODEL=gemini-2.5-flash-preview-04-17 # 권장 (다른 모델로 교체 가능) [다른 모델로 교체시 성능 보장 불가]
|
||||
GOOGLE_PLANNER_MODEL=gemini-2.0-flash-lite # 권장 (다른 모델로 교체 가능) [다른 모델로 교체시 성능 보장 불가]
|
||||
|
||||
# 선택
|
||||
PROXY_HOST=127.0.0.1
|
||||
|
|
|
|||
32
main.py
32
main.py
|
|
@ -4,19 +4,20 @@ import os
|
|||
from typing import List
|
||||
from dotenv import load_dotenv
|
||||
from pydantic import BaseModel
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from browser_use import Agent, Browser, BrowserConfig, Controller
|
||||
from browser_use.browser.context import BrowserContext, BrowserContextConfig
|
||||
from lib.browser_config import browser_config_kwargs
|
||||
import csv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Check environment variables
|
||||
if os.getenv("OPENAI_API_KEY") is None:
|
||||
if os.getenv("GOOGLE_API_KEY") is None:
|
||||
raise ValueError("OPENAI_API_KEY environment variable not set.")
|
||||
if os.getenv("OPENAI_MODEL") is None:
|
||||
if os.getenv("GOOGLE_MODEL") is None:
|
||||
raise ValueError("OPENAI_MODEL environment variable not set.")
|
||||
if os.getenv("OPENAI_PLANNER_MODEL") is None:
|
||||
if os.getenv("GOOGLE_PLANNER_MODEL") is None:
|
||||
raise ValueError("OPENAI_PLANNER_MODEL environment variable not set.")
|
||||
|
||||
# Configure browser
|
||||
|
|
@ -89,14 +90,14 @@ extend_planner_system_message = """
|
|||
|
||||
# Main async runner
|
||||
async def main():
|
||||
url = "https://auth0.com"
|
||||
url = "https://git.imnya.ng"
|
||||
|
||||
agent = Agent(
|
||||
browser_context=context,
|
||||
browser=browser,
|
||||
task=f"Go to {url}, navigate to the login page, and collect the OAuth provider buttons and their login URLs. Ignore Passkey.",
|
||||
llm=ChatOpenAI(model=os.getenv("OPENAI_MODEL")),
|
||||
planner_llm=ChatOpenAI(model=os.getenv("OPENAI_PLANNER_MODEL")),
|
||||
llm=ChatGoogleGenerativeAI(model=os.getenv("GOOGLE_MODEL")),
|
||||
planner_llm=ChatGoogleGenerativeAI(model=os.getenv("GOOGLE_PLANNER_MODEL")),
|
||||
controller=controller,
|
||||
extend_planner_system_message=extend_planner_system_message,
|
||||
)
|
||||
|
|
@ -129,6 +130,23 @@ async def main():
|
|||
else:
|
||||
print(f"- {entry.provider}: {entry.oauth_uri}")
|
||||
|
||||
# Save the result to CSV (append mode, so you can continue later)
|
||||
# 이거 좀 이상한데 나중에 고쳐야 할듯 파일이 수정이 안됨
|
||||
csv_file = "oauth_providers.csv"
|
||||
file_exists = os.path.isfile(csv_file)
|
||||
with open(csv_file, "a", newline="", encoding="utf-8") as f:
|
||||
writer = csv.writer(f)
|
||||
if not file_exists:
|
||||
writer.writerow(["issuer", "provider", "oauth_uri"])
|
||||
for entry in oauth_entries:
|
||||
writer.writerow([url, entry.provider, entry.oauth_uri])
|
||||
print(f"\n✅ OAuth providers saved to {csv_file}")
|
||||
|
||||
# Save the result to JSON
|
||||
with open(f"oauth_providers_{url}.json", "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
print(f"✅ OAuth providers saved to oauth_providers_{url}.json")
|
||||
|
||||
|
||||
# Run it
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue