This commit includes the following changes as part of an ongoing effort to migrate the project from OpenAI models and SDKs to Google's Gemini:
1. **Updated `requirements.txt`**:
* Removed `langchain-openai` and `openai`.
* Added `langchain-google-genai` and `google-generativeai`.
2. **Modified `tradingagents/agents/utils/agent_utils.py`**:
* Replaced the import of `ChatOpenAI` from `langchain_openai` with `ChatGoogleGenerativeAI` from `langchain_google_genai`.
* Updated tool function names (e.g., `get_stock_news_openai` to `get_stock_news_gemini`) and their internal calls to `interface` methods to reflect changes in `interface.py`.
3. **Refactored `tradingagents/dataflows/interface.py`**:
* Removed direct usage of the `openai` package.
* Added `google.generativeai` for direct Gemini API calls.
* Configured Gemini API key handling via the `GEMINI_API_KEY` environment variable.
* Rewrote `get_stock_news_openai`, `get_global_news_openai`, and `get_fundamentals_openai` to use `gemini-pro` via `genai.GenerativeModel`. These functions were renamed to `_gemini` equivalents (e.g., `get_stock_news_gemini`).
* Removed the `web_search_preview` function as it's not directly available in the `google-generativeai` SDK in the same way.
**Work In Progress / Next Steps:**
The migration is not yet complete. Your feedback indicated that many files still contain the "openai" keyword, which would need to be addressed. Key remaining tasks before this migration can be considered complete include:
* **Locating and updating main Langchain LLM instantiations**: The `ChatOpenAI` models (e.g., `quick_thinking_llm`, `deep_thinking_llm` passed to `GraphSetup`) are instantiated outside of the files modified so far. These instantiations need to be found (likely in `main.py` or `cli/main.py`) and changed to `ChatGoogleGenerativeAI`.
* **Updating all type hints**: Type hints for `ChatOpenAI` need to be changed to `ChatGoogleGenerativeAI` in `tradingagents/graph/setup.py` and throughout all agent creation functions and their usages in `tradingagents/agents/`.
* **Addressing all remaining "openai" keywords**: A global search for "openai" should be performed to identify and address any remaining occurrences in comments, documentation, or other utility functions throughout the project.
* **Thorough testing**: Once all code changes are made, comprehensive testing (unit, integration, manual) will be required.
I was in the process of identifying the central LLM instantiation points when the work was submitted.