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
34e0449c
Commit
34e0449c
authored
Aug 07, 2025
by
R10
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
智写-文书写作模板-ai对话
parent
c6b38d89
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
3 deletions
+64
-3
BizAiDialoguesServiceImpl.java
.../ai_dialogues/service/impl/BizAiDialoguesServiceImpl.java
+3
-0
LegalRest.java
src/main/java/cn/com/poc/law/rest/LegalRest.java
+2
-2
LegalRestImpl.java
src/main/java/cn/com/poc/law/rest/impl/LegalRestImpl.java
+1
-1
AiLawServiceImpl.java
...in/java/cn/com/poc/law/service/impl/AiLawServiceImpl.java
+58
-0
No files found.
src/main/java/cn/com/poc/ai_dialogues/service/impl/BizAiDialoguesServiceImpl.java
View file @
34e0449c
...
...
@@ -98,6 +98,9 @@ public class BizAiDialoguesServiceImpl extends BaseServiceImpl
if
(
entity
.
getTitle
()
!=
null
)
{
model
.
setTitle
(
entity
.
getTitle
());
}
if
(
entity
.
getDialoguesType
()
!=
null
)
{
model
.
setDialoguesType
(
entity
.
getDialoguesType
());
}
if
(
entity
.
getMemberId
()
!=
null
)
{
model
.
setMemberId
(
entity
.
getMemberId
());
}
...
...
src/main/java/cn/com/poc/law/rest/LegalRest.java
View file @
34e0449c
...
...
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
* @author alex.yao
* @date 2025/7/28
*/
@Permission
(
Access
.
Anonymous
)
@Permission
(
Access
.
Safety
)
public
interface
LegalRest
extends
BaseRest
{
/**
...
...
@@ -26,7 +26,7 @@ public interface LegalRest extends BaseRest {
/**
* ai对话
*/
void
AI
WritingCall
(
@RequestBody
AiLawDialoguesDto
dto
)
throws
Exception
;
void
ai
WritingCall
(
@RequestBody
AiLawDialoguesDto
dto
)
throws
Exception
;
/**
* templateAi对话
...
...
src/main/java/cn/com/poc/law/rest/impl/LegalRestImpl.java
View file @
34e0449c
...
...
@@ -48,7 +48,7 @@ public class LegalRestImpl implements LegalRest {
private
AiLawService
aiLawService
;
@Override
public
void
AI
WritingCall
(
AiLawDialoguesDto
dto
)
throws
Exception
{
public
void
ai
WritingCall
(
AiLawDialoguesDto
dto
)
throws
Exception
{
cn
.
hutool
.
core
.
lang
.
Assert
.
notNull
(
dto
.
getDialoguesId
(),
"对话id不能为空"
);
cn
.
hutool
.
core
.
lang
.
Assert
.
notNull
(
dto
.
getInput
(),
"问题不能为空"
);
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
...
...
src/main/java/cn/com/poc/law/service/impl/AiLawServiceImpl.java
View file @
34e0449c
...
...
@@ -36,6 +36,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.function.AbstractFunctionResult;
import
cn.com.poc.thirdparty.resource.demand.ai.function.web_seach.WebSearchFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.web_seach.WebSearchFunctionResult
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.poc.writing.dto.AiWritingTitleGenerationDto
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
cn.hutool.core.util.ObjectUtil
;
...
...
@@ -168,6 +169,13 @@ public class AiLawServiceImpl implements AiLawService {
}
}
//作文标题生成
AiWritingTitleGenerationDto
aiWritingTitleGenerationDto
=
titleGeneration
(
input
);
Boolean
needWriting
=
aiWritingTitleGenerationDto
.
getNeedWriting
();
if
(
needWriting
&&
StringUtils
.
isNotBlank
(
aiWritingTitleGenerationDto
.
getTitle
()))
{
sseUtil
.
send
(
JsonUtils
.
serialize
(
aiWritingTitleGenerationDto
));
}
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
dialoguesId
,
userId
,
input
,
fileUrl
,
null
,
toolFunction
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
...
...
@@ -577,4 +585,54 @@ public class AiLawServiceImpl implements AiLawService {
}
}
public
AiWritingTitleGenerationDto
titleGeneration
(
String
input
)
{
String
system
=
"## 角色\n"
+
"你的任务需要帮我判断用户是否需要进行【写作】\n"
+
"\n"
+
"## 输出\n"
+
"1.包含字段有 needWriting:bool 判断是否需要写作 true-需要 false-不需要 。 title-写作标题,如果需要则生成文章的标题\n"
+
"2.仅使用文本方式输出内容。\n"
+
"\n"
+
"## 输出案例\n"
+
"{”needWriting“:true,\"title\":\"论人工智能发展对生产力的影响\"}"
;
// 配置message
List
<
Message
>
messages
=
new
ArrayList
<>();
Message
systemMessage
=
new
Message
();
systemMessage
.
setContent
(
system
);
systemMessage
.
setRole
(
LLMRoleEnum
.
SYSTEM
.
getRole
());
messages
.
add
(
systemMessage
);
Message
userMessage
=
new
Message
();
userMessage
.
setContent
(
input
);
userMessage
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
messages
.
add
(
userMessage
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-v3"
);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setTopP
(
0.7
F
);
largeModelResponse
.
setTemperature
(
0.5
F
);
largeModelResponse
.
setStream
(
false
);
LargeModelDemandResult
largeModelDemandResult
=
llmService
.
chat
(
largeModelResponse
);
if
(
largeModelDemandResult
==
null
||
StringUtils
.
isBlank
(
largeModelDemandResult
.
getMessage
()))
{
throw
new
BusinessException
(
"调用大模型失败"
);
}
String
message
=
largeModelDemandResult
.
getMessage
();
int
startEnd
=
message
.
indexOf
(
"{"
);
int
endIndex
=
message
.
lastIndexOf
(
"}"
);
if
(
startEnd
==
-
1
||
endIndex
==
-
1
)
{
logger
.
error
(
"解析内容失败, message:{}"
,
message
);
throw
new
BusinessException
(
"解析内容失败"
);
}
String
substring
=
message
.
substring
(
startEnd
,
endIndex
+
1
);
AiWritingTitleGenerationDto
aiWritingTitleGenerationDto
=
JsonUtils
.
deSerialize
(
substring
,
AiWritingTitleGenerationDto
.
class
);
if
(
aiWritingTitleGenerationDto
==
null
)
{
aiWritingTitleGenerationDto
.
setNeedWriting
(
false
);
aiWritingTitleGenerationDto
.
setTitle
(
StringUtils
.
EMPTY
);
}
return
aiWritingTitleGenerationDto
;
}
}
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