Spaces:
Running
Running
Charles Grandjean commited on
Commit ·
4548589
1
Parent(s): 298e92e
ah oui eux ils fallaient qu ils changent la parallelisation de snoeuds cetait essentiel!
Browse files- agents/pdf_analyzer.py +9 -7
agents/pdf_analyzer.py
CHANGED
|
@@ -3,15 +3,11 @@
|
|
| 3 |
PDF Analysis Agent - Extracts and analyzes legal documents from PDF files
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
import os
|
| 7 |
import logging
|
| 8 |
import pypdf
|
| 9 |
-
import httpx
|
| 10 |
-
import re
|
| 11 |
import asyncio
|
| 12 |
-
from typing import Optional
|
| 13 |
from langgraph.graph import StateGraph, END
|
| 14 |
-
from langchain_openai import ChatOpenAI
|
| 15 |
from langchain_core.messages import HumanMessage, SystemMessage
|
| 16 |
from mistralai import Mistral
|
| 17 |
|
|
@@ -46,9 +42,15 @@ class PDFAnalyzerAgent:
|
|
| 46 |
{"ocr": "ocr_pdf", "extract": "extract_content"}
|
| 47 |
)
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
workflow.add_edge("extract_actors", END)
|
| 54 |
workflow.add_edge("extract_key_details", END)
|
|
|
|
| 3 |
PDF Analysis Agent - Extracts and analyzes legal documents from PDF files
|
| 4 |
"""
|
| 5 |
|
|
|
|
| 6 |
import logging
|
| 7 |
import pypdf
|
|
|
|
|
|
|
| 8 |
import asyncio
|
| 9 |
+
from typing import Optional
|
| 10 |
from langgraph.graph import StateGraph, END
|
|
|
|
| 11 |
from langchain_core.messages import HumanMessage, SystemMessage
|
| 12 |
from mistralai import Mistral
|
| 13 |
|
|
|
|
| 42 |
{"ocr": "ocr_pdf", "extract": "extract_content"}
|
| 43 |
)
|
| 44 |
|
| 45 |
+
# OCR branch - parallel execution to all three analysis nodes
|
| 46 |
+
workflow.add_edge("ocr_pdf", "extract_actors")
|
| 47 |
+
workflow.add_edge("ocr_pdf", "extract_key_details")
|
| 48 |
+
workflow.add_edge("ocr_pdf", "generate_summary")
|
| 49 |
|
| 50 |
+
# Extract content branch - parallel execution to all three analysis nodes
|
| 51 |
+
workflow.add_edge("extract_content", "extract_actors")
|
| 52 |
+
workflow.add_edge("extract_content", "extract_key_details")
|
| 53 |
+
workflow.add_edge("extract_content", "generate_summary")
|
| 54 |
|
| 55 |
workflow.add_edge("extract_actors", END)
|
| 56 |
workflow.add_edge("extract_key_details", END)
|