mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-16 21:33:40 +00:00
feat(chat): 集成 FastGPT 聊天模型- 在 ChatModeType 枚举中添加 FASTGPT 选项- 新增 FastGPT 相关的实体类和请求响应类
- 实现 FastGPT聊天服务接口 - 添加 FastGPT SSE 事件监听器
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.common.chat.entity.chat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class FastGPTAnswerResponse {
|
||||
private String id;
|
||||
private String object;
|
||||
private long created;
|
||||
private String model;
|
||||
private List<FastGPTChatChoice> choices;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.ruoyi.common.chat.entity.chat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class FastGPTChatChoice implements Serializable {
|
||||
private long index;
|
||||
/**
|
||||
* 请求参数stream为true返回是delta
|
||||
*/
|
||||
@JsonProperty("delta")
|
||||
private Message delta;
|
||||
/**
|
||||
* 请求参数stream为false返回是message
|
||||
*/
|
||||
@JsonProperty("message")
|
||||
private Message message;
|
||||
@JsonProperty("finish_reason")
|
||||
private String finishReason;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.ruoyi.common.chat.entity.chat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FastGPTChatCompletion extends ChatCompletion implements Serializable {
|
||||
|
||||
/**
|
||||
* 是否使用FastGPT提供的上下文
|
||||
*/
|
||||
private String chatId;
|
||||
|
||||
|
||||
/**
|
||||
* 是否返回详细信息;stream模式下会通过event进行区分,非stream模式结果保存在responseData中.
|
||||
*/
|
||||
private boolean detail;
|
||||
|
||||
|
||||
/**
|
||||
* 运行时变量
|
||||
* 模块变量,一个对象,会替换模块中,输入fastgpt框内容里的{{key}}
|
||||
*/
|
||||
private Variables variables;
|
||||
|
||||
/**
|
||||
* responseChatItemId: string | undefined 。
|
||||
* 如果传入,则会将该值作为本次对话的响应消息的 ID,
|
||||
* FastGPT 会自动将该 ID 存入数据库。请确保,
|
||||
* 在当前chatId下,responseChatItemId是唯一的。
|
||||
*/
|
||||
private String responseChatItemId;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.ruoyi.common.chat.entity.chat;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Variables implements Serializable {
|
||||
|
||||
private String uid;
|
||||
|
||||
private String name;
|
||||
}
|
||||
Reference in New Issue
Block a user