Spaces:
Sleeping
Sleeping
Update irpr/main.py
Browse files- irpr/main.py +9 -5
irpr/main.py
CHANGED
|
@@ -1,10 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException, Response
|
| 2 |
from irpr.models import IngestRequest, GenerateRequest
|
| 3 |
-
from rag.ingest import ingest_edinet_for_company, download_edinet_pdf
|
| 4 |
-
from generators.summary import make_summary
|
| 5 |
-
from generators.qa import make_qa
|
| 6 |
-
from export.ppt import build_deck, save_pptx
|
| 7 |
-
from export.qa_csv import save_qa_csv
|
| 8 |
|
| 9 |
app = FastAPI(title="IR/PR Co-Pilot Pro", version="0.1.0")
|
| 10 |
|
|
@@ -14,11 +9,19 @@ def root():
|
|
| 14 |
|
| 15 |
@app.post("/ingest/edinet")
|
| 16 |
def ingest_edinet(req: IngestRequest):
|
|
|
|
|
|
|
| 17 |
n = ingest_edinet_for_company(req.edinet_code, req.date)
|
| 18 |
return {"ingested_chunks": n}
|
| 19 |
|
| 20 |
@app.post("/generate/all")
|
| 21 |
def generate_all(req: GenerateRequest):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
summary_text, links = make_summary(req.query)
|
| 23 |
sections = {
|
| 24 |
"highlights": _extract_section(summary_text, "業績ハイライト"),
|
|
@@ -45,6 +48,7 @@ def _extract_section(text: str, head: str):
|
|
| 45 |
def proxy_edinet(doc_id: str, type: str = "pdf"):
|
| 46 |
if type != "pdf":
|
| 47 |
raise HTTPException(400, "unsupported type")
|
|
|
|
| 48 |
from rag.ingest import download_edinet_pdf
|
| 49 |
pdf = download_edinet_pdf(doc_id)
|
| 50 |
if not pdf:
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException, Response
|
| 2 |
from irpr.models import IngestRequest, GenerateRequest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI(title="IR/PR Co-Pilot Pro", version="0.1.0")
|
| 5 |
|
|
|
|
| 9 |
|
| 10 |
@app.post("/ingest/edinet")
|
| 11 |
def ingest_edinet(req: IngestRequest):
|
| 12 |
+
# ← ここで初めて読み込む(起動時に重い依存を踏まない)
|
| 13 |
+
from rag.ingest import ingest_edinet_for_company
|
| 14 |
n = ingest_edinet_for_company(req.edinet_code, req.date)
|
| 15 |
return {"ingested_chunks": n}
|
| 16 |
|
| 17 |
@app.post("/generate/all")
|
| 18 |
def generate_all(req: GenerateRequest):
|
| 19 |
+
# 必要なものだけ都度 import(遅延)
|
| 20 |
+
from generators.summary import make_summary
|
| 21 |
+
from generators.qa import make_qa
|
| 22 |
+
from export.ppt import build_deck, save_pptx
|
| 23 |
+
from export.qa_csv import save_qa_csv
|
| 24 |
+
|
| 25 |
summary_text, links = make_summary(req.query)
|
| 26 |
sections = {
|
| 27 |
"highlights": _extract_section(summary_text, "業績ハイライト"),
|
|
|
|
| 48 |
def proxy_edinet(doc_id: str, type: str = "pdf"):
|
| 49 |
if type != "pdf":
|
| 50 |
raise HTTPException(400, "unsupported type")
|
| 51 |
+
# ここも遅延
|
| 52 |
from rag.ingest import download_edinet_pdf
|
| 53 |
pdf = download_edinet_pdf(doc_id)
|
| 54 |
if not pdf:
|