system-prompts-and-models-o.../task/tester.py
2026-06-18 21:23:01 +05:30

244 lines
13 KiB
Python

DOCUMENT_CLASSIFY_PROMPT = """
You are an expert in document classification where you are given a document under <document> xml tags and you need to classify it based on the data inside <document-type> xml tag.
Your output should be enclosed inside <output> xml tag and it should be based on one of the <document-type> options mentioned below.Just output <document-type> in the output <output> xml tag.
### Document
<document>
{document}
</document>
###
## Document Types that need to classified.
<document-type>
["LPA(Limited Partner Agreement)", "LPA-Amendment(Limited Partner Agreement-Amendment)", "Side Letter"]
</document-type>
"""
LPA_STATEMENT_PROMPT = """
<SYSTEM>
You are an expert in LPA (Limited Partner Agreement) data extraction that uses a Chain of Thought (CoT) approach with reflection to answer queries. Follow these steps:
1. Think through the problem step by step within the <thinking> tags.
2. Reflect on your thinking to check for any errors or improvements within the <reflection> tags.
3. Make any necessary adjustments based on your reflection.
4. Provide your final, concise answer within the <output> tags.
Important: The <thinking> and <reflection> sections are for your internal reasoning process only.
Do not include any part of the final answer in these sections and never make assumptions.
The actual response to the query must be entirely contained within the <output> tags.
Use the following format for your response:
<thinking>
[Your step-by-step reasoning goes here. This is your internal thought process, not the final answer. Please explain the reason for selecting each piece of information.]
</thinking>
<reflection>
[Your reflection on your reasoning, checking for errors or improvements]
</reflection>
<output>
[Your final, concise answer to the query in the specified JSON format. This is the only part that will be shown to the user.]
</output>
</SYSTEM>
<USER>
You are given data in the <document> xml tag. First, get a very good understanding of the document and extract data related to the fields described below by understanding the fields based on the description.
### Document
<document>
{document}
</document>
Final output to place under <output> xml tag and populate empty values if the data is not present in the document.
<output-format>
{{
"fundName": "name of the fund",
"fileInfo":"name of the fund and under which type of the document is it - Date of the agreement"
"managementFee": "Extract the following information from the document:
1. Annual management fee percentage(s), including any changes over time
2. Fund start date which you can find in the first page of the document: (YYYY-MM-DD)
3. Fund end date: (YYYY-MM-DD)
Using this extracted information, create a Python structure with the following elements:
1. fund_start_date: A string representing the fund start date in 'YYYY-MM-DD' format
2. fund_end_date: A string representing the fund end date in 'YYYY-MM-DD' format
3. management_fee_schedule: A list of dictionaries, where each dictionary represents a fee period with the following keys:
- 'start_date': A string in 'YYYY-MM-DD' format representing the start date of the fee period
- 'annual_management_fee_percent': A float representing the annual management fee percentage for that period
The fee_schedule should capture any changes in the management fee over the fund's lifetime.
Example output:
{{
fund_start_date = "2019-07-15"
fund_end_date = "2024-12-31"
management_fee_schedule = [
{{`start_date`: "2019-07-15", `annual_management_fee_percent`: 2.5}},
{{`start_date`: "2023-07-01", `annual_management_fee_percent`: 2.0}}
]
}},
"fundSector": "This field refers to where the fund will be invested, like sectors etc.",
"fundRegisteredOffice": "The address location of the office",
"fundClosingDate": "This field should be populated with the timeframe within which LPs should join based on the general partner's call",( give me year or quarter details)
"fundsToInvestDays": "Extract the number of days within which the General Partner must return capital contributions for unconsummated investments to the Partners. Please provide only the numerical value?",
"lateEntryFee": "What is the extra fee that a Limited Partner must pay to join the VC after the closing date?",
"lateEntryFeeAllocation": "What will be done with the lateEntryFee received from new Limited Partners?",
"capitalThreshold": "What is the capital threshold that a limited partner can make a single call ?",
"capitalContributionDays": "Within how many days the Limited Partner should contribute capital to the partnership as requested by the General Partner?((Captial contribution)",
"erisaLimit": "What percentage of capital contribution should the VC get from ERISA partners out of their total fund?",
"capitalContributionOfGP": "What is the capital contribution percentage of the General Partner to partnership capital?",
"profitAllocationToGP": "What is the percentage of profit that will be allocated to the General Partner?", # just give me the percentage value
"limitedPartnerContributionAfterDistrubtion":"Identify and extract any clauses or sections that describe limitations on the return of distributions to partners in a partnership agreement. Specifically, look for:
1. The maximum amount partners may be required to return
2. Any percentage limitations based on initial investments or capital commitments
3. Distinctions between different types of partners (e.g., Limited Partners vs. General Partners)
4. Time limits for requesting the return of distributions
5. Conditions under which distributions may be recalled
6. Any formulas or calculations used to determine the amount to be returned
Please provide the exact text of relevant clauses along with a brief explanation of each limitation found"
"managementFeeCompensation": "How often will the management fee be compensated?",
"managementFeeReductionTimeFrame": "Within what timeframe will there be a reduction of the management fee?",
"reducedManagementFee": "What is the new management fee percentage for the quarter after the reduction date?",
"timeFrameReducedManagementFee": "How often will there be a decrease in the management fee after hitting the management fee reduction timeframe?",# timeframe
"floorValueOfManagementFee": "What is the floor value of the management fee after annual management fee reduction?",
"partnershipExtension": "For how many years can a General Partner extend the partnership upon the partnership end date?",
"partnershipExtensionAdditional": "For how many additional years can the General Partner extend after the initial partnership extension?",
"Management Expenses":"Extract complete information in any clauses or sections that describe about the expenses related to management and there limitations and i want the section as well",
"Fund/Partnership Expenses": "Extract complete information in any clauses or sections that describe about the expenses related to Fund/Partnership and there limitations and i want the section as well",
"OnetimeOrganizationExpenses":"Extract complete information in any clauses or sections that describe about the expenses related to OnetimeOrganization and there limitations and i want the section as well"
}}
</output-format>
</user>
"""
SIDE_LETTER_PROMPT = """
You are given side letter document related to a limited partner under <document> xml tag.
First get a very good understanding of the below document under <document> xml tag . Your task is to generate the response in below format <output-format> in <output> xml tags and partner id related to the partner to be written to <id>
## Document
<document>
{document}
</document>
## partner id document
<partner-id-document>
{role_doc}
</partner-id-document>
<output-format>
{{
"fundName":"Name of the fund",
"fundDate":"Limited Partner Agreement date in format : YYYY-MM-DD",
"partnerName":"Name of the investing partner",
"quarter":"",
"platform":"Name of the platform which generated the report,if you are not sure return empty",
"carriedInterest": " <case:1> : If there is a change in carried interest then execute below one
Just give me the percentage value of profit/carry interest that will be allocated to the General Partner.
else
<case:2>: Just return `No changes` ",
"managementFee": "
<case:1> : If there is a changing in management fee structure execute below one
Extract the following information from the document:
1. Annual management fee percentage(s), including any changes over time
2. Fund start date which you can find in the first page of the document: (YYYY-MM-DD)
3. Fund end date: which you have to create based on the understanding you got from the document : (YYYY-MM-DD)
Using this extracted information, create a Python structure with the following elements:
1. fund_start_date: A string representing the fund start date in 'YYYY-MM-DD' format
2. fund_end_date: A string representing the fund end date in 'YYYY-MM-DD' format
3. management_fee_schedule: A list of dictionaries, where each dictionary represents a fee period with the following keys:
- 'start_date': A string in 'YYYY-MM-DD' format representing the start date of the fee period
- 'annual_management_fee_percent': A float representing the annual management fee percentage for that period
The fee_schedule should capture any changes in the management fee over the fund's lifetime.
Example output:
{{
fund_start_date = "2019-07-15"
fund_end_date = "2024-12-31"
management_fee_schedule = [
{{`start_date`: "2019-07-15", `annual_management_fee_percent`: 2.5}},
{{`start_date`: "2023-07-01", `annual_management_fee_percent`: 2.0}}
]
}}
else
<case:2> :Just return `No changes` ",
"sideLetterKeyPoints": "Extract key details in the document, Just return it in a string",
}}
</output-format>
<id>
"Extract value related to partner id name from <role-document> document"
</id>
"""
import pdfplumber
with pdfplumber.open('Side_letter_Greylock Partners_062723.pdf') as pdf:
list_pages = []
for page in pdf.pages:
text = page.extract_text()
if text:
list_pages.append(text.strip())
pdf_string = "".join(list_pages)
data_string = """"data": [
{
"label": "FIN CAP INVEST LLC",
"value": "66fbfbd920655b335e6d1ccc"
},
{
"label": "Avinash",
"value": "6740785c268e6da0e1c746e6"
},
{
"label": "CODY HEALTHCARE S CORP",
"value": "66fbfbd820655b335e6d1ca8"
},
{
"label": "Enterprise International, Inc.",
"value": "66fbfbd820655b335e6d1cc0"
},
{
"label": "Pradeepp Kukunuri",
"value": "66fbfbc6f78cfc9f3cafb51c"
},
{
"label": "Shresth",
"value": "672dd65e6844833570e5b0e2"
},
{
"label": "Support",
"value": "672dd6376844833570e5b0be"
},
{
"label": "Greylock Partners",
"value": "66fbfbd820655b335e6d1cb4"
}
]"""
from llm_bedrock import model
import re
output = model.invoke(SIDE_LETTER_PROMPT.format(document=pdf_string,role_doc=data_string)).content
pattern = r'<output>(.*?)</output>'
match = re.search(pattern, output, re.DOTALL)
print(match.group(1).strip())
id = r'<id>(.*?)</id>'
match = re.search(id,output,re.DOTALL)
print(match.group(1).strip())
print(match)