Spaces:
Sleeping
Sleeping
Tanner Davis commited on
Commit ·
2cd20ef
1
Parent(s): 840cb29
remove references to storage for now
Browse files- src/papertrail/pipeline.py +16 -16
src/papertrail/pipeline.py
CHANGED
|
@@ -23,14 +23,14 @@ from papertrail.events import Done, Event, Failed, Stage, Token
|
|
| 23 |
from papertrail.inference.client import BasePaperTrailClient, get_client
|
| 24 |
from papertrail.preprocess import load_document
|
| 25 |
from papertrail.schema import EXTRACTION_INSTRUCTION, ProcessedExpense
|
| 26 |
-
from papertrail.storage import Repository
|
| 27 |
|
| 28 |
|
| 29 |
def process_document(
|
| 30 |
path: str | Path,
|
| 31 |
*,
|
| 32 |
client: BasePaperTrailClient | None = None,
|
| 33 |
-
repo: Repository | None = None,
|
| 34 |
instruction: str = EXTRACTION_INSTRUCTION,
|
| 35 |
doc_type: str = "upload",
|
| 36 |
) -> ProcessedExpense:
|
|
@@ -44,12 +44,12 @@ def process_document(
|
|
| 44 |
|
| 45 |
result = ProcessedExpense(expense=expense, eligibility=verdict, readiness=readiness)
|
| 46 |
|
| 47 |
-
if repo is not None:
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
return result
|
| 55 |
|
|
@@ -58,7 +58,7 @@ def process_document_stream(
|
|
| 58 |
path: str | Path,
|
| 59 |
*,
|
| 60 |
client: BasePaperTrailClient | None = None,
|
| 61 |
-
repo: Repository | None = None,
|
| 62 |
instruction: str = EXTRACTION_INSTRUCTION,
|
| 63 |
doc_type: str = "upload",
|
| 64 |
) -> Iterator[Event]:
|
|
@@ -89,13 +89,13 @@ def process_document_stream(
|
|
| 89 |
yield Stage("scoring", "scoring audit readiness…")
|
| 90 |
readiness = score(expense)
|
| 91 |
result = ProcessedExpense(expense=expense, eligibility=verdict, readiness=readiness)
|
| 92 |
-
if repo is not None:
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
yield Done(result)
|
| 100 |
except Exception as exc: # surface as a terminal event, don't crash the stream
|
| 101 |
yield Failed(f"{type(exc).__name__}: {exc}")
|
|
|
|
| 23 |
from papertrail.inference.client import BasePaperTrailClient, get_client
|
| 24 |
from papertrail.preprocess import load_document
|
| 25 |
from papertrail.schema import EXTRACTION_INSTRUCTION, ProcessedExpense
|
| 26 |
+
# from papertrail.storage import Repository
|
| 27 |
|
| 28 |
|
| 29 |
def process_document(
|
| 30 |
path: str | Path,
|
| 31 |
*,
|
| 32 |
client: BasePaperTrailClient | None = None,
|
| 33 |
+
# repo: Repository | None = None,
|
| 34 |
instruction: str = EXTRACTION_INSTRUCTION,
|
| 35 |
doc_type: str = "upload",
|
| 36 |
) -> ProcessedExpense:
|
|
|
|
| 44 |
|
| 45 |
result = ProcessedExpense(expense=expense, eligibility=verdict, readiness=readiness)
|
| 46 |
|
| 47 |
+
# if repo is not None:
|
| 48 |
+
# doc_id = repo.add_document(
|
| 49 |
+
# Path(path).name, path, doc_type, raw_model_output=expense.model_dump_json()
|
| 50 |
+
# )
|
| 51 |
+
# result.document_id = doc_id
|
| 52 |
+
# result.expense_id = repo.add_expense(doc_id, expense, verdict, readiness)
|
| 53 |
|
| 54 |
return result
|
| 55 |
|
|
|
|
| 58 |
path: str | Path,
|
| 59 |
*,
|
| 60 |
client: BasePaperTrailClient | None = None,
|
| 61 |
+
# repo: Repository | None = None,
|
| 62 |
instruction: str = EXTRACTION_INSTRUCTION,
|
| 63 |
doc_type: str = "upload",
|
| 64 |
) -> Iterator[Event]:
|
|
|
|
| 89 |
yield Stage("scoring", "scoring audit readiness…")
|
| 90 |
readiness = score(expense)
|
| 91 |
result = ProcessedExpense(expense=expense, eligibility=verdict, readiness=readiness)
|
| 92 |
+
# if repo is not None:
|
| 93 |
+
# yield Stage("storage", "saving record…")
|
| 94 |
+
# doc_id = repo.add_document(
|
| 95 |
+
# Path(path).name, path, doc_type, raw_model_output=expense.model_dump_json()
|
| 96 |
+
# )
|
| 97 |
+
# result.document_id = doc_id
|
| 98 |
+
# result.expense_id = repo.add_expense(doc_id, expense, verdict, readiness)
|
| 99 |
yield Done(result)
|
| 100 |
except Exception as exc: # surface as a terminal event, don't crash the stream
|
| 101 |
yield Failed(f"{type(exc).__name__}: {exc}")
|