63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
|
|
""" main.py
|
|
Doczy AI - Pricing Before Carveouts: Main Execution Module
|
|
|
|
This module is the main entry point for the Priority B: Pricing Before Carveouts section of Doczy AI.
|
|
|
|
Functional Overview:
|
|
- In test mode, a simple Claude 3 model invocation is demonstrated.
|
|
- In normal mode, the module reads input documents, processes each document concurrently,
|
|
and manages exceptions and errors during processing.
|
|
- The processed results can be optionally consolidated into a single CSV file.
|
|
"""
|
|
|
|
# Imports
|
|
import concurrent.futures
|
|
import traceback
|
|
import os
|
|
|
|
import utils
|
|
import config
|
|
import claude_funcs
|
|
import file_processing
|
|
|
|
def main():
|
|
if config.TEST:
|
|
print(claude_funcs.invoke_claude_3("Write 'test', nothing more.", max_tokens = 10))
|
|
else:
|
|
# Read contract txt
|
|
input_dict = utils.read_input()
|
|
|
|
if config.FILTER_ALREADY_PROCESSED:
|
|
input_dict = utils.filter_already_processed(input_dict)
|
|
|
|
def process_item(item):
|
|
key, value = item
|
|
if utils.contains_reimbursement(item[1],0):
|
|
try:
|
|
file_processing.process_file(item)
|
|
#prompt_funcs.bottom_up(item)
|
|
except Exception as e:
|
|
# Print the error message and traceback
|
|
print(f"Error processing item {key}: {e}")
|
|
traceback.print_exc()
|
|
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=config.MAX_WORKERS) as executor:
|
|
# Process each item individually
|
|
futures = [executor.submit(process_item, item) for item in input_dict.items()]
|
|
|
|
# Wait for all futures to complete
|
|
for future in concurrent.futures.as_completed(futures):
|
|
# Retrieve any exceptions raised by the thread
|
|
try:
|
|
future.result()
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
# Write Consolidated Output
|
|
# if config.WRITE_OUTPUT:
|
|
# utils.consolidate_csvs(config.CONSOLIDATED_OUTPUT_DIRECTORY, config.OUTPUT_CSV_PATH)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|