mirror of
https://github.com/hackertron/LucidLoanMachine.git
synced 2026-01-09 04:28:03 -05:00
front desk agent added, that give response in json
This commit is contained in:
11
OAI_CONFIG_LIST.json
Normal file
11
OAI_CONFIG_LIST.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"api_key": "api-key-here"
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"api_key": "api-key-here"
|
||||
}
|
||||
]
|
||||
|
||||
62
download_verify_email.py
Normal file
62
download_verify_email.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import PyPDF2
|
||||
import requests
|
||||
import hashlib
|
||||
import io
|
||||
def verify_bank_pdf(pdf_url):
|
||||
"""
|
||||
Download a PDF from a given URL and perform basic integrity checks.
|
||||
|
||||
Args:
|
||||
pdf_url (str): The URL of the PDF file to download and verify.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing verification results.
|
||||
"""
|
||||
try:
|
||||
# Download the PDF
|
||||
response = requests.get(pdf_url)
|
||||
if response.status_code != 200:
|
||||
return {"success": False, "message": f"Failed to download PDF. Status code: {response.status_code}"}
|
||||
|
||||
pdf_content = response.content
|
||||
|
||||
# Calculate MD5 hash of the PDF
|
||||
md5_hash = hashlib.md5(pdf_content).hexdigest()
|
||||
|
||||
# Read the PDF
|
||||
pdf_reader = PyPDF2.PdfReader(io.BytesIO(pdf_content))
|
||||
|
||||
# Extract metadata
|
||||
metadata = pdf_reader.metadata
|
||||
|
||||
# Check if the PDF is encrypted
|
||||
is_encrypted = pdf_reader.is_encrypted
|
||||
|
||||
# Get the number of pages
|
||||
num_pages = len(pdf_reader.pages)
|
||||
|
||||
# Check for digital signatures (this is a basic check and may not catch all types of signatures)
|
||||
has_signature = '/Sig' in pdf_reader.trailer['/Root'].get('/AcroForm', {}).get('/Fields', {})
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"md5_hash": md5_hash,
|
||||
"is_encrypted": is_encrypted,
|
||||
"num_pages": num_pages,
|
||||
"has_signature": has_signature,
|
||||
"metadata": {
|
||||
"author": metadata.get('/Author', 'N/A'),
|
||||
"creator": metadata.get('/Creator', 'N/A'),
|
||||
"producer": metadata.get('/Producer', 'N/A'),
|
||||
"subject": metadata.get('/Subject', 'N/A'),
|
||||
"title": metadata.get('/Title', 'N/A'),
|
||||
"creation_date": metadata.get('/CreationDate', 'N/A'),
|
||||
"modification_date": metadata.get('/ModDate', 'N/A')
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
return {"success": False, "message": f"An error occurred: {str(e)}"}
|
||||
|
||||
# Example usage
|
||||
# result = verify_bank_pdf("https://example.com/bank_statement.pdf")
|
||||
# print(result)
|
||||
34
main.py
34
main.py
@@ -5,39 +5,55 @@ from dotenv import load_dotenv
|
||||
load_dotenv() # take environment variables from .env.
|
||||
config_list = [
|
||||
{
|
||||
'model': 'gpt-3.5-turbo-16k',
|
||||
'model': 'gpt-3.5-turbo',
|
||||
'api_key': os.getenv('OPENAI_API_KEY'),
|
||||
}
|
||||
]
|
||||
|
||||
llm_config = {
|
||||
"timeout": 300,
|
||||
"timeout": 120,
|
||||
"seed": 42, # for caching. once task is run it caches the response,
|
||||
"config_list": config_list,
|
||||
"temperature": 0 #lower temperature more standard lesss creative response, higher is more creative
|
||||
|
||||
}
|
||||
|
||||
assistant = autogen.AssistantAgent(
|
||||
name="laon_assistant",
|
||||
front_desk_assistant = autogen.AssistantAgent(
|
||||
name="front_desk_assistant",
|
||||
llm_config=llm_config,
|
||||
system_message="checks the bank documents. extract pdf using extract_pdf_skill.",
|
||||
system_message="""You have a personality of monopoly banker. You have to ask questions and collect information from user
|
||||
Questions that you have to ask : What is your name, How much do you want to borrow, What country do you live in,
|
||||
What bank do you use, Do you have a job/proof of income, Do you have any history of not paying back loans?
|
||||
once you collect all these answers, create a json response with following key
|
||||
{"first_name" : "", last_name: "", "country" : "", "bank" : "", "income" : "", "history" : "", loan_amount : ""}
|
||||
Ask user for confirmation that the details are right and want to proceed with it. Show the response in json format and save it to a file
|
||||
""",
|
||||
)
|
||||
|
||||
# assistant = autogen.AssistantAgent(
|
||||
# name="laon_assistant",
|
||||
# llm_config=llm_config,
|
||||
# system_message="checks the bank documents. extract pdf using extract_pdf_skill.",
|
||||
# )
|
||||
|
||||
user_proxy = autogen.UserProxyAgent(
|
||||
name="user_proxy",
|
||||
human_input_mode="TERMINATE",
|
||||
human_input_mode="ALWAYS",
|
||||
max_consecutive_auto_reply=3,
|
||||
is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"),
|
||||
code_execution_config={"work_dir": "web"},
|
||||
code_execution_config={
|
||||
"last_n_messages": 3,
|
||||
"work_dir": "code",
|
||||
"use_docker": False,
|
||||
},
|
||||
llm_config=llm_config,
|
||||
system_message="""Reply TERMINATE if the task has been solved at full satisfaction
|
||||
otherwise, reply CONTINUE, or the reason why the task is not solved yet."""
|
||||
)
|
||||
|
||||
def main():
|
||||
task = """"""
|
||||
user_proxy.initiate_chat(assistant, message=task)
|
||||
# task = """"""
|
||||
user_proxy.initiate_chat(front_desk_assistant, message="I want to apply for a loan, please help me")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user