mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 08:31:51 +09:00
feat: Browser Use Update
This commit is contained in:
parent
353e98e28c
commit
bc9b598993
5 changed files with 82 additions and 313 deletions
|
|
@ -1,25 +1,18 @@
|
|||
from langchain.callbacks.base import BaseCallbackHandler
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from browser_use.llm import ChatGoogle
|
||||
from dotenv import load_dotenv
|
||||
|
||||
class QuotaExhaustedHandler(BaseCallbackHandler):
|
||||
def on_llm_error(self, error, **kwargs):
|
||||
if "ResourceExhausted" in str(error) or "429" in str(error):
|
||||
print("⚠️ API 쿼터가 소진되었습니다. 재시도 로직에 위임합니다...")
|
||||
# backoff handled in scan_one_url
|
||||
# 환경 변수 로드 (GOOGLE_API_KEY 필요)
|
||||
load_dotenv(override=True)
|
||||
|
||||
def CreateChatGoogleGenerativeAI(model: str):
|
||||
"""재시도 로직이 포함된 LLM 생성"""
|
||||
def CreateChatGoogle(model: str):
|
||||
"""Browser Use용 Google 모델 생성"""
|
||||
if model == "fallback":
|
||||
print("⚠️ Fallback 모델을 사용합니다. Envorinment 변수를 확인하세요.")
|
||||
print("⚠️ Model Gemini-2.0-flash-lite를 사용합니다.")
|
||||
print("⚠️ Fallback 모델을 사용합니다. Environment 변수를 확인하세요.")
|
||||
print("⚠️ Model gemini-2.0-flash-lite를 사용합니다.")
|
||||
model = "gemini-2.0-flash-lite"
|
||||
return ChatGoogleGenerativeAI(
|
||||
|
||||
return ChatGoogle(
|
||||
model=model,
|
||||
max_retries=10, # 최대 재시도 횟수 증가
|
||||
model_kwargs={
|
||||
"request_timeout": 120, # 타임아웃 시간 증가 (2분)
|
||||
},
|
||||
callbacks=[QuotaExhaustedHandler()],
|
||||
# API 호출 간격 조정
|
||||
temperature=0.0,
|
||||
)
|
||||
# Browser Use는 내부적으로 재시도 로직을 처리합니다
|
||||
)
|
||||
|
|
@ -31,7 +31,6 @@ Your task is to navigate to the login page of the given URL. Follow the steps be
|
|||
- Username/password fields
|
||||
- Email-based login
|
||||
- Non-OAuth methods such as certificate or phone verification
|
||||
- ✅ If you are unsure whether a button is OAuth-based or not, you MUST click the button and check the redirect behavior yourself.
|
||||
|
||||
3. RETURN FORMAT
|
||||
- If the login page is successfully found, return:
|
||||
|
|
@ -59,5 +58,4 @@ Your task is to navigate to the login page of the given URL. Follow the steps be
|
|||
}
|
||||
```
|
||||
- Return ONLY the JSON object. Do NOT include any explanation, logging, or extra output.
|
||||
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue