feat: 增加ppio厂商支持

This commit is contained in:
ageerle
2026-02-25 21:20:22 +08:00
parent e768c4b356
commit c78b1a14a9
2 changed files with 51 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ public enum ChatModeType {
ZHI_PU("zhipu", "智谱清言"),
DEEP_SEEK("deepseek", "深度求索"),
QIAN_WEN("qianwen", "通义千问"),
PPIO("ppio", "PPIO派欧云"),
OPEN_AI("openai", "openai");
private final String code;
private final String description;

View File

@@ -0,0 +1,50 @@
package org.ruoyi.service.chat.impl.provider;
import dev.langchain4j.data.message.ChatMessage;
import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.chat.response.StreamingChatResponseHandler;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import lombok.extern.slf4j.Slf4j;
import org.ruoyi.common.chat.domain.dto.request.ChatRequest;
import org.ruoyi.common.chat.domain.vo.chat.ChatModelVo;
import org.ruoyi.enums.ChatModeType;
import org.ruoyi.service.chat.impl.AbstractStreamingChatService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* PPIO服务调用
*
* @author ageerle@163.com
* @date 2025/12/13
*/
@Service
@Slf4j
public class PPIOServiceImpl extends AbstractStreamingChatService {
@Override
protected StreamingChatModel buildStreamingChatModel(ChatModelVo chatModelVo, ChatRequest chatRequest) {
return OpenAiStreamingChatModel.builder()
.baseUrl(chatModelVo.getApiHost())
.apiKey(chatModelVo.getApiKey())
.modelName(chatModelVo.getModelName())
.returnThinking(chatRequest.getEnableThinking())
.build();
}
@Override
protected void doChat(ChatModelVo chatModelVo, ChatRequest chatRequest, List<ChatMessage> messagesWithMemory, StreamingChatResponseHandler handler) {
StreamingChatModel streamingChatModel = buildStreamingChatModel(chatModelVo, chatRequest);
streamingChatModel.chat(messagesWithMemory, handler);
}
@Override
public String getProviderName() {
return ChatModeType.PPIO.getCode();
}
}