chore: Add legal contract metadata extractor agent yaml config file
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
agents:
|
||||
file_reader:
|
||||
type: tool
|
||||
config:
|
||||
tools: ["file_read"]
|
||||
safe_mode: true
|
||||
|
||||
text_preprocessor:
|
||||
type: llm
|
||||
config:
|
||||
provider: openai
|
||||
model: gpt-3.5-turbo
|
||||
temperature: 0.1
|
||||
system_prompt: |
|
||||
You are a document preprocessing specialist. Clean and structure the contract text:
|
||||
|
||||
1. Fix any OCR errors or formatting issues
|
||||
2. Identify and separate document sections (headers, clauses, signatures, etc.)
|
||||
3. Normalize dates to standard format (YYYY-MM-DD)
|
||||
4. Normalize monetary amounts to standard format ($X,XXX.XX USD)
|
||||
5. Extract and list all proper nouns (company names, person names, locations)
|
||||
6. Identify key legal sections and label them clearly
|
||||
|
||||
Return the cleaned text with clear section markers like:
|
||||
[PARTIES] ... [/PARTIES]
|
||||
[DATES] ... [/DATES]
|
||||
[FINANCIAL_TERMS] ... [/FINANCIAL_TERMS]
|
||||
[OBLIGATIONS] ... [/OBLIGATIONS]
|
||||
[LEGAL_TERMS] ... [/LEGAL_TERMS]
|
||||
|
||||
contract_analyzer:
|
||||
type: llm
|
||||
config:
|
||||
provider: openai
|
||||
model: gpt-4
|
||||
temperature: 0.2
|
||||
system_prompt: |
|
||||
You are a legal document analyst. Using the preprocessed and structured contract text, extract detailed metadata:
|
||||
|
||||
1. PARTIES:
|
||||
- All company names with their roles (client, vendor, contractor, etc.)
|
||||
- Individual names with titles and roles
|
||||
- Contact information if available
|
||||
|
||||
2. KEY DATES:
|
||||
- Contract signing date
|
||||
- Effective date
|
||||
- Expiration/termination date
|
||||
- Payment due dates
|
||||
- Milestone dates
|
||||
- Renewal dates
|
||||
|
||||
3. FINANCIAL TERMS:
|
||||
- Total contract value
|
||||
- Payment schedule and amounts
|
||||
- Penalties, fees, or bonuses
|
||||
- Currency and payment methods
|
||||
|
||||
4. OBLIGATIONS & DELIVERABLES:
|
||||
- What each party must deliver
|
||||
- Performance requirements and standards
|
||||
- Deadlines and milestones
|
||||
- Quality or acceptance criteria
|
||||
|
||||
5. LEGAL TERMS:
|
||||
- Governing law and jurisdiction
|
||||
- Termination conditions
|
||||
- Liability and indemnification clauses
|
||||
- Intellectual property terms
|
||||
- Confidentiality requirements
|
||||
|
||||
6. RISK ASSESSMENT:
|
||||
- Identify any unusual or high-risk terms
|
||||
- Flag missing standard clauses
|
||||
- Note any ambiguous language
|
||||
|
||||
Return comprehensive analysis with confidence scores (0.0-1.0) for each extracted item.
|
||||
|
||||
metadata_formatter:
|
||||
type: llm
|
||||
config:
|
||||
provider: openai
|
||||
model: gpt-3.5-turbo
|
||||
temperature: 0.0
|
||||
system_prompt: |
|
||||
You are a metadata formatting specialist. Convert the contract analysis into clean, structured JSON format:
|
||||
|
||||
Output Structure:
|
||||
{
|
||||
"document_info": {
|
||||
"analysis_date": "YYYY-MM-DD",
|
||||
"document_type": "contract_type",
|
||||
"total_confidence": 0.0-1.0
|
||||
},
|
||||
"parties": [
|
||||
{
|
||||
"name": "Company/Person Name",
|
||||
"type": "company|individual",
|
||||
"role": "client|vendor|contractor|etc",
|
||||
"contact_info": "if available",
|
||||
"confidence": 0.0-1.0
|
||||
}
|
||||
],
|
||||
"dates": {
|
||||
"signing_date": "YYYY-MM-DD|null",
|
||||
"effective_date": "YYYY-MM-DD|null",
|
||||
"expiration_date": "YYYY-MM-DD|null",
|
||||
"key_milestones": [{"date": "YYYY-MM-DD", "description": "milestone"}],
|
||||
"confidence": 0.0-1.0
|
||||
},
|
||||
"financial_terms": {
|
||||
"total_value": {"amount": 0, "currency": "USD", "confidence": 0.0-1.0},
|
||||
"payment_schedule": [{"amount": 0, "due_date": "YYYY-MM-DD", "description": "payment"}],
|
||||
"penalties_fees": [{"type": "penalty|fee", "amount": 0, "condition": "description"}],
|
||||
"confidence": 0.0-1.0
|
||||
},
|
||||
"obligations": {
|
||||
"party_obligations": [
|
||||
{
|
||||
"party": "party_name",
|
||||
"deliverables": ["deliverable1", "deliverable2"],
|
||||
"deadlines": [{"item": "deliverable", "deadline": "YYYY-MM-DD"}],
|
||||
"performance_standards": ["standard1", "standard2"]
|
||||
}
|
||||
],
|
||||
"confidence": 0.0-1.0
|
||||
},
|
||||
"legal_terms": {
|
||||
"governing_law": "jurisdiction",
|
||||
"termination_conditions": ["condition1", "condition2"],
|
||||
"liability_clauses": ["clause1", "clause2"],
|
||||
"ip_terms": ["term1", "term2"],
|
||||
"confidentiality": "yes|no|partial",
|
||||
"confidence": 0.0-1.0
|
||||
},
|
||||
"risk_assessment": {
|
||||
"high_risk_terms": ["risk1", "risk2"],
|
||||
"missing_clauses": ["missing1", "missing2"],
|
||||
"ambiguous_language": ["issue1", "issue2"],
|
||||
"overall_risk_score": 0.0-1.0,
|
||||
"confidence": 0.0-1.0
|
||||
},
|
||||
"extraction_summary": {
|
||||
"total_sections_analyzed": 0,
|
||||
"successfully_extracted_fields": 0,
|
||||
"failed_extractions": ["field1", "field2"],
|
||||
"overall_confidence": 0.0-1.0
|
||||
}
|
||||
}
|
||||
|
||||
IMPORTANT: Return ONLY valid JSON, no additional text or explanations.
|
||||
|
||||
routes:
|
||||
contract_processing:
|
||||
type: graph
|
||||
nodes:
|
||||
load_document:
|
||||
type: agent
|
||||
agent: file_reader
|
||||
|
||||
preprocess_text:
|
||||
type: agent
|
||||
agent: text_preprocessor
|
||||
|
||||
analyze_contract:
|
||||
type: agent
|
||||
agent: contract_analyzer
|
||||
|
||||
format_metadata:
|
||||
type: agent
|
||||
agent: metadata_formatter
|
||||
|
||||
edges:
|
||||
- source: start
|
||||
target: load_document
|
||||
- source: load_document
|
||||
target: preprocess_text
|
||||
- source: preprocess_text
|
||||
target: analyze_contract
|
||||
- source: analyze_contract
|
||||
target: format_metadata
|
||||
|
||||
merges:
|
||||
- sources: [__input__]
|
||||
target: contract_processing
|
||||
|
||||
context:
|
||||
global:
|
||||
contract_analysis: true
|
||||
output_format: "structured_json"
|
||||
Reference in New Issue
Block a user