Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
d13fe95e
Commit
d13fe95e
authored
Aug 08, 2025
by
R10
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
智写-文书写作模板-模板对话结果放回
parent
aa0fda4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
435 additions
and
124 deletions
+435
-124
MotorVehicleDrivingComplaint.java
...ategy/ExtractEntityType/MotorVehicleDrivingComplaint.java
+435
-121
AiLawServiceImpl.java
...in/java/cn/com/poc/law/service/impl/AiLawServiceImpl.java
+0
-3
No files found.
src/main/java/cn/com/poc/law/ExtractEntityStrategy/ExtractEntityType/MotorVehicleDrivingComplaint.java
View file @
d13fe95e
package
cn
.
com
.
poc
.
law
.
ExtractEntityStrategy
.
ExtractEntityType
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.KnowledgeContentResult
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.law.ExtractEntityStrategy.ExtractEntityStrategy
;
...
...
@@ -12,12 +9,11 @@ import cn.com.poc.law.dto.LegalTemplateDto;
import
cn.com.poc.law.entity.*
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.
dialogue.ToolFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.
largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.hutool.core.util.ObjectUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -53,11 +49,17 @@ public class MotorVehicleDrivingComplaint implements ExtractEntityStrategy {
@Override
public
LegalTemplateDto
extractEntity
(
String
input
)
throws
ExecutionException
,
InterruptedException
{
// CompletableFuture<Plaintiff> extractPlaintiffFuture = CompletableFuture
// .supplyAsync(() -> extractPlaintiff(input), executor)
// .exceptionally(ex -> {
// return new Plaintiff();
// });
CompletableFuture
<
Plaintiff
>
extractPlaintiffFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractPlaintiff
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
Plaintiff
();
});
//
CompletableFuture
<
PlaintiffOrg
>
extractPlaintiffOrgFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
...
...
@@ -71,164 +73,476 @@ public class MotorVehicleDrivingComplaint implements ExtractEntityStrategy {
return
new
PlaintiffOrg
();
});
//
// CompletableFuture<Agent> extractAgentFuture = CompletableFuture
// .supplyAsync(() -> extractAgent(input), executor)
// .exceptionally(ex -> {
// return new Agent();
// });
//
// CompletableFuture<Defendant> extractDefendantFuture = CompletableFuture
// .supplyAsync(() -> extractDefendant(input), executor)
// .exceptionally(ex -> {
// return new Defendant();
// });
// CompletableFuture<DefendantOrg> extractDefendantOrgFuture = CompletableFuture
// .supplyAsync(() -> {
// try {
// return extractDefendantOrg(input);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }, executor)
// .exceptionally(ex -> {
// return new DefendantOrg();
// });
// CompletableFuture<ThirdParty> extractThirdPartyFuture = CompletableFuture
// .supplyAsync(() -> extractThirdParty(input), executor)
// .exceptionally(ex -> {
// return new ThirdParty();
// });
//
// CompletableFuture<ThirdPartyOrg> extractThirdPartyOrgFuture = CompletableFuture
// .supplyAsync(() -> extractThirdPartyOrg(input), executor)
// .exceptionally(ex -> {
// return new ThirdPartyOrg();
// });
//
// CompletableFuture<Claim> extractClaimFuture = CompletableFuture
// .supplyAsync(() -> extractClaim(input), executor)
// .exceptionally(ex -> {
// return new Claim();
// });
//
// CompletableFuture<Preservation> extractPreservationFuture = CompletableFuture
// .supplyAsync(() -> extractPreservation(input), executor)
// .exceptionally(ex -> {
// return new Preservation();
// });
//
// CompletableFuture<FactsAndReasons> extractFactsAndReasonsFuture = CompletableFuture
// .supplyAsync(() -> extractFactsAndReasons(input), executor)
// .exceptionally(ex -> {
// return new FactsAndReasons();
// });
//
// CompletableFuture<UnderstandsMediationBenefit> extractUnderstandsMediationBenefitFuture = CompletableFuture
// .supplyAsync(() -> extractUnderstandsMediationBenefit(input), executor)
// .exceptionally(ex -> {
// return new UnderstandsMediationBenefit();
// });
CompletableFuture
<
Agent
>
extractAgentFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractAgent
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
Agent
();
});
CompletableFuture
<
Defendant
>
extractDefendantFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractDefendant
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
Defendant
();
});
CompletableFuture
<
DefendantOrg
>
extractDefendantOrgFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractDefendantOrg
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
DefendantOrg
();
});
CompletableFuture
<
ThirdParty
>
extractThirdPartyFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractThirdParty
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
ThirdParty
();
});
CompletableFuture
<
ThirdPartyOrg
>
extractThirdPartyOrgFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractThirdPartyOrg
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
ThirdPartyOrg
();
});
CompletableFuture
<
Claim
>
extractClaimFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractClaim
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
Claim
();
});
CompletableFuture
<
Preservation
>
extractPreservationFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractPreservation
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
Preservation
();
});
CompletableFuture
<
FactsAndReasons
>
extractFactsAndReasonsFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractFactsAndReasons
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
FactsAndReasons
();
});
CompletableFuture
<
UnderstandsMediationBenefit
>
extractUnderstandsMediationBenefitFuture
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
return
extractUnderstandsMediationBenefit
(
input
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
},
executor
)
.
exceptionally
(
ex
->
{
return
new
UnderstandsMediationBenefit
();
});
// 等待所有任务完成并获取结果
//
CompletableFuture.allOf(extractPlaintiffFuture, extractPlaintiffOrgFuture, extractAgentFuture, extractDefendantFuture, extractDefendantOrgFuture,
//
extractThirdPartyFuture, extractThirdPartyOrgFuture, extractClaimFuture, extractPreservationFuture, extractFactsAndReasonsFuture, extractUnderstandsMediationBenefitFuture).join();
CompletableFuture
.
allOf
(
extractPlaintiffFuture
,
extractPlaintiffOrgFuture
,
extractAgentFuture
,
extractDefendantFuture
,
extractDefendantOrgFuture
,
extractThirdPartyFuture
,
extractThirdPartyOrgFuture
,
extractClaimFuture
,
extractPreservationFuture
,
extractFactsAndReasonsFuture
,
extractUnderstandsMediationBenefitFuture
).
join
();
//
//
Plaintiff extractPlaintiffResults = extractPlaintiffFuture.get();
Plaintiff
extractPlaintiffResults
=
extractPlaintiffFuture
.
get
();
PlaintiffOrg
extractPlaintiffOrgResults
=
extractPlaintiffOrgFuture
.
get
();
// Agent extractAgentResults = extractAgentFuture.get();
// Defendant extractDefendantResult = extractDefendantFuture.get();
// DefendantOrg extractDefendantOrgResult = extractDefendantOrgFuture.get();
// ThirdParty extractThirdPartyResult = extractThirdPartyFuture.get();
// ThirdPartyOrg extractThirdPartyOrgResult = extractThirdPartyOrgFuture.get();
// Claim extractClaimResult = extractClaimFuture.get();
// Preservation preservationResult = extractPreservationFuture.get();
// FactsAndReasons FactsAndReasonsResult = extractFactsAndReasonsFuture.get();
// UnderstandsMediationBenefit UnderstandsMediationBenefitResult = extractUnderstandsMediationBenefitFuture.get();
Agent
extractAgentResults
=
extractAgentFuture
.
get
();
Defendant
extractDefendantResult
=
extractDefendantFuture
.
get
();
DefendantOrg
extractDefendantOrgResult
=
extractDefendantOrgFuture
.
get
();
ThirdParty
extractThirdPartyResult
=
extractThirdPartyFuture
.
get
();
ThirdPartyOrg
extractThirdPartyOrgResult
=
extractThirdPartyOrgFuture
.
get
();
Claim
extractClaimResult
=
extractClaimFuture
.
get
();
Preservation
preservationResult
=
extractPreservationFuture
.
get
();
FactsAndReasons
factsAndReasonsResult
=
extractFactsAndReasonsFuture
.
get
();
UnderstandsMediationBenefit
UnderstandsMediationBenefitResult
=
extractUnderstandsMediationBenefitFuture
.
get
();
MotorVehicleDrivingComplaintEntity
motorVehicleDrivingComplaintEntity
=
new
MotorVehicleDrivingComplaintEntity
();
motorVehicleDrivingComplaintEntity
.
setPlaintiff
(
extractPlaintiffResults
);
motorVehicleDrivingComplaintEntity
.
setPlaintiffOrg
(
extractPlaintiffOrgResults
);
motorVehicleDrivingComplaintEntity
.
setAgent
(
extractAgentResults
);
motorVehicleDrivingComplaintEntity
.
setDefendant
(
extractDefendantResult
);
motorVehicleDrivingComplaintEntity
.
setDefendantOrg
(
extractDefendantOrgResult
);
motorVehicleDrivingComplaintEntity
.
setThirdParty
(
extractThirdPartyResult
);
motorVehicleDrivingComplaintEntity
.
setThirdPartyOrg
(
extractThirdPartyOrgResult
);
motorVehicleDrivingComplaintEntity
.
setClaim
(
extractClaimResult
);
motorVehicleDrivingComplaintEntity
.
setPreservation
(
preservationResult
);
motorVehicleDrivingComplaintEntity
.
setFactsAndReasons
(
factsAndReasonsResult
);
motorVehicleDrivingComplaintEntity
.
setUnderstandsMediationBenefit
(
UnderstandsMediationBenefitResult
);
return
motorVehicleDrivingComplaintEntity
;
}
private
PlaintiffOrg
extractPlaintiffOrg
(
String
input
)
throws
Exception
{
private
Plaintiff
extractPlaintiff
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptPlaintiff"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
null
,
null
,
input
,
null
,
null
,
null
);
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
true
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
String
res
;
PlaintiffOrg
result
=
null
;
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
if
(
StringUtils
.
isEmpty
(
res
))
{
continue
;
}
res
=
res
.
replace
(
"data: "
,
StringUtils
.
EMPTY
);
result
=
JsonUtils
.
deSerialize
(
res
,
PlaintiffOrg
.
class
);
if
(
ObjectUtil
.
isEmpty
(
result
))
{
throw
new
BusinessException
(
"提取失败"
);
}
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
Plaintiff
plaintiff
=
new
Plaintiff
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
plaintiff
=
JsonUtils
.
deSerialize
(
message
,
Plaintiff
.
class
);
if
(
ObjectUtil
.
isEmpty
(
plaintiff
))
{
throw
new
BusinessException
(
"提取失败"
);
}
bufferedReader
.
close
();
return
result
;
return
plaintiff
;
}
private
Defendant
extractDefendant
(
String
input
)
{
return
null
;
}
private
PlaintiffOrg
extractPlaintiffOrg
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptPlaintiffOrg"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
private
ThirdParty
extractThirdParty
(
String
input
)
{
return
null
;
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
PlaintiffOrg
plaintiffOrg
=
new
PlaintiffOrg
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
plaintiffOrg
=
JsonUtils
.
deSerialize
(
message
,
PlaintiffOrg
.
class
);
if
(
ObjectUtil
.
isEmpty
(
plaintiffOrg
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
plaintiffOrg
;
}
private
ThirdPartyOrg
extractThirdPartyOrg
(
String
input
)
{
return
null
;
private
Agent
extractAgent
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptAgent"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
Agent
agent
=
new
Agent
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
agent
=
JsonUtils
.
deSerialize
(
message
,
Agent
.
class
);
if
(
ObjectUtil
.
isEmpty
(
agent
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
agent
;
}
private
Claim
extractClaim
(
String
input
)
{
return
null
;
private
Defendant
extractDefendant
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptDefendant"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
Defendant
defendant
=
new
Defendant
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
defendant
=
JsonUtils
.
deSerialize
(
message
,
Defendant
.
class
);
if
(
ObjectUtil
.
isEmpty
(
defendant
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
defendant
;
}
private
Preservation
extractPreservation
(
String
input
)
{
return
null
;
private
DefendantOrg
extractDefendantOrg
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptDefendantOrg"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
DefendantOrg
defendantOrg
=
new
DefendantOrg
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
defendantOrg
=
JsonUtils
.
deSerialize
(
message
,
DefendantOrg
.
class
);
if
(
ObjectUtil
.
isEmpty
(
defendantOrg
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
defendantOrg
;
}
private
FactsAndReasons
extractFactsAndReasons
(
String
input
)
{
return
null
;
private
ThirdParty
extractThirdParty
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptThirdParty"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
ThirdParty
thirdParty
=
new
ThirdParty
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
thirdParty
=
JsonUtils
.
deSerialize
(
message
,
ThirdParty
.
class
);
if
(
ObjectUtil
.
isEmpty
(
thirdParty
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
thirdParty
;
}
private
UnderstandsMediationBenefit
extractUnderstandsMediationBenefit
(
String
input
)
{
return
null
;
private
ThirdPartyOrg
extractThirdPartyOrg
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptThirdPartyOrg"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
ThirdPartyOrg
thirdPartyOrg
=
new
ThirdPartyOrg
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
thirdPartyOrg
=
JsonUtils
.
deSerialize
(
message
,
ThirdPartyOrg
.
class
);
if
(
ObjectUtil
.
isEmpty
(
thirdPartyOrg
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
thirdPartyOrg
;
}
private
Agent
extractAgent
(
String
input
)
{
return
null
;
private
Claim
extractClaim
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptClaim"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
Claim
claim
=
new
Claim
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
claim
=
JsonUtils
.
deSerialize
(
message
,
Claim
.
class
);
if
(
ObjectUtil
.
isEmpty
(
claim
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
claim
;
}
private
Preservation
extractPreservation
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptPreservation"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
private
Plaintiff
extractPlaintiff
(
String
input
)
{
return
null
;
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
Preservation
preservation
=
new
Preservation
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
preservation
=
JsonUtils
.
deSerialize
(
message
,
Preservation
.
class
);
if
(
ObjectUtil
.
isEmpty
(
preservation
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
preservation
;
}
private
FactsAndReasons
extractFactsAndReasons
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"AILawyerWritingPromptFactsAndReasons"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
Long
userId
,
String
input
,
String
fileUrl
,
List
<
KnowledgeContentResult
>
knowledgeContentResults
,
ToolFunction
toolFunction
)
throws
Exception
{
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
FactsAndReasons
factsAndReasons
=
new
FactsAndReasons
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
factsAndReasons
=
JsonUtils
.
deSerialize
(
message
,
FactsAndReasons
.
class
);
if
(
ObjectUtil
.
isEmpty
(
factsAndReasons
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
factsAndReasons
;
}
private
UnderstandsMediationBenefit
extractUnderstandsMediationBenefit
(
String
input
)
throws
Exception
{
// 获取对话提示词
String
promptCode
=
"
ExtractDefendantOrgPromp
t"
;
String
promptCode
=
"
AILawyerWritingPromptUnderstandsMediationBenefi
t"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
if
(
documentDialoguePrompt
==
null
||
StringUtils
.
isBlank
(
documentDialoguePrompt
.
getConfigSystem
()))
{
// logger.error("获取对话提示词失败 , configCode:{}", promptCode);
throw
new
BusinessException
(
"获取对话提示词失败"
);
}
String
prompt
=
documentDialoguePrompt
.
getConfigSystem
().
replace
(
"${input}"
,
input
);
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
input
,
null
,
prompt
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
//获取模型);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
chat
=
llmService
.
chat
(
largeModelResponse
);
UnderstandsMediationBenefit
understandsMediationBenefit
=
new
UnderstandsMediationBenefit
();
if
(
ObjectUtil
.
isEmpty
(
chat
)
||
!
chat
.
getCode
().
equals
(
"0"
))
{
throw
new
BusinessException
(
"获取失败"
);
}
String
message
=
chat
.
getMessage
().
replaceAll
(
"```json"
,
StringUtils
.
EMPTY
).
replaceAll
(
"```"
,
StringUtils
.
EMPTY
);
understandsMediationBenefit
=
JsonUtils
.
deSerialize
(
message
,
UnderstandsMediationBenefit
.
class
);
if
(
ObjectUtil
.
isEmpty
(
understandsMediationBenefit
))
{
throw
new
BusinessException
(
"提取失败"
);
}
return
understandsMediationBenefit
;
}
private
List
<
Message
>
buildMessages
(
String
input
,
String
fileUrl
,
String
prompt
)
throws
Exception
{
// 加载文件
String
fileContent
=
StringUtils
.
EMPTY
;
if
(
StringUtils
.
isNoneBlank
(
fileUrl
))
{
...
...
@@ -260,7 +574,7 @@ public class MotorVehicleDrivingComplaint implements ExtractEntityStrategy {
// 用户输入
Message
message
=
new
Message
();
message
.
setContent
(
input
);
message
.
setContent
(
"请根据要求提取"
);
message
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
messages
.
add
(
message
);
// logger.info("--------- Build Messages dialogsId:{},messages:{}--------------", dialogsId, messages);
...
...
src/main/java/cn/com/poc/law/service/impl/AiLawServiceImpl.java
View file @
d13fe95e
...
...
@@ -241,9 +241,6 @@ public class AiLawServiceImpl implements AiLawService {
ExtractEntityStrategy
extractEntityStrategy
=
LawyerTemplateExtractServiceBuilder
.
getService
(
LawyerExtractTypeEnum
.
valueOf
(
templateCode
));
//解析文件
LegalTemplateDto
legalTemplateDto
=
extractEntityStrategy
.
extractEntity
(
input
+
fileContent
);
return
legalTemplateDto
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment