Commit
·
77ecec5
1
Parent(s):
3f7d898
updated comparing results
Browse files- app.py +1 -0
- src/pipelines.py +5 -3
- src/prompts.py +0 -12
app.py
CHANGED
@@ -36,6 +36,7 @@ invoice_json_path = f"{data_folder}/invoices.json"
|
|
36 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
37 |
with open(f"{data_folder}/car_parts.json", "r") as f:
|
38 |
car_parts = json.load(f)
|
|
|
39 |
|
40 |
faiss_index_path = f"{data_folder}/invoice_index.faiss"
|
41 |
print("Index file size:", os.path.getsize(faiss_index_path))
|
|
|
36 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
37 |
with open(f"{data_folder}/car_parts.json", "r") as f:
|
38 |
car_parts = json.load(f)
|
39 |
+
print("Successfully loaded car parts")
|
40 |
|
41 |
faiss_index_path = f"{data_folder}/invoice_index.faiss"
|
42 |
print("Index file size:", os.path.getsize(faiss_index_path))
|
src/pipelines.py
CHANGED
@@ -47,6 +47,7 @@ class InvoiceGenerator:
|
|
47 |
|
48 |
@staticmethod
|
49 |
def check_within_range(generated_invoice, car_parts):
|
|
|
50 |
def get_part_info(part_name, car_parts):
|
51 |
part_name = part_name.lower()
|
52 |
max_match = [None, 0]
|
@@ -62,13 +63,14 @@ class InvoiceGenerator:
|
|
62 |
last_cost_line = -2 if all_lines[-1] == '' else -1
|
63 |
lines = generated_invoice.split("\n")[first_cost_line:last_cost_line]
|
64 |
cost_lines = [[line.strip() for line in cost_line.split("|")] for cost_line in lines]
|
|
|
65 |
|
66 |
comparing_results = {}
|
67 |
|
68 |
for line in cost_lines:
|
69 |
-
part = line[
|
70 |
-
cost = line[1]
|
71 |
-
hours = line[2]
|
72 |
found_part = get_part_info(part, car_parts)
|
73 |
if found_part:
|
74 |
comparing_results[part] = {
|
|
|
47 |
|
48 |
@staticmethod
|
49 |
def check_within_range(generated_invoice, car_parts):
|
50 |
+
print("Comparing results")
|
51 |
def get_part_info(part_name, car_parts):
|
52 |
part_name = part_name.lower()
|
53 |
max_match = [None, 0]
|
|
|
63 |
last_cost_line = -2 if all_lines[-1] == '' else -1
|
64 |
lines = generated_invoice.split("\n")[first_cost_line:last_cost_line]
|
65 |
cost_lines = [[line.strip() for line in cost_line.split("|")] for cost_line in lines]
|
66 |
+
start_index = 0 if cost_lines[0][0] != "" else 1
|
67 |
|
68 |
comparing_results = {}
|
69 |
|
70 |
for line in cost_lines:
|
71 |
+
part = line[start_index]
|
72 |
+
cost = line[start_index + 1]
|
73 |
+
hours = line[start_index + 2]
|
74 |
found_part = get_part_info(part, car_parts)
|
75 |
if found_part:
|
76 |
comparing_results[part] = {
|
src/prompts.py
CHANGED
@@ -58,15 +58,3 @@ Be thorough and specific, covering all visible damage in the image.
|
|
58 |
Write no more than 3-4 sentences describing the damage in detail.
|
59 |
Do not add any additional information beyond the visible damage in the image and any comments.
|
60 |
"""
|
61 |
-
|
62 |
-
|
63 |
-
ESTIMATE_COST_OF_CAR_PARTS_REPLACEMENT_PROMPT = """
|
64 |
-
I will provide you with a list of car parts that need to be replaced due to damage in a car accident (in German).
|
65 |
-
Your task is to estimate the cost of each part in Euros (EUR) based on the damage description provided.
|
66 |
-
Also, you need to estimate approximate labor hours required to replace each part.
|
67 |
-
There may be duplicate parts in the list (for example, for right and left sides of the car).
|
68 |
-
You may also expand the list with new parts which are not in the list but may be necessary for the repair.
|
69 |
-
Delete any duplicate entries and provide the cost and labor hours for one side only.
|
70 |
-
Sort the parts in the list in ascending order based on name of each part (in alphabetical order).
|
71 |
-
Your output should be a python dictionary where the keys are the names of the parts and the values are lists containing the estimated cost and labor hours for each part.
|
72 |
-
"""
|
|
|
58 |
Write no more than 3-4 sentences describing the damage in detail.
|
59 |
Do not add any additional information beyond the visible damage in the image and any comments.
|
60 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|