From d5836c6fbf0f25db3fc4bec342cab752f01dba7b Mon Sep 17 00:00:00 2001 From: martsforever Date: Mon, 8 Sep 2025 22:28:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B5=B0=E9=85=92=E5=BA=97=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E3=80=81=E6=88=96=E8=80=85=E6=8F=90=E4=BA=A4=E6=8A=A5?= =?UTF-8?q?=E9=94=80=E5=8D=95=E5=AE=A1=E6=89=B9=E6=B5=81=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=B0=83=E7=94=A8AI=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E6=AF=94=E6=8A=A5=E9=94=80=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=B8=8E=E6=8A=A5=E9=94=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E5=AE=A1=E6=89=B9=E6=A0=87=E8=AF=86=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=AE=A1=E6=89=B9=E4=B8=8D=E9=80=9A=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/llm_approve_utils.py | 45 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/app/utils/llm_approve_utils.py b/app/utils/llm_approve_utils.py index 8440758..41d7bb2 100644 --- a/app/utils/llm_approve_utils.py +++ b/app/utils/llm_approve_utils.py @@ -5,7 +5,6 @@ from langchain_core.prompts import ChatPromptTemplate from pydantic import BaseModel, Field from app.model.KnowledgeDoc import KnowledgeDocServiceWithCreator, KnowledgeDocModel -from app.model.ReimburseModel import ReimburseModel from app.utils.db_utils import AsyncSessionDep from app.utils.llm_utils import create_llm @@ -15,7 +14,7 @@ class LlmApproveResult(BaseModel): llm_reason: str | None = Field(default=None, description="审核不通过时的原因") -async def get_llm_approve_result(session: AsyncSessionDep, reimburse_cls: ReimburseModel): +async def get_llm_approve_result(session: AsyncSessionDep, reimburse_dict: dict): try: reimburse_document: KnowledgeDocModel = await KnowledgeDocServiceWithCreator.query_item(session, {"code": "REIMBURSE"}) except Exception as e: @@ -37,7 +36,7 @@ async def get_llm_approve_result(session: AsyncSessionDep, reimburse_cls: Reimbu print(reimburse_document.content) print(":::::::::::::::报销单描述::::::::::::::::::::::::") - reimburse_description = get_reimburse_description(reimburse_cls) + reimburse_description = get_reimburse_description(reimburse_dict) print(reimburse_description) llm_response_content = await chain.ainvoke({ @@ -53,38 +52,38 @@ async def get_llm_approve_result(session: AsyncSessionDep, reimburse_cls: Reimbu return llm_response_dict -def get_reimburse_description(reimrbuse_cls: ReimburseModel): - if not reimrbuse_cls.project: +def get_reimburse_description(reimburse_dict: dict): + if not reimburse_dict["project"]: raise Exception("报销单关联项目不存在") reimbruse_content = f""" - 报销申请人:{reimrbuse_cls.user.full_name} - 报销单标题:{str(reimrbuse_cls.title)} - 报销单金额:{str(reimrbuse_cls.amount)} - 报销单备注信息:{str(reimrbuse_cls.remarks)} - 报销项目:{str(reimrbuse_cls.project.name)} + 报销申请人:{reimburse_dict["user"]["full_name"]} + 报销单标题:{str(reimburse_dict["title"])} + 报销单金额:{str(reimburse_dict["amount"])} + 报销单备注信息:{str(reimburse_dict["remarks"])} + 报销项目:{str(reimburse_dict["project"]["name"])} """ - for index, travel_item in enumerate(reimrbuse_cls.travel_list): + for index, travel_item in enumerate(reimburse_dict["travel_list"]): reimbruse_content += f""" 第{index + 1}条差旅费用信息: - 差旅费用名称:{travel_item.title} - 差旅费用类型:{travel_item.type} - 差旅出发时间:{travel_item.depart_time} - 差旅出发地点:{travel_item.depart_city} - 差旅到达时间:{travel_item.arrive_time} - 差旅到达地点:{travel_item.arrive_city} - 差旅报销金额:{travel_item.amount} + 差旅费用名称:{travel_item["title"]} + 差旅费用类型:{travel_item["type"]} + 差旅出发时间:{travel_item["depart_time"]} + 差旅出发地点:{travel_item["depart_city"]} + 差旅到达时间:{travel_item["arrive_time"]} + 差旅到达地点:{travel_item["arrive_city"]} + 差旅报销金额:{travel_item["amount"]} """ - for index, other_item in enumerate(reimrbuse_cls.other_list): + for index, other_item in enumerate(reimburse_dict["other_list"]): reimbruse_content += f""" 第{index + 1}条费用信息: - 费用名称:{other_item.title} - 费用类型:{other_item.type} - 报销金额:{other_item.amount} - 票据类型:{other_item.recipe_type} + 费用名称:{other_item["title"]} + 费用类型:{other_item["type"]} + 报销金额:{other_item["amount"]} + 票据类型:{other_item["recipe_type"]} """ return reimbruse_content