Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
konke-ai-alibaba-mcp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何金镒
konke-ai-alibaba-mcp
Commits
c8d56664
Commit
c8d56664
authored
Sep 02, 2025
by
何金镒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dify token
parent
64de612b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
102 additions
and
26 deletions
+102
-26
src/main/java/com/ikonke/konkeaialibabamcp/aitools/CDCSpacesTools.java
.../com/ikonke/konkeaialibabamcp/aitools/CDCSpacesTools.java
+4
-4
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
...ava/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
+14
-14
src/main/java/com/ikonke/konkeaialibabamcp/aitools/WeatherTools.java
...va/com/ikonke/konkeaialibabamcp/aitools/WeatherTools.java
+3
-3
src/main/java/com/ikonke/konkeaialibabamcp/config/ToolCategory.java
...ava/com/ikonke/konkeaialibabamcp/config/ToolCategory.java
+13
-0
src/main/java/com/ikonke/konkeaialibabamcp/constant/RedisKeys.java
...java/com/ikonke/konkeaialibabamcp/constant/RedisKeys.java
+2
-0
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
...m/ikonke/konkeaialibabamcp/controller/DifyController.java
+17
-1
src/main/resources/application-prod.yml
src/main/resources/application-prod.yml
+5
-2
src/main/resources/application.yml
src/main/resources/application.yml
+6
-0
提示词.md
提示词.md
+38
-2
No files found.
src/main/java/com/ikonke/konkeaialibabamcp/aitools/CDCSpacesTools.java
View file @
c8d56664
...
@@ -19,7 +19,7 @@ public class CDCSpacesTools {
...
@@ -19,7 +19,7 @@ public class CDCSpacesTools {
this
.
spacesService
=
spacesService
;
this
.
spacesService
=
spacesService
;
}
}
@Tool
(
description
=
"根据房间(场所)ID和日期查询该日期可预约情况"
)
@Tool
(
description
=
"
场所(会所、共享空间)相关:
根据房间(场所)ID和日期查询该日期可预约情况"
)
public
JSONObject
getAppointmentTimeByRoomId
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
public
JSONObject
getAppointmentTimeByRoomId
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
@ToolParam
(
description
=
"查询的日期,如:2025-08-12"
)
String
date
,
@ToolParam
(
description
=
"查询的日期,如:2025-08-12"
)
String
date
,
@ToolParam
(
description
=
"查询的房间(场所)ID"
)
String
roomId
,
@ToolParam
(
description
=
"查询的房间(场所)ID"
)
String
roomId
,
...
@@ -28,14 +28,14 @@ public class CDCSpacesTools {
...
@@ -28,14 +28,14 @@ public class CDCSpacesTools {
return
spacesService
.
getAppointmentTimeByRoomId
(
sn
,
date
,
roomId
,
subspaceId
);
return
spacesService
.
getAppointmentTimeByRoomId
(
sn
,
date
,
roomId
,
subspaceId
);
}
}
@Tool
(
description
=
"获取可使用的优惠卷"
)
@Tool
(
description
=
"
场所(会所、共享空间)相关:
获取可使用的优惠卷"
)
public
JSONArray
getUserSpacesCoupons
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
public
JSONArray
getUserSpacesCoupons
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
@ToolParam
(
description
=
"查询的房间(场所)ID,若不传就查询所有房间(场所)的优惠券"
,
required
=
false
)
String
roomId
){
@ToolParam
(
description
=
"查询的房间(场所)ID,若不传就查询所有房间(场所)的优惠券"
,
required
=
false
)
String
roomId
){
log
.
info
(
"mcp调用--->getUserCoupons..获取用户优惠券..sn:{},roomId:{}"
,
sn
,
roomId
);
log
.
info
(
"mcp调用--->getUserCoupons..获取用户优惠券..sn:{},roomId:{}"
,
sn
,
roomId
);
return
spacesService
.
getUserCoupons
(
sn
,
roomId
);
return
spacesService
.
getUserCoupons
(
sn
,
roomId
);
}
}
@Tool
(
description
=
"获取在某个时间段可使用的优惠卷"
)
@Tool
(
description
=
"
场所(会所、共享空间)相关:
获取在某个时间段可使用的优惠卷"
)
public
JSONArray
getUserSpacesCouponsByTime
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
public
JSONArray
getUserSpacesCouponsByTime
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
@ToolParam
(
description
=
"使用的开始时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 09:00:00"
)
String
beginTime
,
@ToolParam
(
description
=
"使用的开始时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 09:00:00"
)
String
beginTime
,
@ToolParam
(
description
=
"使用的结束时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 10:30:00"
)
String
endTime
,
@ToolParam
(
description
=
"使用的结束时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 10:30:00"
)
String
endTime
,
...
@@ -64,7 +64,7 @@ public class CDCSpacesTools {
...
@@ -64,7 +64,7 @@ public class CDCSpacesTools {
// return e.getMessage();
// return e.getMessage();
// }
// }
// }
// }
@Tool
(
description
=
"自动查找优惠卷并使用优惠券预订房间(场所)"
)
@Tool
(
description
=
"
场所(会所、共享空间)相关:
自动查找优惠卷并使用优惠券预订房间(场所)"
)
public
String
bookingSpaces
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
public
String
bookingSpaces
(
@ToolParam
(
description
=
"设备的sn号,如:00226DA86A12"
)
String
sn
,
@ToolParam
(
description
=
"使用的开始时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 09:00:00"
)
String
beginTime
,
@ToolParam
(
description
=
"使用的开始时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 09:00:00"
)
String
beginTime
,
@ToolParam
(
description
=
"使用的结束时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 10:30:00"
)
String
endTime
,
@ToolParam
(
description
=
"使用的结束时间,必须是30分钟的倍数且不能隔天预约,如:2025-08-12 10:30:00"
)
String
endTime
,
...
...
src/main/java/com/ikonke/konkeaialibabamcp/aitools/DeviceTools.java
View file @
c8d56664
...
@@ -25,27 +25,27 @@ public class DeviceTools {
...
@@ -25,27 +25,27 @@ public class DeviceTools {
this
.
sycDeviceService
=
sycDeviceService
;
this
.
sycDeviceService
=
sycDeviceService
;
}
}
@Tool
(
description
=
"根据主机号和设备ID查询设备状态信息."
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID查询设备状态信息."
)
public
DeviceStatus
findDeviceState
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
DeviceStatus
findDeviceState
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
Integer
devId
)
{
@ToolParam
(
description
=
"设备ID"
)
Integer
devId
)
{
log
.
info
(
"mcp调用--->根据主机号和设备ID查询设备状态信息....ccuName:{},devId:{}"
,
ccuName
,
devId
);
log
.
info
(
"mcp调用--->根据主机号和设备ID查询设备状态信息....ccuName:{},devId:{}"
,
ccuName
,
devId
);
return
deviceStatusUtil
.
findUserByUserId
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
return
deviceStatusUtil
.
findUserByUserId
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
);
}
}
@Tool
(
description
=
"根据主机号同步设备"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号同步设备"
)
public
boolean
synchronousDevice
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
){
public
boolean
synchronousDevice
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
){
log
.
info
(
"mcp调用--->根据主机号同步设备....ccuName:{}"
,
ccuName
);
log
.
info
(
"mcp调用--->根据主机号同步设备....ccuName:{}"
,
ccuName
);
return
sycDeviceService
.
synchronousDevice
(
CcuUtils
.
getCcuName
(
ccuName
));
return
sycDeviceService
.
synchronousDevice
(
CcuUtils
.
getCcuName
(
ccuName
));
}
}
//==============================设备控制=============================================
//==============================设备控制=============================================
@Tool
(
description
=
"根据主机号和设备ID控制:打开设备"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:打开设备"
)
public
String
optDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
optDeviceOpen
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制打开设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
return
konkeIotServer
.
optDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
return
konkeIotServer
.
optDeviceOpen
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制:关闭设备"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:关闭设备"
)
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
optDeviceClosed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
...
@@ -53,7 +53,7 @@ public class DeviceTools {
...
@@ -53,7 +53,7 @@ public class DeviceTools {
return
konkeIotServer
.
optDeviceClosed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
return
konkeIotServer
.
optDeviceClosed
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制:设置亮度"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:设置亮度"
)
public
String
setBrightness
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setBrightness
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -61,7 +61,7 @@ public class DeviceTools {
...
@@ -61,7 +61,7 @@ public class DeviceTools {
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备亮度....ccuName:{},devId:{},type:{},brightness:{}"
,
ccuName
,
devId
,
typeId
,
brightness
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备亮度....ccuName:{},devId:{},type:{},brightness:{}"
,
ccuName
,
devId
,
typeId
,
brightness
);
return
konkeIotServer
.
setBrightness
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
brightness
);
return
konkeIotServer
.
setBrightness
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
brightness
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制:设置色温"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:设置色温"
)
public
String
setColourTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setColourTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -69,7 +69,7 @@ public class DeviceTools {
...
@@ -69,7 +69,7 @@ public class DeviceTools {
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备的色温....ccuName:{},devId:{},type:{},colourTemperature:{}"
,
ccuName
,
devId
,
typeId
,
colourTemperature
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制设备的色温....ccuName:{},devId:{},type:{},colourTemperature:{}"
,
ccuName
,
devId
,
typeId
,
colourTemperature
);
return
konkeIotServer
.
setColourTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
colourTemperature
);
return
konkeIotServer
.
setColourTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
colourTemperature
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制:设置显示的颜色"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:设置显示的颜色"
)
public
String
setColor
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setColor
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -78,14 +78,14 @@ public class DeviceTools {
...
@@ -78,14 +78,14 @@ public class DeviceTools {
return
konkeIotServer
.
setColor
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
color
);
return
konkeIotServer
.
setColor
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
color
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制:暂停设备.只支持窗帘类型"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制:暂停设备.只支持窗帘类型"
)
public
String
setPause
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setPause
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
){
log
.
info
(
"mcp调用--->根据主机号和设备ID控制暂停设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
log
.
info
(
"mcp调用--->根据主机号和设备ID控制暂停设备....ccuName:{},devId:{},type:{}"
,
ccuName
,
devId
,
typeId
);
return
konkeIotServer
.
setPause
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
return
konkeIotServer
.
setPause
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制设备:移动位置.只支持窗帘电机(CURTAIN_MOTOR)类型"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制设备:移动位置.只支持窗帘电机(CURTAIN_MOTOR)类型"
)
public
String
setMove
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setMove
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -94,7 +94,7 @@ public class DeviceTools {
...
@@ -94,7 +94,7 @@ public class DeviceTools {
return
konkeIotServer
.
setMove
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
progress
);
return
konkeIotServer
.
setMove
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
progress
);
}
}
@Tool
(
description
=
"根据主机号和设备ID控制设备:延时关机.只支持新风、地暖、空调"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID控制设备:延时关机.只支持新风、地暖、空调"
)
public
String
setDelayedShutdown
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setDelayedShutdown
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -103,7 +103,7 @@ public class DeviceTools {
...
@@ -103,7 +103,7 @@ public class DeviceTools {
return
konkeIotServer
.
setDelayedShutdown
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
delayTime
);
return
konkeIotServer
.
setDelayedShutdown
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
delayTime
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作温度.只支持空调、地暖"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID设置设备的工作温度.只支持空调、地暖"
)
public
String
setTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setTemperature
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -111,7 +111,7 @@ public class DeviceTools {
...
@@ -111,7 +111,7 @@ public class DeviceTools {
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作温度....ccuName:{},devId:{},type:{},temperature:{}"
,
ccuName
,
devId
,
typeId
,
temperature
);
log
.
info
(
"mcp调用--->根据主机号和设备ID设置设备的工作温度....ccuName:{},devId:{},type:{},temperature:{}"
,
ccuName
,
devId
,
typeId
,
temperature
);
return
konkeIotServer
.
setTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
temperature
);
return
konkeIotServer
.
setTemperature
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
temperature
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作模式.只支持地暖、空调、新风"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID设置设备的工作模式.只支持地暖、空调、新风"
)
public
String
setModel
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setModel
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -120,7 +120,7 @@ public class DeviceTools {
...
@@ -120,7 +120,7 @@ public class DeviceTools {
return
konkeIotServer
.
setModel
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
mode
);
return
konkeIotServer
.
setModel
(
CcuUtils
.
getCcuName
(
ccuName
),
devId
,
typeId
,
mode
);
}
}
@Tool
(
description
=
"根据主机号和设备ID设置设备的工作风速.只支持空调、新风"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和设备ID设置设备的工作风速.只支持空调、新风"
)
public
String
setSpeed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
setSpeed
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备ID"
)
String
devId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
@ToolParam
(
description
=
"设备类型ID"
)
String
typeId
,
...
@@ -131,7 +131,7 @@ public class DeviceTools {
...
@@ -131,7 +131,7 @@ public class DeviceTools {
@Tool
(
description
=
"根据主机号和场景ID:触发场景"
)
@Tool
(
description
=
"
智能家居相关:
根据主机号和场景ID:触发场景"
)
public
String
triggerScene
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
public
String
triggerScene
(
@ToolParam
(
description
=
"主机号"
)
String
ccuName
,
@ToolParam
(
description
=
"场景ID"
)
String
devId
,
@ToolParam
(
description
=
"场景ID"
)
String
devId
,
@ToolParam
(
description
=
"场景类型ID,type等于scene"
)
String
typeId
){
@ToolParam
(
description
=
"场景类型ID,type等于scene"
)
String
typeId
){
...
...
src/main/java/com/ikonke/konkeaialibabamcp/aitools/WeatherTools.java
View file @
c8d56664
...
@@ -16,17 +16,17 @@ public class WeatherTools {
...
@@ -16,17 +16,17 @@ public class WeatherTools {
}
}
@Tool
(
description
=
"根据城市名查询当前的天气"
)
@Tool
(
description
=
"
天气相关:
根据城市名查询当前的天气"
)
public
String
getWeatherNow
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
public
String
getWeatherNow
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
log
.
info
(
"mcp调用--->根据城市名查询当前的天气....city:{}"
,
city
);
log
.
info
(
"mcp调用--->根据城市名查询当前的天气....city:{}"
,
city
);
return
weatherUtils
.
getWeatherNow
(
city
);
return
weatherUtils
.
getWeatherNow
(
city
);
}
}
@Tool
(
description
=
"根据城市名查询未来24小时的天气"
)
@Tool
(
description
=
"
天气相关:
根据城市名查询未来24小时的天气"
)
public
String
getWeatherHourly
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
public
String
getWeatherHourly
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
log
.
info
(
"mcp调用--->根据城市名查询未来24小时的天气...city:{}"
,
city
);
log
.
info
(
"mcp调用--->根据城市名查询未来24小时的天气...city:{}"
,
city
);
return
weatherUtils
.
getWeatherHourly
(
city
);
return
weatherUtils
.
getWeatherHourly
(
city
);
}
}
@Tool
(
description
=
"根据城市名查询未来7天的天气"
)
@Tool
(
description
=
"
天气相关:
根据城市名查询未来7天的天气"
)
public
String
getWeatherDaily
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
public
String
getWeatherDaily
(
@ToolParam
(
description
=
"城市,如:成都、西安"
)
String
city
){
log
.
info
(
"mcp调用--->根据城市名查询未来7天的天气....city:{}"
,
city
);
log
.
info
(
"mcp调用--->根据城市名查询未来7天的天气....city:{}"
,
city
);
return
weatherUtils
.
getWeatherDaily
(
city
);
return
weatherUtils
.
getWeatherDaily
(
city
);
...
...
src/main/java/com/ikonke/konkeaialibabamcp/config/ToolCategory.java
0 → 100644
View file @
c8d56664
package
com.ikonke.konkeaialibabamcp.config
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Target
({
ElementType
.
TYPE
,
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
ToolCategory
{
String
value
();
}
src/main/java/com/ikonke/konkeaialibabamcp/constant/RedisKeys.java
View file @
c8d56664
...
@@ -11,4 +11,6 @@ public class RedisKeys {
...
@@ -11,4 +11,6 @@ public class RedisKeys {
public
static
final
String
KONKE_DIFY_CONVERSATION_ID
=
"konke:dify:conversationid:"
;
public
static
final
String
KONKE_DIFY_CONVERSATION_ID
=
"konke:dify:conversationid:"
;
public
static
final
String
KONKE_DIFY_API_KEY
=
"konke:dify:api:key"
;
}
}
src/main/java/com/ikonke/konkeaialibabamcp/controller/DifyController.java
View file @
c8d56664
...
@@ -12,8 +12,10 @@ import com.ikonke.konkeaialibabamcp.controller.param.DifyStreamResponse;
...
@@ -12,8 +12,10 @@ import com.ikonke.konkeaialibabamcp.controller.param.DifyStreamResponse;
import
com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken
;
import
com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken
;
import
com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService
;
import
com.ikonke.konkeaialibabamcp.service.mysqlservice.ICDCTokenService
;
import
com.ikonke.konkeaialibabamcp.utils.CcuUtils
;
import
com.ikonke.konkeaialibabamcp.utils.CcuUtils
;
import
jakarta.annotation.PostConstruct
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -34,7 +36,21 @@ public class DifyController {
...
@@ -34,7 +36,21 @@ public class DifyController {
@Autowired
@Autowired
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
private
final
static
String
dify_api_key
=
"app-YHXQcZVzokkdsrQ3mTOFhO9x"
;
@Value
(
"${dify.token}"
)
private
String
dify_api_key
;
@PostConstruct
public
void
init
()
{
Object
redisValue
=
redisTemplate
.
opsForValue
().
get
(
RedisKeys
.
KONKE_DIFY_API_KEY
);
// 如果Redis中有值,则使用Redis中的值覆盖配置文件的值
if
(
redisValue
!=
null
)
{
this
.
dify_api_key
=
redisValue
.
toString
();
log
.
info
(
"Using Dify API key from Redis: {}"
,
this
.
dify_api_key
);
}
else
{
log
.
info
(
"Using Dify API key from configuration file: {}"
,
this
.
dify_api_key
);
}
}
@GetMapping
(
"/chatMessages"
)
@GetMapping
(
"/chatMessages"
)
...
...
src/main/resources/application-prod.yml
View file @
c8d56664
...
@@ -28,16 +28,19 @@ mybatis-plus:
...
@@ -28,16 +28,19 @@ mybatis-plus:
logging
:
logging
:
level
:
level
:
org.springframework.cloud.sleuth
:
DEBUG
root
:
info
root
:
info
file
:
file
:
path
:
./log/${server.port}
path
:
./log/${server.port}
pattern
:
pattern
:
file
:
'
%d{yyyy/MM/dd
HH:mm:ss.SSS}
%-5level
[%X{traceId:-}][%thread]
%logger{15}
:
%msg%n'
file
:
'
%d{yyyy/MM/dd
HH:mm:ss.SSS}
%-5level
[%X{traceId:-},%X{spanId:-}][%thread]
%logger{15}
:
%msg%n'
console
:
'
%d{yyyy/MM/dd
HH:mm:ss.SSS}
%clr(%-5level)
[%X{traceId:-}][%magenta(%thread)]
%cyan(%logger{15})
:
%msg%n'
console
:
'
%d{yyyy/MM/dd
HH:mm:ss.SSS}
%clr(%-5level)
[%X{traceId:-},%X{spanId:-}][%magenta(%thread)]
%cyan(%logger{15})
:
%msg%n'
# level: "%5p [${spring.application.name},%X{traceId},%X{spanId}]"
logback
:
logback
:
rollingpolicy
:
rollingpolicy
:
max-history
:
30
max-history
:
30
konke
:
konke
:
weather
:
weather
:
clientId
:
da4c19db2be64671
clientId
:
da4c19db2be64671
...
...
src/main/resources/application.yml
View file @
c8d56664
...
@@ -18,3 +18,9 @@ spring:
...
@@ -18,3 +18,9 @@ spring:
resource
:
true
resource
:
true
prompt
:
true
prompt
:
true
completion
:
true
completion
:
true
enabled
:
true
dify
:
token
:
app-YHXQcZVzokkdsrQ3mTOFhO9x
提示词.md
View file @
c8d56664
-
测试主机
-
测试主机
### 设备控制与状态查询
```
你是一个智能家居设备控制专家,具备设备状态查询和场景触发的专业能力,能够准确解析用户指令并调用相应的MCP服务完成操作。
你的任务是根据用户输入的指令,结合用户的主机号({{#1754485785703.ccuName#}})和可操作设备及场景信息({{#1754554523017.body#}}),通过调用对应的MCP服务来执行设备控制、场景触发和设备状态查询功能。
- 内容范围:仅限于设备控制、场景触发和设备状态查询操作
- 输出格式:简洁的中文回复,直接告知用户操作结果或查询信息
- 语言风格:专业、简洁、友好
- 长度限制:50-100字
- 执行设备操作必须调用对应的mcp函数
- 查询设备的状态必须调用mcp函数:findDeviceState
- 禁止不调用MCP服务直接回复用户设备状态
- 对于type等于scene的场景,只能使用triggerScene函数触发
- 场景没有状态查询功能,遇到场景状态查询请求需明确告知用户
- 所有回复必须使用中文且保持简洁明了
```
-
执行设备操作必须调用mcp函数:optDeviceOpen、optDeviceClosed、setBrightness、setColourTemperature、setColor、setPause、setMove、setDelayedShutdown、setTemperature、setModel、setSpeed
# 设备控制
# 设备控制
## 任务
## 任务
根据用户的
输入的主机号{{#1754485785703.ccuName#}}和可操作的设备:{{#1754554523017.body#}}
再调用对应的mcp服务来完成用户的控制设备的需求
根据用户的
主机号{{#1754485785703.ccuName#}}和可操作的设备:{{#1754554523017.body#}}
再调用对应的mcp服务来完成用户的控制设备的需求
## 注意
## 注意
控制设备操作必须调用mcp服务,严禁不调用mcp服务直接回复用户
控制设备操作必须调用mcp服务,严禁不调用mcp服务直接回复用户
## 任务
根据用户的输入 {{#sys.query#}} 和您管理的主机号{{#1754485785703.ccuName#}}和可操作的设备:{{#1754554523017.body#}} 调用对应的mcp服务来完成用户的查询设备状态的需求
## 注意
查询设备状态操作必须调用mcp服务,严禁不调用mcp服务直接回复用
# 设备状态查询
# 设备状态查询
## 任务
## 任务
根据用户的输入
的
主机号{{#1754485785703.ccuName#}}和可操作的设备:{{#17546471575190.body#}}再调用对应的mcp服务来完成用户的查询设备状态的需求
根据用户的输入主机号{{#1754485785703.ccuName#}}和可操作的设备:{{#17546471575190.body#}}再调用对应的mcp服务来完成用户的查询设备状态的需求
## 注意
## 注意
查询设备状态操作必须调用mcp服务,严禁不调用mcp服务直接回复用户
查询设备状态操作必须调用mcp服务,严禁不调用mcp服务直接回复用户
# 会所优惠券查询
# 会所优惠券查询
## 任务
## 任务
根据会所信息调用合适的mcp函数来获取某个场所可使用的优惠卷
根据会所信息调用合适的mcp函数来获取某个场所可使用的优惠卷
...
...
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