Download orchestrator/agent_utils.py from luoleyuan/XHS: direct link, hf CLI and curl.
- Browser
- Download file 940 Bytes
-
https://huggingface.co/spaces/luoleyuan/XHS/resolve/main/orchestrator/agent_utils.py
- Command line
-
hf download hf://spaces/luoleyuan/XHS/orchestrator/agent_utils.py
-
curl -L -o agent_utils.py https://huggingface.co/spaces/luoleyuan/XHS/resolve/main/orchestrator/agent_utils.py
940 Bytes
| import os | |
| from langchain_openai import ChatOpenAI | |
| from browser_use import Browser | |
| from orchestrator.config import AGENT_LLM_API_KEY, AGENT_LLM_MODEL, AGENT_LLM_BASE_URL | |
| def get_llm(): | |
| """ | |
| Returns an instance of ChatOpenAI configured with environment variables. | |
| Make sure the model supports Vision capabilities. | |
| """ | |
| if not AGENT_LLM_API_KEY: | |
| raise ValueError("AGENT_LLM_API_KEY is not set. Please configure it in your environment.") | |
| return ChatOpenAI( | |
| api_key=AGENT_LLM_API_KEY, | |
| model=AGENT_LLM_MODEL, | |
| base_url=AGENT_LLM_BASE_URL, | |
| ) | |
| def get_browser_with_auth(storage_state_path: str | None = None) -> Browser: | |
| """ | |
| Creates a browser-use Browser instance. | |
| """ | |
| # Just instantiate Browser. Since v0.12, complex config is usually handled at the Agent/Context level | |
| # or by passing playwright arguments. Here we just use the default. | |
| return Browser() | |