grantforge-api / backend /agents /document_gap_analyzer.py
GrantForge Bot
Deploy to Hugging Face
afd56bc
from typing import Dict, Any
from langchain_core.messages import AIMessage
from core.llm_router import get_llm
from schemas import AgentState
def document_gap_analyzer_node(state: AgentState) -> Dict[str, Any]:
"""
Analizuje za艂膮czniki i profil, by precyzyjnie wykaza膰 braki we frameworku dotacyjnym
Zwraca list臋 brak贸w, np. brak KPI, brak wska藕nik贸w ROI itp.
"""
llm = get_llm(task_type="standard")
# Simple simulation check
if state.profile and state.profile.financials:
prompt_context = f"Dane finansowe podane: {state.profile.financials}"
else:
prompt_context = "Brak danych finansowych w systemie."
prompt = f"""
Jeste艣 Document Gap Analyzerem. Sp贸jrz na zebrane dane o firmie i odpowiedz czego dok艂adnie brakuje,
aby wniosek dotacyjny zyska艂 wysokie szanse.
Zwr贸膰 odpowied藕 w li艣cie wypunktowanej. PISZ ZAWSZE I WY艁膭CZNIE W J臉ZYKU POLSKIM.
Kontekst:
{prompt_context}
"""
response = llm.invoke(prompt)
from core.utils import safe_extract_text
gap_result = safe_extract_text(response.content)
return {
"messages": [
AIMessage(
content=f"[GAP ANALYZER] Znalaz艂em nast臋puj膮ce braki:\n{gap_result}"
)
],
"current_agent": "supervisor",
}