工业互联网平台2.0版本后端代码
houzhongjian
2025-06-05 ca6ad5acfb389b852211355c4a56c71769a018c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.iailab.module.ai.service.model;
 
import com.iailab.framework.ai.core.model.midjourney.api.MidjourneyApi;
import com.iailab.framework.ai.core.model.suno.api.SunoApi;
import com.iailab.framework.common.pojo.PageResult;
import com.iailab.module.ai.controller.admin.model.vo.model.AiModelPageReqVO;
import com.iailab.module.ai.controller.admin.model.vo.model.AiModelSaveReqVO;
import com.iailab.module.ai.dal.dataobject.model.AiModelDO;
import jakarta.validation.Valid;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.image.ImageModel;
import org.springframework.ai.vectorstore.VectorStore;
 
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
 
/**
 * AI 模型 Service 接口
 *
 * @author fansili
 * @since 2024/4/24 19:42
 */
public interface AiModelService {
 
    /**
     * 创建模型
     *
     * @param createReqVO 创建信息
     * @return 编号
     */
    Long createModel(@Valid AiModelSaveReqVO createReqVO);
 
    /**
     * 更新模型
     *
     * @param updateReqVO 更新信息
     */
    void updateModel(@Valid AiModelSaveReqVO updateReqVO);
 
    /**
     * 删除模型
     *
     * @param id 编号
     */
    void deleteModel(Long id);
 
    /**
     * 获得模型
     *
     * @param id 编号
     * @return 模型
     */
    AiModelDO getModel(Long id);
 
    /**
     * 根据模型名称获得模型(工业大模型使用)
     *
     * @param name
     * @return 模型
     */
    AiModelDO getModelByName(String name);
 
    /**
     * 获得默认的模型
     *
     * 如果获取不到,则抛出 {@link com.iailab.framework.common.exception.ServiceException} 业务异常
     *
     * @return 模型
     */
    AiModelDO getRequiredDefaultModel(Integer type);
 
    /**
     * 获得模型分页
     *
     * @param pageReqVO 分页查询
     * @return 模型分页
     */
    PageResult<AiModelDO> getModelPage(AiModelPageReqVO pageReqVO);
 
    /**
     * 校验模型是否可使用
     *
     * @param id 编号
     * @return 模型
     */
    AiModelDO validateModel(Long id);
 
    /**
     * 获得模型列表
     *
     * @param status 状态
     * @param type 类型
     * @param platform 平台,允许空
     * @return 模型列表
     */
    List<AiModelDO> getModelListByStatusAndType(Integer status, Integer type,
                                                @Nullable String platform);
 
    // ========== 与 Spring AI 集成 ==========
 
    /**
     * 获得 ChatModel 对象
     *
     * @param id 编号
     * @return ChatModel 对象
     */
    ChatModel getChatModel(Long id);
 
    /**
     * 获得 ImageModel 对象
     *
     * @param id 编号
     * @return ImageModel 对象
     */
    ImageModel getImageModel(Long id);
 
    /**
     * 获得 MidjourneyApi 对象
     *
     * @param id 编号
     * @return MidjourneyApi 对象
     */
    MidjourneyApi getMidjourneyApi(Long id);
 
    /**
     * 获得 SunoApi 对象
     *
     * @return SunoApi 对象
     */
    SunoApi getSunoApi();
 
    /**
     * 获得 VectorStore 对象
     *
     * @param id 编号
     * @param metadataFields 元数据的定义
     * @return VectorStore 对象
     */
    VectorStore getOrCreateVectorStore(Long id, Map<String, Class<?>> metadataFields);
 
}