Skip to content

Commit 95659b4

Browse files
committed
feat:add long-term memory and update weather tool
1 parent ddf961d commit 95659b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1537
-55
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mysql,redis,emqx和influxdb环境。
8888
欢迎加入群聊一起交流讨论有关Aiot相关的话题,免费获取智控台的前端源码,链接过期了可以issue或email提醒一下作者。
8989

9090
<div style="width: 250px;margin: 0 auto;">
91-
<img src="./images/728a85f486074938ba54d89a6eb6171f.jpg" width="250px"/>
91+
<img src="./images/f05e3fe25dd4196e9abfbe4d8d2b8ed1.jpg" width="250px"/>
9292
</div>
9393

9494

-163 KB
Binary file not shown.
166 KB
Loading

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mysql,redis,emqx和influxdb环境,安装详情请看官方文档。
116116
欢迎加入群聊一起交流讨论有关Aiot相关的话题,有机会获取项目的免费部署咨询,链接过期了可以issue或email提醒一下作者。
117117

118118
<div style="width: 250px;margin: 0 auto;">
119-
<img src="./docs/images/728a85f486074938ba54d89a6eb6171f.jpg" width="250px"/>
119+
<img src="./docs/images/f05e3fe25dd4196e9abfbe4d8d2b8ed1.jpg" width="250px"/>
120120
</div>
121121

122122
## 致谢

src/main/java/top/rslly/iot/controllers/Tool.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public class Tool {
8181
private OtaXiaozhiPassiveServiceImpl otaXiaozhiPassiveService;
8282
@Autowired
8383
private ProductToolsBanServiceImpl productToolsBanService;
84+
@Autowired
85+
private AgentLongMemoryServiceImpl agentLongMemoryService;
8486

8587
@Operation(summary = "用于获取平台运行环境信息", description = "单位为百分比")
8688
@RequestMapping(value = "/machineMessage", method = RequestMethod.GET)
@@ -490,4 +492,38 @@ public JsonResult<?> deleteProductToolsBan(@RequestParam("productId") int produc
490492
return productToolsBanService.deleteProductToolsBan(productId);
491493
}
492494

495+
// 长期记忆
496+
@Operation(summary = "获取长期记忆", description = "获取长期记忆")
497+
@RequestMapping(value = "/longMemory", method = RequestMethod.GET)
498+
public JsonResult<?> getLongMemory(@RequestHeader("Authorization") String header) {
499+
return agentLongMemoryService.getLongMemory(header);
500+
}
501+
502+
@Operation(summary = "提交/修改长期记忆详情", description = "提交/修改长期记忆")
503+
@RequestMapping(value = "/longMemory", method = RequestMethod.POST)
504+
public JsonResult<?> postLongMemory(
505+
@Valid @RequestBody AgentLongMemory agentLongMemory,
506+
@RequestHeader("Authorization") String header) {
507+
try {
508+
if (!safetyService.controlAuthorizeProduct(header, agentLongMemory.getProductId()))
509+
return ResultTool.fail(ResultCode.NO_PERMISSION);
510+
} catch (NullPointerException e) {
511+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
512+
}
513+
return agentLongMemoryService.postLongMemory(agentLongMemory);
514+
}
515+
516+
@Operation(summary = "删除长期记忆", description = "删除长期记忆")
517+
@RequestMapping(value = "/longMemory", method = RequestMethod.DELETE)
518+
public JsonResult<?> deleteLongMemory(@RequestParam("id") int id,
519+
@RequestHeader("Authorization") String header) {
520+
try {
521+
if (!safetyService.controlAuthorizeAgentLongMemory(header, id))
522+
return ResultTool.fail(ResultCode.NO_PERMISSION);
523+
} catch (NullPointerException e) {
524+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
525+
}
526+
return agentLongMemoryService.deleteLongMemory(id);
527+
}
528+
493529
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.dao;
21+
22+
import org.springframework.data.jpa.repository.JpaRepository;
23+
import org.springframework.transaction.annotation.Transactional;
24+
import top.rslly.iot.models.AgentLongMemoryEntity;
25+
26+
import java.util.List;
27+
28+
public interface AgentLongMemoryRepository extends JpaRepository<AgentLongMemoryEntity, Integer> {
29+
List<AgentLongMemoryEntity> findAllById(int id);
30+
31+
List<AgentLongMemoryEntity> findAllByProductId(int productId);
32+
33+
List<AgentLongMemoryEntity> findAllByProductIdAndMemoryKey(int productId, String memoryKey);
34+
35+
@Transactional
36+
List<AgentLongMemoryEntity> deleteAllById(int id);
37+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.models;
21+
22+
import javax.persistence.*;
23+
import java.util.Objects;
24+
25+
@Entity
26+
@Table(name = "agent_long_memory", schema = "cwliot1.8", catalog = "")
27+
public class AgentLongMemoryEntity {
28+
private int id;
29+
private int productId;
30+
private String memoryKey;
31+
private String description;
32+
private String memoryValue;
33+
34+
@Id
35+
@GeneratedValue(strategy = GenerationType.IDENTITY)
36+
@Column(name = "id")
37+
public int getId() {
38+
return id;
39+
}
40+
41+
public void setId(int id) {
42+
this.id = id;
43+
}
44+
45+
@Basic
46+
@Column(name = "product_id")
47+
public int getProductId() {
48+
return productId;
49+
}
50+
51+
public void setProductId(int productId) {
52+
this.productId = productId;
53+
}
54+
55+
@Basic
56+
@Column(name = "memory_key")
57+
public String getMemoryKey() {
58+
return memoryKey;
59+
}
60+
61+
public void setMemoryKey(String memoryKey) {
62+
this.memoryKey = memoryKey;
63+
}
64+
65+
@Basic
66+
@Column(name = "description")
67+
public String getDescription() {
68+
return description;
69+
}
70+
71+
public void setDescription(String description) {
72+
this.description = description;
73+
}
74+
75+
@Basic
76+
@Column(name = "memory_value")
77+
public String getMemoryValue() {
78+
return memoryValue;
79+
}
80+
81+
public void setMemoryValue(String memoryValue) {
82+
this.memoryValue = memoryValue;
83+
}
84+
85+
@Override
86+
public boolean equals(Object o) {
87+
if (this == o)
88+
return true;
89+
if (o == null || getClass() != o.getClass())
90+
return false;
91+
AgentLongMemoryEntity that = (AgentLongMemoryEntity) o;
92+
return id == that.id && productId == that.productId && Objects.equals(memoryKey, that.memoryKey)
93+
&& Objects.equals(description, that.description)
94+
&& Objects.equals(memoryValue, that.memoryValue);
95+
}
96+
97+
@Override
98+
public int hashCode() {
99+
return Objects.hash(id, productId, memoryKey, description, memoryValue);
100+
}
101+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.param.prompt;
21+
22+
import lombok.Data;
23+
24+
@Data
25+
public class AgentLongMemoryDescription {
26+
private String memoryKey;
27+
private String description;
28+
private String memoryValue;
29+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.param.request;
21+
22+
import lombok.Data;
23+
24+
import javax.validation.constraints.NotBlank;
25+
import javax.validation.constraints.Size;
26+
27+
@Data
28+
public class AgentLongMemory {
29+
private int productId;
30+
@NotBlank(message = "memoryKey 不能为空")
31+
@Size(min = 1, max = 255, message = "memoryKey 长度必须在 1 到 255 之间")
32+
private String memoryKey;
33+
@NotBlank(message = "description 不能为空")
34+
@Size(min = 1, max = 255, message = "description 长度必须在 1 到 255 之间")
35+
private String description;
36+
@NotBlank(message = "memoryValue 不能为空")
37+
@Size(min = 1, max = 1024, message = "memoryValue 长度必须在 1 到 1024 之间")
38+
private String memoryValue;
39+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.param.request;
21+
22+
import lombok.Data;
23+
24+
@Data
25+
public class AgentLongMemoryToolParam {
26+
private int productId;
27+
private String memoryKey;
28+
private String memoryValue;
29+
}

0 commit comments

Comments
 (0)