diff --git a/README.md b/README.md index 43cc21ef..f20f0171 100644 --- a/README.md +++ b/README.md @@ -63,31 +63,19 @@ TODO: `pip install rdagent` in the future. make dev ``` -### πŸ“¦ Install Pytorch -TODO: use docker in quick start intead. - -- Install Pytorch and related libraries: - ```sh - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip3 install torch_geometric - ``` ### βš™οΈ Environment Configuration - Place the `.env` file in the same directory as the `.env.example` file. - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - please refer to [Configuration](docs/build/html/installation.html#azure-openai) for the detailed explanation of the `.env` -- Export each variable in the `.env` file: - ```sh - export $(grep -v '^#' .env | xargs) - ``` ### πŸš€ Run the Application TODO: run the front-page demo. -The [πŸŽ₯demo](https://rdagent.azurewebsites.net) is implemented by the above commands. +The [πŸŽ₯demo](https://rdagent.azurewebsites.net) is implemented by the following commands: - Run the factor extraction and implementation application based on financial reports: ```sh - python rdagent/app/qlib_rd_loop/factor_from_report_sh.py + rdagent fin_factor_report ``` - Run the self-loop factor extraction and implementation application: @@ -205,5 +193,5 @@ Making contributions is not a hard thing. Solving an issue(maybe just answering -# Disclaimer -The RD-agent is provided β€œas is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. The RD-agent is aimed to facilitate research and development process in the financial industry and not ready-to-use for any financial investment or advice. Users shall independently assess and test the risks of the RD-agent in a specific use scenario, ensure the responsible use of AI technology, including but not limited to developing and integrating risk mitigation measures, and comply with all applicable laws and regulations in all applicable jurisdictions. The RD-agent does not provide financial opinions or reflect the opinions of Microsoft, nor is it designed to replace the role of qualified financial professionals in formulating, assessing, and approving finance products. The inputs and outputs of the RD-agent belong to the users and users shall assume all liability under any theory of liability, whether in contract, torts, regulatory, negligence, products liability, or otherwise, associated with use of the RD-agent and any inputs and outputs thereof. +# Legal disclaimer +

The RD-agent is provided β€œas is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. The RD-agent is aimed to facilitate research and development process in the financial industry and not ready-to-use for any financial investment or advice. Users shall independently assess and test the risks of the RD-agent in a specific use scenario, ensure the responsible use of AI technology, including but not limited to developing and integrating risk mitigation measures, and comply with all applicable laws and regulations in all applicable jurisdictions. The RD-agent does not provide financial opinions or reflect the opinions of Microsoft, nor is it designed to replace the role of qualified financial professionals in formulating, assessing, and approving finance products. The inputs and outputs of the RD-agent belong to the users and users shall assume all liability under any theory of liability, whether in contract, torts, regulatory, negligence, products liability, or otherwise, associated with use of the RD-agent and any inputs and outputs thereof.

diff --git a/docs/scens/data_agent_fin.rst b/docs/scens/data_agent_fin.rst index fd222a49..b819f2d9 100644 --- a/docs/scens/data_agent_fin.rst +++ b/docs/scens/data_agent_fin.rst @@ -98,23 +98,9 @@ You can try our demo by running the following command: make dev -- πŸ“¦ Install Pytorch - - Install Pytorch and related libraries: - - .. code-block:: sh - - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip3 install torch_geometric - - βš™οΈ Environment Configuration - Place the `.env` file in the same directory as the `.env.example` file. - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - - - Export each variable in the .env file: - - .. code-block:: sh - - export $(grep -v '^#' .env | xargs) - If you want to change the default environment variables, you can refer to `Env Config`_ below diff --git a/docs/scens/data_copilot_fin.rst b/docs/scens/data_copilot_fin.rst index 6c14afd1..7e71c238 100644 --- a/docs/scens/data_copilot_fin.rst +++ b/docs/scens/data_copilot_fin.rst @@ -98,23 +98,9 @@ You can try our demo by running the following command: make dev -- πŸ“¦ Install Pytorch - - Install Pytorch and related libraries: - - .. code-block:: sh - - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip3 install torch_geometric - - βš™οΈ Environment Configuration - Place the `.env` file in the same directory as the `.env.example` file. - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - - - Export each variable in the .env file: - - .. code-block:: sh - - export $(grep -v '^#' .env | xargs) - If you want to change the default environment variables, you can refer to `Env Config`_ below diff --git a/docs/scens/model_agent_fin.rst b/docs/scens/model_agent_fin.rst index 1a3c103f..ef67868c 100644 --- a/docs/scens/model_agent_fin.rst +++ b/docs/scens/model_agent_fin.rst @@ -91,24 +91,10 @@ You can try our demo by running the following command: make dev -- πŸ“¦ Install Pytorch - - Install Pytorch and related libraries: - - .. code-block:: sh - - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip3 install torch_geometric - - βš™οΈ Environment Configuration - Place the `.env` file in the same directory as the `.env.example` file. - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - - Export each variable in the .env file: - - .. code-block:: sh - - export $(grep -v '^#' .env | xargs) - - πŸš€ Run the Application .. code-block:: sh diff --git a/docs/scens/model_copilot_general.rst b/docs/scens/model_copilot_general.rst index 2e1d2bae..626320b8 100644 --- a/docs/scens/model_copilot_general.rst +++ b/docs/scens/model_copilot_general.rst @@ -67,24 +67,10 @@ You can try our demo by running the following command: make dev -- πŸ“¦ Install Pytorch - - Install Pytorch and related libraries: - - .. code-block:: sh - - pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu - pip3 install torch_geometric - - βš™οΈ Environment Configuration - Place the `.env` file in the same directory as the `.env.example` file. - The `.env.example` file contains the environment variables required for users using the OpenAI API (Please note that `.env.example` is an example file. `.env` is the one that will be finally used.) - - Export each variable in the .env file: - - .. code-block:: sh - - export $(grep -v '^#' .env | xargs) - - πŸš€ Run the Application - Prepare relevant files (in pdf format) by uploading papers to the directory below and copy the path as report_file_path. diff --git a/rdagent/app/benchmark/model/README.md b/rdagent/app/benchmark/model/README.md index bcd068e0..dabb7e6d 100644 --- a/rdagent/app/benchmark/model/README.md +++ b/rdagent/app/benchmark/model/README.md @@ -1,17 +1,3 @@ - -# Preparation - -## Install Pytorch -CPU CUDA will be enough for verify the implementation - -Please install pytorch based on your system. -Here is an example on my system -```bash -pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu -pip3 install torch_geometric - -``` - # Tasks ## Task Extraction diff --git a/rdagent/app/qlib_rd_loop/factor_from_report.py b/rdagent/app/qlib_rd_loop/factor_from_report.py index b5d2c5a6..81fa8998 100644 --- a/rdagent/app/qlib_rd_loop/factor_from_report.py +++ b/rdagent/app/qlib_rd_loop/factor_from_report.py @@ -103,9 +103,15 @@ def extract_hypothesis_and_exp_from_reports(report_file_path: str) -> Tuple[Qlib class FactorReportLoop(FactorRDLoop, metaclass=LoopMeta): - def __init__(self, PROP_SETTING: FACTOR_FROM_REPORT_PROP_SETTING): - super().__init__(PROP_SETTING=PROP_SETTING) - self.judge_pdf_data_items = json.load(open(PROP_SETTING.report_result_json_file_path, "r")) + def __init__(self, report_folder: str = None): + super().__init__(PROP_SETTING=FACTOR_FROM_REPORT_PROP_SETTING) + if report_folder is None: + self.judge_pdf_data_items = json.load( + open(FACTOR_FROM_REPORT_PROP_SETTING.report_result_json_file_path, "r") + ) + else: + self.judge_pdf_data_items = Path(report_folder).rglob("*.pdf") + self.pdf_file_index = 0 self.valid_pdf_file_count = 0 self.current_loop_hypothesis = None diff --git a/rdagent/components/document_reader/document_reader.py b/rdagent/components/document_reader/document_reader.py index 258a5975..cfb06105 100644 --- a/rdagent/components/document_reader/document_reader.py +++ b/rdagent/components/document_reader/document_reader.py @@ -1,9 +1,11 @@ from __future__ import annotations +import io from pathlib import Path from typing import TYPE_CHECKING import fitz +import requests from azure.ai.formrecognizer import DocumentAnalysisClient from azure.core.credentials import AzureKeyCredential from langchain.document_loaders import ( @@ -111,8 +113,11 @@ def load_and_process_pdfs_by_azure_document_intelligence(path: Path) -> dict[str return content_dict -def extract_first_page_screenshot_from_pdf(pdf_path: Path) -> Image: - doc = fitz.open(pdf_path) +def extract_first_page_screenshot_from_pdf(pdf_path: str) -> Image: + if not Path(pdf_path).exists(): + doc = fitz.open(stream=io.BytesIO(requests.get(pdf_path).content), filetype="pdf") + else: + doc = fitz.open(pdf_path) page = doc.load_page(0) pix = page.get_pixmap() image = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) diff --git a/rdagent/oai/llm_utils.py b/rdagent/oai/llm_utils.py index c10c32d3..e149c6d4 100644 --- a/rdagent/oai/llm_utils.py +++ b/rdagent/oai/llm_utils.py @@ -155,8 +155,6 @@ class SessionChatHistoryCache(SingletonBaseClass): logger.warning(f"Directory {self.session_cache_location} does not exist.") self.session_cache_location.mkdir(parents=True, exist_ok=True) json_files = [f for f in self.session_cache_location.iterdir() if f.suffix == ".json"] - if not json_files: - logger.info(f"No JSON files found in {self.session_cache_location}.") for file_path in json_files: conversation_id = file_path.stem with file_path.open("r") as f: