mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-08-07 12:07:43 +00:00
fix: fix quick start problem (#191)
* all update code * fix a small bug
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user