mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes Adds storage in the database for full document content alongside the RAG content (and changes the service to `DocumentService` instead of `RagService`). Then adds a generic capability that should be usable by any agent (currently just used by the Question Agent) which allows the agent to pull out the full contents of the doc, chunks it into various sections that will fit in the context window, and then processes them in parallel to create an intermediate result, and then processes the intermediate result into a final answer. It will re-chunk as many times as necessary to get the content small enough for the actual answer to be analysed (I've tested on PDFs ~3500 pages long, which is well above the context limit and requires maybe 3 rounds of compression to get an answer). The new full doc analysis stuff is heavier than the RAG lookup so both remain. The agents should use RAG for targeted info and the chunked reasoner for info that requires reading the full doc.
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from fastapi import Request
|
|
|
|
from stirling.agents import (
|
|
ExecutionPlanningAgent,
|
|
OrchestratorAgent,
|
|
PdfEditAgent,
|
|
PdfQuestionAgent,
|
|
UserSpecAgent,
|
|
)
|
|
from stirling.agents.ledger import MathAuditorAgent
|
|
from stirling.agents.pdf_comment import PdfCommentAgent
|
|
from stirling.documents import DocumentService
|
|
from stirling.services import AppRuntime
|
|
|
|
|
|
def get_runtime(request: Request) -> AppRuntime:
|
|
return request.app.state.runtime
|
|
|
|
|
|
def get_orchestrator_agent(request: Request) -> OrchestratorAgent:
|
|
return request.app.state.orchestrator_agent
|
|
|
|
|
|
def get_pdf_edit_agent(request: Request) -> PdfEditAgent:
|
|
return request.app.state.pdf_edit_agent
|
|
|
|
|
|
def get_pdf_question_agent(request: Request) -> PdfQuestionAgent:
|
|
return request.app.state.pdf_question_agent
|
|
|
|
|
|
def get_user_spec_agent(request: Request) -> UserSpecAgent:
|
|
return request.app.state.user_spec_agent
|
|
|
|
|
|
def get_execution_planning_agent(request: Request) -> ExecutionPlanningAgent:
|
|
return request.app.state.execution_planning_agent
|
|
|
|
|
|
def get_document_service(request: Request) -> DocumentService:
|
|
return request.app.state.runtime.documents
|
|
|
|
|
|
def get_math_auditor_agent(request: Request) -> MathAuditorAgent:
|
|
return request.app.state.math_auditor_agent
|
|
|
|
|
|
def get_pdf_comment_agent(request: Request) -> PdfCommentAgent:
|
|
return request.app.state.pdf_comment_agent
|