Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ask_data_ai_admin
Project
Project
Details
Activity
Releases
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
linyangyang
ask_data_ai_admin
Commits
8fde3496
Commit
8fde3496
authored
Jul 31, 2025
by
林洋洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化提示词
parent
550d9a7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
ChatController.java
...-biz/src/main/java/com/ask/controller/ChatController.java
+15
-1
ExcelTools.java
...k-data-ai-biz/src/main/java/com/ask/tools/ExcelTools.java
+4
-3
No files found.
ask-data-ai/ask-data-ai-biz/src/main/java/com/ask/controller/ChatController.java
View file @
8fde3496
...
@@ -49,6 +49,8 @@ import org.springframework.web.bind.annotation.*;
...
@@ -49,6 +49,8 @@ import org.springframework.web.bind.annotation.*;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicBoolean
;
...
@@ -213,7 +215,19 @@ public class ChatController {
...
@@ -213,7 +215,19 @@ public class ChatController {
@RequestParam
String
conversationId
,
@RequestParam
String
conversationId
,
@RequestParam
(
required
=
false
)
Optional
<
Long
>
modelId
)
{
@RequestParam
(
required
=
false
)
Optional
<
Long
>
modelId
)
{
Long
actualModelId
=
modelId
.
orElse
(
1L
);
Long
actualModelId
=
modelId
.
orElse
(
1L
);
Message
systemMessage
=
new
SystemMessage
(
"你是一个AI问答助手,请用回答用户问题,使用相关工具"
);
String
now
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-M-d HH:mm:ss"
));
Message
systemMessage
=
new
SystemMessage
(
String
.
format
(
"你是一位“工具优先”的 AI 问答助手。\n"
+
"1.先判断是否需要调用工具获取最新信息;如需要,立即调用。\n"
+
"2.将工具返回的结构化数据整理成简洁、可落地的自然语言答案。\n"
+
"3.默认当前时间为 %s,使用表格或代码块清晰展示关键信息。\n"
+
"4.若无法调用工具,说明原因并给出替代方案。\n"
+
"5.遵守中国法律,拒绝敏感或违法内容。"
,
now
)
);
Message
userMessage
=
new
UserMessage
(
message
);
Message
userMessage
=
new
UserMessage
(
message
);
Prompt
prompt
=
new
Prompt
(
List
.
of
(
systemMessage
,
userMessage
));
Prompt
prompt
=
new
Prompt
(
List
.
of
(
systemMessage
,
userMessage
));
ChatClient
chatClient
=
askModelService
.
getChatClientById
(
actualModelId
);
ChatClient
chatClient
=
askModelService
.
getChatClientById
(
actualModelId
);
...
...
ask-data-ai/ask-data-ai-biz/src/main/java/com/ask/tools/ExcelTools.java
View file @
8fde3496
...
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
...
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.ai.tool.annotation.Tool
;
import
org.springframework.ai.tool.annotation.Tool
;
import
org.springframework.ai.tool.annotation.ToolParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -89,8 +90,8 @@ public class ExcelTools {
...
@@ -89,8 +90,8 @@ public class ExcelTools {
return
date
.
format
(
formatter
);
return
date
.
format
(
formatter
);
}
}
@Tool
(
description
=
"获取科环集团电力运营日报
,入参时间(yyyy-M-d)
"
)
@Tool
(
description
=
"获取科环集团电力运营日报"
)
public
String
getProductionFile
(
String
dateStr
)
{
public
String
getProductionFile
(
@ToolParam
(
description
=
"时间(yyyy-M-d)"
)
String
dateStr
)
{
log
.
info
(
"getProductionFile{}"
,
dateStr
);
log
.
info
(
"getProductionFile{}"
,
dateStr
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-M-d"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-M-d"
);
LocalDate
date
=
LocalDate
.
parse
(
dateStr
,
formatter
);
LocalDate
date
=
LocalDate
.
parse
(
dateStr
,
formatter
);
...
@@ -124,7 +125,7 @@ public class ExcelTools {
...
@@ -124,7 +125,7 @@ public class ExcelTools {
}
}
@Tool
(
description
=
"获取天津智深DCS卡件日报"
,
returnDirect
=
true
)
@Tool
(
description
=
"获取天津智深DCS卡件日报"
,
returnDirect
=
true
)
public
String
getDcsFile
(
String
dateStr
)
{
public
String
getDcsFile
(
@ToolParam
(
description
=
"时间(yyyy-M-d)"
)
String
dateStr
)
{
var
ref
=
new
Object
()
{
var
ref
=
new
Object
()
{
String
markDown
=
"| 产线 | 计划产量 | 实际产量 | 成品率 |\n"
+
String
markDown
=
"| 产线 | 计划产量 | 实际产量 | 成品率 |\n"
+
...
...
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