Init
This commit is contained in:
@@ -2,26 +2,26 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional
|
||||
|
||||
# --- 分类结果模型 ---
|
||||
# --- Classification Result Model ---
|
||||
class ClassificationResult(BaseModel):
|
||||
"""Defines the structured output for the classification agent."""
|
||||
category: str = Field(description="The category of the document, must be one of ['LETTER', 'INVOICE', 'RECEIPT', 'CONTRACT', 'OTHER']")
|
||||
language: str = Field(description="The detected primary language of the document as a two-letter code (e.g., 'en', 'zh', 'es').")
|
||||
|
||||
# --- 现有模型 (无变化) ---
|
||||
# --- Existing Model (Unchanged) ---
|
||||
class ReceiptItem(BaseModel):
|
||||
name: str = Field(description="购买的项目或服务名称")
|
||||
quantity: float = Field(description="项目数量")
|
||||
price: float = Field(description="项目单价")
|
||||
name: str = Field(description="The name of the purchased item or service")
|
||||
quantity: float = Field(description="The quantity of the item")
|
||||
price: float = Field(description="The unit price of the item")
|
||||
|
||||
class ReceiptInfo(BaseModel):
|
||||
merchant_name: Optional[str] = Field(None, description="商户或店铺的名称")
|
||||
transaction_date: Optional[str] = Field(None, description="交易日期,格式为 YYYY-MM-DD")
|
||||
total_amount: Optional[float] = Field(None, description="收据上的总金额")
|
||||
items: Optional[List[ReceiptItem]] = Field(None, description="购买的所有项目列表")
|
||||
merchant_name: Optional[str] = Field(None, description="The name of the merchant or store")
|
||||
transaction_date: Optional[str] = Field(None, description="The transaction date in the YYYY-MM-DD format")
|
||||
total_amount: Optional[float] = Field(None, description="The total amount on the receipt")
|
||||
items: Optional[List[ReceiptItem]] = Field(None, description="The list of all purchased items")
|
||||
|
||||
|
||||
# --- 新增: 发票行项目模型 ---
|
||||
# --- Added: Invoice Line Item Model ---
|
||||
class LineItem(BaseModel):
|
||||
"""Defines a single line item from an invoice."""
|
||||
description: Optional[str] = Field("", description="The description of the product or service.")
|
||||
@@ -30,7 +30,6 @@ class LineItem(BaseModel):
|
||||
total_price: Optional[float] = Field(None, description="The total price for this line item (quantity * unit_price).")
|
||||
|
||||
|
||||
# --- 发票模型 (已更新) ---
|
||||
class InvoiceInfo(BaseModel):
|
||||
"""Defines the detailed, structured information to be extracted from an invoice."""
|
||||
date: Optional[str] = Field("", description="Extract in YYYY-MM-DD format. If unclear, leave as an empty string.")
|
||||
@@ -48,4 +47,7 @@ class InvoiceInfo(BaseModel):
|
||||
customer_address_region: Optional[str] = Field("", description="It's the receiver's address region. If not found, find the region of the extracted city or country. If unclear, leave as an empty string.")
|
||||
customer_address_care_of: Optional[str] = Field("", description="It's the receiver's address care of. If not found or unclear, leave as an empty string.")
|
||||
billo_id: Optional[str] = Field("", description="Extract from customer_address if it exists, following the format 'LLL NNN-A'. If not found or unclear, leave as an empty string.")
|
||||
bank_giro: Optional[str] = Field("", description="BankGiro number, e.g., '123-4567'. If not found, leave as an empty string.")
|
||||
plus_giro: Optional[str] = Field("", description="PlusGiro number, e.g., '123456-7'. If not found, leave as an empty string.")
|
||||
customer_ssn: Optional[str] = Field("", description="Customer's social security number, e.g., 'YYYYMMDD-XXXX'. If not found, leave as an empty string.")
|
||||
line_items: List[LineItem] = Field([], description="A list of all line items from the invoice.")
|
||||
Reference in New Issue
Block a user