Skip to content

Commit

Permalink
fix: fix quick start problem (#191)
Browse files Browse the repository at this point in the history
* all update code

* fix a small bug
  • Loading branch information
peteryang1 authored Aug 9, 2024
1 parent 0ed585f commit 44f61bf
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 93 deletions.
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -205,5 +193,5 @@ Making contributions is not a hard thing. Solving an issue(maybe just answering

<a href="https://github.com/microsoft/RD-Agent/graphs/contributors"><img src="https://contrib.rocks/image?repo=microsoft/RD-Agent&max=240&columns=18" /></a>

# 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
<p style="line-height: 1; font-style: italic;">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.</p>
14 changes: 0 additions & 14 deletions docs/scens/data_agent_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions docs/scens/data_copilot_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions docs/scens/model_agent_fin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions docs/scens/model_copilot_general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 0 additions & 14 deletions rdagent/app/benchmark/model/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 9 additions & 3 deletions rdagent/app/qlib_rd_loop/factor_from_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions rdagent/components/document_reader/document_reader.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions rdagent/oai/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ def __init__(self) -> None:
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:
Expand Down

0 comments on commit 44f61bf

Please sign in to comment.