fixes
This commit is contained in:
@@ -268,6 +268,8 @@ def get_vision_mission_extraction_from_questionnaire_executive():
|
||||
"<p>Company Goals:</p><p>1. Audit Department:<br> a. Enhance Risk Management and Internal Controls: Strengthen the organization’s risk posture by identifying, assessing, and recommending improvements to internal controls.<br> b. Ensure Regulatory and Policy Compliance: Monitor adherence to relevant laws, regulations, standards, and internal policies.<br> c. Support Organizational Governance: Provide independent assurance to senior management and the board on the effectiveness of governance processes.<br> d. Drive Operational Efficiency: Identify inefficiencies and areas for process improvement during audits.<br> e. Leverage Technology and Data Analytics: Use automated tools and analytics for continuous auditing and real-time risk monitoring.<br> f. Develop Audit Talent and Capabilities: Invest in training and upskilling for the audit team.<br> g. Enhance Stakeholder Communication: Improve reporting clarity, timeliness, and relevance to stakeholders.<br><br>2. Finance Department:<br> a. Ensure Financial Stability and Sustainability: Maintain strong cash flow and optimize working capital.<br> b. Improve Financial Planning and Analysis (FP&A): Provide accurate forecasting and budgeting to support strategic decision-making.<br> c. Enhance Cost Management and Operational Efficiency: Identify cost-saving opportunities and drive efficient use of financial resources.<br> d. Ensure Regulatory and Compliance Integrity: Maintain full compliance with financial regulations and internal controls.<br> e. Enable Strategic Investment and Capital Allocation: Evaluate and fund initiatives that align with the organization’s long-term growth strategy.<br> f. Improve Financial Reporting and Transparency: Deliver timely and accurate financial reports for stakeholders.<br> g. Leverage Financial Technology and Automation: Implement tools to streamline financial operations.<br> h. Develop Finance Talent and Leadership: Upskill finance staff and promote cross-functional knowledge.<br><br>3. Account Department:<br> a. Maintain Accurate and Timely Financial Records: Ensure all transactions are recorded properly.<br> b. Ensure Regulatory and Tax Compliance: Comply with all financial regulations and timely tax filings.<br> c. Streamline Month-End and Year-End Closing Processes: Reduce the time and complexity of closing periods.<br> d. Support Strategic Financial Planning: Provide reliable data for budgeting and forecasting.<br> e. Implement Automation and Digital Tools: Use accounting software and RPA to increase efficiency.<br> f. Strengthen Internal Controls and Risk Management: Ensure robust controls over financial transactions.<br> g. Improve Financial Transparency and Reporting Quality: Produce clear and consistent reports for stakeholders.<br> h. Develop Accounting Team Skills and Expertise: Provide continuous learning and leadership development for accounting staff.<br></p>"
|
||||
],
|
||||
|
||||
"vision": "To create safe, broadly beneficial AI systems that ensure the advantages of artificial general intelligence (AGI) are shared equitably across society. Our vision emphasizes the importance of safety and alignment, ensuring that AI systems align with human values and remain under human control. We aspire to collaborate with other research and policy institutions to address global challenges associated with advanced AI, prioritizing the safe development of increasingly capable systems that act in the best interests of humanity.",
|
||||
|
||||
"department_goals": [
|
||||
{
|
||||
"department": "Account Management",
|
||||
|
||||
@@ -1,32 +1,45 @@
|
||||
import os
|
||||
from spire.doc import Document, FileFormat
|
||||
from langchain_community.document_loaders import PyPDFLoader
|
||||
from docx import Document as DocxDocument
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
|
||||
from reportlab.lib.styles import getSampleStyleSheet
|
||||
from langchain_community.document_loaders import PyPDFLoader, UnstructuredWordDocumentLoader
|
||||
|
||||
def convert_word_to_pdf(doc_path: str) -> str:
|
||||
"""
|
||||
Convert a .doc or .docx file to PDF using Spire.Doc.
|
||||
Convert a .docx file to PDF using python-docx and reportlab.
|
||||
|
||||
Args:
|
||||
doc_path (str): The path to the .doc or .docx file.
|
||||
doc_path (str): The path to the .docx file.
|
||||
|
||||
Returns:
|
||||
str: The path to the converted PDF file.
|
||||
"""
|
||||
pdf_path = os.path.splitext(doc_path)[0] + '.pdf'
|
||||
|
||||
# Create a Document object
|
||||
document = Document()
|
||||
# Load the Word document
|
||||
document.LoadFromFile(doc_path)
|
||||
# Save as PDF
|
||||
document.SaveToFile(pdf_path, FileFormat.PDF)
|
||||
document.Close()
|
||||
doc = DocxDocument(doc_path)
|
||||
|
||||
# Create a PDF
|
||||
pdf = SimpleDocTemplate(pdf_path, pagesize=letter)
|
||||
styles = getSampleStyleSheet()
|
||||
flowables = []
|
||||
|
||||
# Extract text from paragraphs and add to PDF
|
||||
for para in doc.paragraphs:
|
||||
if para.text:
|
||||
p = Paragraph(para.text, styles['Normal'])
|
||||
flowables.append(p)
|
||||
flowables.append(Spacer(1, 12))
|
||||
|
||||
# Build the PDF
|
||||
pdf.build(flowables)
|
||||
|
||||
return pdf_path
|
||||
|
||||
def load_document(file_path: str):
|
||||
"""
|
||||
Utility function to load a PDF, DOCX, or DOC file by first converting it to PDF.
|
||||
Utility function to load a PDF, DOCX, or DOC file.
|
||||
|
||||
Args:
|
||||
file_path (str): The path to the file to load.
|
||||
@@ -34,15 +47,25 @@ def load_document(file_path: str):
|
||||
Returns:
|
||||
List[Document]: A list of Document objects representing the contents of the file.
|
||||
"""
|
||||
extension = os.path.splitext(file_path)[1].lower()
|
||||
|
||||
if extension in ['.doc', '.docx']:
|
||||
# Convert .doc or .docx to PDF first
|
||||
pdf_path = convert_word_to_pdf(file_path)
|
||||
loader = PyPDFLoader(pdf_path)
|
||||
elif extension == '.pdf':
|
||||
loader = PyPDFLoader(file_path)
|
||||
else:
|
||||
raise ValueError(f"Unsupported file type: {extension}. Only .pdf, .docx, and .doc are supported.")
|
||||
try:
|
||||
extension = os.path.splitext(file_path)[1].lower()
|
||||
|
||||
return loader.load()
|
||||
if extension == '.docx':
|
||||
# For .docx files, use UnstructuredWordDocumentLoader directly
|
||||
loader = UnstructuredWordDocumentLoader(file_path)
|
||||
return loader.load()
|
||||
elif extension == '.doc':
|
||||
# Convert .doc to .pdf first
|
||||
pdf_path = convert_word_to_pdf(file_path)
|
||||
loader = PyPDFLoader(pdf_path)
|
||||
return loader.load()
|
||||
elif extension == '.pdf':
|
||||
loader = PyPDFLoader(file_path)
|
||||
return loader.load()
|
||||
else:
|
||||
raise ValueError(f"Unsupported file type: {extension}. Only .pdf, .docx, and .doc are supported.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error loading document: {str(e)}")
|
||||
return None
|
||||
Reference in New Issue
Block a user