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
fa46d72a
Commit
fa46d72a
authored
Aug 11, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:长文/写作 添加思考模式/联网模式
parent
4ce373e7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
192 additions
and
15 deletions
+192
-15
LongTextDialoguesService.java
...poc/long_document/aggregate/LongTextDialoguesService.java
+1
-1
LongTextDialoguesServiceImpl.java
...document/aggregate/impl/LongTextDialoguesServiceImpl.java
+66
-5
LongTextDialoguesCallDto.java
...n/com/poc/long_document/dto/LongTextDialoguesCallDto.java
+27
-2
LongTextDialoguesRestImpl.java
...oc/long_document/rest/impl/LongTextDialoguesRestImpl.java
+1
-1
AiWritingService.java
...n/java/cn/com/poc/writing/aggregate/AiWritingService.java
+3
-1
AiWritingServiceImpl.java
.../com/poc/writing/aggregate/impl/AiWritingServiceImpl.java
+64
-4
AiWritingDto.java
src/main/java/cn/com/poc/writing/dto/AiWritingDto.java
+28
-0
AiWritingRestImpl.java
.../java/cn/com/poc/writing/rest/impl/AiWritingRestImpl.java
+2
-1
No files found.
src/main/java/cn/com/poc/long_document/aggregate/LongTextDialoguesService.java
View file @
fa46d72a
...
@@ -12,7 +12,7 @@ import java.util.List;
...
@@ -12,7 +12,7 @@ import java.util.List;
public
interface
LongTextDialoguesService
{
public
interface
LongTextDialoguesService
{
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
)
throws
Exception
;
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
,
Boolean
enableSearchEngine
,
Boolean
enableDeepThinking
)
throws
Exception
;
LongTextSummaryDto
summary
(
String
dialoguesId
,
Long
userId
)
throws
Exception
;
LongTextSummaryDto
summary
(
String
dialoguesId
,
Long
userId
)
throws
Exception
;
...
...
src/main/java/cn/com/poc/long_document/aggregate/impl/LongTextDialoguesServiceImpl.java
View file @
fa46d72a
...
@@ -2,13 +2,14 @@ package cn.com.poc.long_document.aggregate.impl;
...
@@ -2,13 +2,14 @@ package cn.com.poc.long_document.aggregate.impl;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.CheckPluginUseEntity
;
import
cn.com.poc.agent_application.entity.KnowledgeContentResult
;
import
cn.com.poc.agent_application.entity.KnowledgeContentResult
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity
;
import
cn.com.poc.ai_dialogues.service.BizAiDialoguesService
;
import
cn.com.poc.ai_dialogues.service.BizAiDialoguesService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.FmxParamConfigConstant
;
import
cn.com.poc.common.model.BizFileUploadRecordModel
;
import
cn.com.poc.common.model.BizFileUploadRecordModel
;
import
cn.com.poc.common.service.BizFileUploadRecordService
;
import
cn.com.poc.common.service.BizFileUploadRecordService
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.DocumentLoad
;
...
@@ -30,10 +31,17 @@ import cn.com.poc.long_document.service.BizLongTextSummaryCacheService;
...
@@ -30,10 +31,17 @@ import cn.com.poc.long_document.service.BizLongTextSummaryCacheService;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.FunctionCall
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.ToolFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SearchKnowledgeResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SearchKnowledgeResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
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.resource.demand.ai.entity.largemodel.LargeModelResponse
;
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.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
...
@@ -97,9 +105,12 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
...
@@ -97,9 +105,12 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
@Resource
@Resource
private
FmxParamConfigService
fmxParamConfigService
;
private
FmxParamConfigService
fmxParamConfigService
;
@Resource
private
WebSearchFunction
webSearchFunction
;
@Override
@Override
public
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
)
throws
Exception
{
public
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
,
Boolean
enableSearchEngine
,
Boolean
enableDeepThinking
)
throws
Exception
{
BizAiDialoguesEntity
bizAiDialoguesEntity
=
new
BizAiDialoguesEntity
();
BizAiDialoguesEntity
bizAiDialoguesEntity
=
new
BizAiDialoguesEntity
();
bizAiDialoguesEntity
.
setDialoguesId
(
dialoguesId
);
bizAiDialoguesEntity
.
setDialoguesId
(
dialoguesId
);
bizAiDialoguesEntity
.
setMemberId
(
userId
);
bizAiDialoguesEntity
.
setMemberId
(
userId
);
...
@@ -165,9 +176,15 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
...
@@ -165,9 +176,15 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
}
}
String
longTextDialoguesModel
=
fmxParamConfigService
.
getParam
(
"longtext.dialogues_model"
);
String
longTextDialoguesModel
=
enableDeepThinking
?
fmxParamConfigService
.
getParam
(
"longtext.dialogues_model_think"
)
:
fmxParamConfigService
.
getParam
(
"longtext.dialogues_model"
);
// 插件调用
ToolFunction
toolFunction
=
getToolFunction
(
dialoguesId
,
input
,
enableSearchEngine
,
sseUtil
);
//组装请求参数
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
dialoguesId
,
userId
,
input
,
fileUrl
,
knowledgeResult
);
List
<
Message
>
messages
=
buildMessages
(
dialoguesId
,
userId
,
input
,
fileUrl
,
knowledgeResult
,
toolFunction
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
longTextDialoguesModel
);
largeModelResponse
.
setModel
(
longTextDialoguesModel
);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
...
@@ -292,7 +309,7 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
...
@@ -292,7 +309,7 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
}
}
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
Long
userId
,
String
input
,
String
fileUrl
,
List
<
KnowledgeContentResult
>
knowledgeContentResults
)
throws
Exception
{
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
Long
userId
,
String
input
,
String
fileUrl
,
List
<
KnowledgeContentResult
>
knowledgeContentResults
,
ToolFunction
toolFunction
)
throws
Exception
{
// 获取对话提示词
// 获取对话提示词
String
promptCode
=
"DocumentDialoguePrompt"
;
String
promptCode
=
"DocumentDialoguePrompt"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
...
@@ -315,6 +332,10 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
...
@@ -315,6 +332,10 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
prompt
=
prompt
.
replace
(
"${knowledgeContent}"
,
StringUtils
.
EMPTY
);
prompt
=
prompt
.
replace
(
"${knowledgeContent}"
,
StringUtils
.
EMPTY
);
}
}
if
(
toolFunction
!=
null
)
{
prompt
=
prompt
.
replace
(
"${toolFunction}"
,
JsonUtils
.
serialize
(
toolFunction
));
}
// 配置message
// 配置message
List
<
Message
>
messages
=
new
ArrayList
<>();
List
<
Message
>
messages
=
new
ArrayList
<>();
Message
systemMessage
=
new
Message
();
Message
systemMessage
=
new
Message
();
...
@@ -577,4 +598,44 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
...
@@ -577,4 +598,44 @@ public class LongTextDialoguesServiceImpl implements LongTextDialoguesService {
throw
new
BusinessException
(
"获取核心观点失败"
);
throw
new
BusinessException
(
"获取核心观点失败"
);
}
}
}
}
private
ToolFunction
getToolFunction
(
String
dialoguesId
,
String
input
,
Boolean
enableSearchEngine
,
SSEUtil
sseUtil
)
throws
IOException
{
ToolFunction
toolFunction
=
null
;
if
(
enableSearchEngine
)
{
List
<
Message
>
messages
=
new
ArrayList
<>();
Message
message
=
new
Message
();
message
.
setRole
(
"user"
);
message
.
setContent
(
input
);
messages
.
add
(
message
);
String
[]
unitIds
=
new
String
[
1
];
unitIds
[
0
]
=
"web_search"
;
List
<
Tool
>
tools
=
AgentApplicationTools
.
buildFunctionConfig
(
null
,
"N"
,
dialoguesId
,
dialoguesId
,
unitIds
,
"N"
);
CheckPluginUseEntity
checkPluginUseEntity
=
AgentApplicationTools
.
checkPluginUse
(
messages
,
tools
,
null
);
FunctionCallResult
functionCallResult
=
checkPluginUseEntity
.
getFunctionCallResult
();
if
(
functionCallResult
!=
null
)
{
FunctionCall
functionCall
=
functionCallResult
.
getFunctionCall
();
if
(
"web_search"
.
equals
(
functionCall
.
getName
()))
{
AbstractFunctionResult
<
List
<
WebSearchFunctionResult
>>
functionResult
=
webSearchFunction
.
doFunction
(
functionCall
.
getArguments
(),
dialoguesId
,
null
,
null
);
if
(
functionResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
functionResult
.
getFunctionResult
()))
{
List
<
WebSearchFunctionResult
>
webSearchFunctionResults
=
functionResult
.
getFunctionResult
();
if
(
CollectionUtils
.
isNotEmpty
(
webSearchFunctionResults
))
{
toolFunction
=
new
ToolFunction
();
toolFunction
.
setResult
(
JsonUtils
.
serialize
(
webSearchFunctionResults
));
toolFunction
.
setName
(
"web_search"
);
toolFunction
.
setArguments
(
functionCall
.
getArguments
());
toolFunction
.
setDisplayFormat
(
"json"
);
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
result
.
setFunction
(
toolFunction
);
result
.
setDbChainResult
(
null
);
result
.
setKnowledgeContentResult
(
null
);
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
}
}
}
}
}
return
toolFunction
;
}
}
}
src/main/java/cn/com/poc/long_document/dto/LongTextDialoguesCallDto.java
View file @
fa46d72a
package
cn
.
com
.
poc
.
long_document
.
dto
;
package
cn
.
com
.
poc
.
long_document
.
dto
;
import
java.util.List
;
/**
/**
* @author alex.yao
* @author alex.yao
* @date 2025/6/3
* @date 2025/6/3
...
@@ -28,6 +26,33 @@ public class LongTextDialoguesCallDto {
...
@@ -28,6 +26,33 @@ public class LongTextDialoguesCallDto {
*/
*/
private
Integer
[]
knowledgeIds
;
private
Integer
[]
knowledgeIds
;
/**
* 是否启用搜索引擎
*/
private
Boolean
enableSearchEngine
;
/**
* 是否开启深度思考
*/
private
Boolean
enableDeepThinking
;
public
Boolean
getEnableSearchEngine
()
{
return
enableSearchEngine
;
}
public
void
setEnableSearchEngine
(
Boolean
enableSearchEngine
)
{
this
.
enableSearchEngine
=
enableSearchEngine
;
}
public
Boolean
getEnableDeepThinking
()
{
return
enableDeepThinking
;
}
public
void
setEnableDeepThinking
(
Boolean
enableDeepThinking
)
{
this
.
enableDeepThinking
=
enableDeepThinking
;
}
public
String
getDialoguesId
()
{
public
String
getDialoguesId
()
{
return
dialoguesId
;
return
dialoguesId
;
}
}
...
...
src/main/java/cn/com/poc/long_document/rest/impl/LongTextDialoguesRestImpl.java
View file @
fa46d72a
...
@@ -40,7 +40,7 @@ public class LongTextDialoguesRestImpl implements LongTextDialoguesRest {
...
@@ -40,7 +40,7 @@ public class LongTextDialoguesRestImpl implements LongTextDialoguesRest {
dto
.
getFileUrl
(),
dto
.
getFileUrl
(),
dto
.
getInput
(),
dto
.
getInput
(),
dto
.
getKnowledgeIds
(),
dto
.
getKnowledgeIds
(),
userBaseEntity
.
getUserId
());
userBaseEntity
.
getUserId
()
,
dto
.
getEnableSearchEngine
(),
dto
.
getEnableDeepThinking
()
);
}
}
@Override
@Override
...
...
src/main/java/cn/com/poc/writing/aggregate/AiWritingService.java
View file @
fa46d72a
...
@@ -22,8 +22,10 @@ public interface AiWritingService {
...
@@ -22,8 +22,10 @@ public interface AiWritingService {
* @param input
* @param input
* @param knowledgeIds
* @param knowledgeIds
* @param userId
* @param userId
* @param enableSearchEngine
* @param enableDeepThinking
*/
*/
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
)
throws
Exception
;
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
,
Boolean
enableSearchEngine
,
Boolean
enableDeepThinking
)
throws
Exception
;
/**
/**
...
...
src/main/java/cn/com/poc/writing/aggregate/impl/AiWritingServiceImpl.java
View file @
fa46d72a
package
cn
.
com
.
poc
.
writing
.
aggregate
.
impl
;
package
cn
.
com
.
poc
.
writing
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.entity.CheckPluginUseEntity
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.expose.dto.DialoguesContextDto
;
import
cn.com.poc.expose.dto.DialoguesContextDto
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.FunctionCall
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.ToolFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
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.writing.dto.AiWritingDialoguesContextDto
;
import
cn.com.poc.writing.dto.AiWritingDialoguesContextDto
;
import
cn.com.poc.writing.entity.BizAiWritingDialoguesRecordEntity
;
import
cn.com.poc.writing.entity.BizAiWritingDialoguesRecordEntity
;
import
cn.com.poc.writing.query.AiWritingDialoguesRecordQueryItem
;
import
cn.com.poc.writing.query.AiWritingDialoguesRecordQueryItem
;
...
@@ -42,6 +51,7 @@ import cn.com.poc.writing.service.BizAiWritingExampleTypeService;
...
@@ -42,6 +51,7 @@ import cn.com.poc.writing.service.BizAiWritingExampleTypeService;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -92,9 +102,12 @@ public class AiWritingServiceImpl implements AiWritingService {
...
@@ -92,9 +102,12 @@ public class AiWritingServiceImpl implements AiWritingService {
@Resource
@Resource
private
BizAiWritingExampleTypeService
bizAiWritingExampleTypeService
;
private
BizAiWritingExampleTypeService
bizAiWritingExampleTypeService
;
@Resource
private
WebSearchFunction
webSearchFunction
;
@Override
@Override
public
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
)
throws
Exception
{
public
void
call
(
String
dialoguesId
,
String
fileUrl
,
String
input
,
Integer
[]
knowledgeIds
,
Long
userId
,
Boolean
enableSearchEngine
,
Boolean
enableDeepThinking
)
throws
Exception
{
BizAiDialoguesEntity
bizAiDialoguesEntity
=
new
BizAiDialoguesEntity
();
BizAiDialoguesEntity
bizAiDialoguesEntity
=
new
BizAiDialoguesEntity
();
bizAiDialoguesEntity
.
setDialoguesId
(
dialoguesId
);
bizAiDialoguesEntity
.
setDialoguesId
(
dialoguesId
);
bizAiDialoguesEntity
.
setMemberId
(
userId
);
bizAiDialoguesEntity
.
setMemberId
(
userId
);
...
@@ -168,10 +181,14 @@ public class AiWritingServiceImpl implements AiWritingService {
...
@@ -168,10 +181,14 @@ public class AiWritingServiceImpl implements AiWritingService {
sseUtil
.
send
(
JsonUtils
.
serialize
(
aiWritingTitleGenerationDto
));
sseUtil
.
send
(
JsonUtils
.
serialize
(
aiWritingTitleGenerationDto
));
}
}
// 插件调用
ToolFunction
toolFunction
=
getToolFunction
(
dialoguesId
,
input
,
enableSearchEngine
,
sseUtil
);
//组装请求参数
//组装请求参数
List
<
Message
>
messages
=
buildMessages
(
dialoguesId
,
userId
,
input
,
fileUrl
,
knowledgeResult
,
aiWritingTitleGenerationDto
);
List
<
Message
>
messages
=
buildMessages
(
dialoguesId
,
userId
,
input
,
fileUrl
,
knowledgeResult
,
aiWritingTitleGenerationDto
,
toolFunction
);
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
"deepseek-chat
"
);
largeModelResponse
.
setModel
(
enableDeepThinking
?
"deepseek-chat"
:
"deepseek-v3
"
);
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
0
]));
largeModelResponse
.
setStream
(
true
);
largeModelResponse
.
setStream
(
true
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
...
@@ -205,6 +222,46 @@ public class AiWritingServiceImpl implements AiWritingService {
...
@@ -205,6 +222,46 @@ public class AiWritingServiceImpl implements AiWritingService {
bizAiWritingDialoguesRecordService
.
save
(
assistantRecord
);
bizAiWritingDialoguesRecordService
.
save
(
assistantRecord
);
}
}
private
ToolFunction
getToolFunction
(
String
dialoguesId
,
String
input
,
Boolean
enableSearchEngine
,
SSEUtil
sseUtil
)
throws
IOException
{
ToolFunction
toolFunction
=
null
;
if
(
enableSearchEngine
)
{
List
<
Message
>
messages
=
new
ArrayList
<>();
Message
message
=
new
Message
();
message
.
setRole
(
"user"
);
message
.
setContent
(
input
);
messages
.
add
(
message
);
String
[]
unitIds
=
new
String
[
1
];
unitIds
[
0
]
=
"web_search"
;
List
<
Tool
>
tools
=
AgentApplicationTools
.
buildFunctionConfig
(
null
,
"N"
,
dialoguesId
,
dialoguesId
,
unitIds
,
"N"
);
CheckPluginUseEntity
checkPluginUseEntity
=
AgentApplicationTools
.
checkPluginUse
(
messages
,
tools
,
null
);
FunctionCallResult
functionCallResult
=
checkPluginUseEntity
.
getFunctionCallResult
();
if
(
functionCallResult
!=
null
)
{
FunctionCall
functionCall
=
functionCallResult
.
getFunctionCall
();
if
(
"web_search"
.
equals
(
functionCall
.
getName
()))
{
AbstractFunctionResult
<
List
<
WebSearchFunctionResult
>>
functionResult
=
webSearchFunction
.
doFunction
(
functionCall
.
getArguments
(),
dialoguesId
,
null
,
null
);
if
(
functionResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
functionResult
.
getFunctionResult
()))
{
List
<
WebSearchFunctionResult
>
webSearchFunctionResults
=
functionResult
.
getFunctionResult
();
if
(
CollectionUtils
.
isNotEmpty
(
webSearchFunctionResults
))
{
toolFunction
=
new
ToolFunction
();
toolFunction
.
setResult
(
JsonUtils
.
serialize
(
webSearchFunctionResults
));
toolFunction
.
setName
(
"web_search"
);
toolFunction
.
setArguments
(
functionCall
.
getArguments
());
toolFunction
.
setDisplayFormat
(
"json"
);
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
result
.
setFunction
(
toolFunction
);
result
.
setDbChainResult
(
null
);
result
.
setKnowledgeContentResult
(
null
);
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
}
}
}
}
}
return
toolFunction
;
}
@Override
@Override
public
List
<
AiWritingExampleDto
>
example
(
String
type
)
throws
Exception
{
public
List
<
AiWritingExampleDto
>
example
(
String
type
)
throws
Exception
{
...
@@ -295,7 +352,7 @@ public class AiWritingServiceImpl implements AiWritingService {
...
@@ -295,7 +352,7 @@ public class AiWritingServiceImpl implements AiWritingService {
return
aiWritingTitleGenerationDto
;
return
aiWritingTitleGenerationDto
;
}
}
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
Long
userId
,
String
input
,
String
fileUrl
,
List
<
KnowledgeContentResult
>
knowledgeContentResults
,
AiWritingTitleGenerationDto
aiWritingTitleGenerationDto
)
throws
Exception
{
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
Long
userId
,
String
input
,
String
fileUrl
,
List
<
KnowledgeContentResult
>
knowledgeContentResults
,
AiWritingTitleGenerationDto
aiWritingTitleGenerationDto
,
ToolFunction
toolFunction
)
throws
Exception
{
// 获取对话提示词
// 获取对话提示词
String
promptCode
=
"AiWritingPrompt"
;
String
promptCode
=
"AiWritingPrompt"
;
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
BizAgentApplicationGcConfigEntity
documentDialoguePrompt
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
promptCode
);
...
@@ -325,6 +382,9 @@ public class AiWritingServiceImpl implements AiWritingService {
...
@@ -325,6 +382,9 @@ public class AiWritingServiceImpl implements AiWritingService {
}
else
{
}
else
{
prompt
=
prompt
.
replace
(
"${title}"
,
StringUtils
.
EMPTY
);
prompt
=
prompt
.
replace
(
"${title}"
,
StringUtils
.
EMPTY
);
}
}
if
(
toolFunction
!=
null
)
{
prompt
=
prompt
.
replace
(
"${toolFunction}"
,
JsonUtils
.
serialize
(
toolFunction
));
}
prompt
=
prompt
.
replace
(
"${fileContent}"
,
fileContent
);
prompt
=
prompt
.
replace
(
"${fileContent}"
,
fileContent
);
...
...
src/main/java/cn/com/poc/writing/dto/AiWritingDto.java
View file @
fa46d72a
...
@@ -26,6 +26,34 @@ public class AiWritingDto {
...
@@ -26,6 +26,34 @@ public class AiWritingDto {
*/
*/
private
Integer
[]
knowledgeIds
;
private
Integer
[]
knowledgeIds
;
/**
* 是否启用搜索引擎
*/
private
Boolean
enableSearchEngine
;
/**
* 是否开启深度思考
*/
private
Boolean
enableDeepThinking
;
public
Boolean
getEnableSearchEngine
()
{
return
enableSearchEngine
;
}
public
void
setEnableSearchEngine
(
Boolean
enableSearchEngine
)
{
this
.
enableSearchEngine
=
enableSearchEngine
;
}
public
Boolean
getEnableDeepThinking
()
{
return
enableDeepThinking
;
}
public
void
setEnableDeepThinking
(
Boolean
enableDeepThinking
)
{
this
.
enableDeepThinking
=
enableDeepThinking
;
}
public
String
getDialoguesId
()
{
public
String
getDialoguesId
()
{
return
dialoguesId
;
return
dialoguesId
;
}
}
...
...
src/main/java/cn/com/poc/writing/rest/impl/AiWritingRestImpl.java
View file @
fa46d72a
...
@@ -33,7 +33,8 @@ public class AiWritingRestImpl implements AiWritingRest {
...
@@ -33,7 +33,8 @@ public class AiWritingRestImpl implements AiWritingRest {
throw
new
BusinessException
(
"用户未登录"
);
throw
new
BusinessException
(
"用户未登录"
);
}
}
aiWritingService
.
call
(
aiWritingDto
.
getDialoguesId
(),
aiWritingDto
.
getFileUrl
(),
aiWritingService
.
call
(
aiWritingDto
.
getDialoguesId
(),
aiWritingDto
.
getFileUrl
(),
aiWritingDto
.
getInput
(),
aiWritingDto
.
getKnowledgeIds
(),
userBaseEntity
.
getUserId
());
aiWritingDto
.
getInput
(),
aiWritingDto
.
getKnowledgeIds
(),
userBaseEntity
.
getUserId
(),
aiWritingDto
.
getEnableSearchEngine
(),
aiWritingDto
.
getEnableDeepThinking
());
}
}
...
...
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