增加文生图
This commit is contained in:
parent
54c2a296ad
commit
befe0aa672
@ -1,5 +1,9 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.conversation;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.TextToImageReqVo;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -97,4 +101,9 @@ public class ConversationController {
|
||||
public CommonResult<ChatRespVO> chat(@Valid @RequestBody ChatReqVO chatReqVO) {
|
||||
return success(conversationService.chat(chatReqVO));
|
||||
}
|
||||
@PostMapping("/text-to-image")
|
||||
@Operation(summary = "文字转图片接口")
|
||||
public CommonResult<JSONArray> textToImage(@Valid @RequestBody TextToImageReqVo req) {
|
||||
return success(conversationService.textToImage(req));
|
||||
}
|
||||
}
|
@ -98,4 +98,5 @@ public class LLMBackendProperties {
|
||||
private String aigcFileUpload;
|
||||
|
||||
private String autoEvaluation;
|
||||
private String textToImage;
|
||||
}
|
||||
|
@ -2,10 +2,14 @@ package cn.iocoder.yudao.module.llm.service.conversation;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.conversation.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.conversation.ConversationDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.TextToImageReqVo;
|
||||
|
||||
/**
|
||||
* 大模型对话记录 Service 接口
|
||||
@ -53,4 +57,11 @@ public interface ConversationService {
|
||||
PageResult<ConversationDO> getConversationPage(ConversationPageReqVO pageReqVO);
|
||||
|
||||
ChatRespVO chat(@Valid ChatReqVO chatReqVO);
|
||||
|
||||
/**
|
||||
* 文生图接口
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
JSONArray textToImage(TextToImageReqVo req);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.llm.service.conversation;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.application.vo.ApplicationRespVO;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.application.vo.ApplicationSaveReqVO;
|
||||
@ -14,6 +16,8 @@ import cn.iocoder.yudao.module.llm.service.datarefluxdata.DataRefluxDataService;
|
||||
import cn.iocoder.yudao.module.llm.service.http.ModelService;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.ModelCompletionsReqVO;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.ModelCompletionsRespVO;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.TextToImageReqVo;
|
||||
import cn.iocoder.yudao.module.llm.service.http.vo.TextToImageRespVo;
|
||||
import cn.iocoder.yudao.module.llm.service.prompttemplates.PromptTemplatesService;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
@ -138,6 +142,12 @@ public class ConversationServiceImpl implements ConversationService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray textToImage(TextToImageReqVo req) {
|
||||
TextToImageRespVo textToImageRespVo = modelService.textToImage(req);
|
||||
return textToImageRespVo.getData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 公共模型聊天
|
||||
|
@ -17,6 +17,7 @@ import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -139,4 +140,20 @@ public class ModelService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public TextToImageRespVo textToImage(TextToImageReqVo req) {
|
||||
log.info("url: {}", llmBackendProperties.getTextToImage());
|
||||
log.info("request: {}", req);
|
||||
String result = HttpUtils.post(llmBackendProperties.getTextToImage(),new HashMap<>(), JSON.toJSONString(req));
|
||||
log.info("response: {}", result);
|
||||
if (StringUtils.isBlank(result)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return JSON.parseObject(result, TextToImageRespVo.class);
|
||||
}catch (Exception e){
|
||||
log.error("text to image error : {}",e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TextToImageReqVo {
|
||||
private String prompt;
|
||||
private String Size;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.llm.service.http.vo;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TextToImageRespVo {
|
||||
private String created;
|
||||
private JSONArray data;
|
||||
}
|
@ -275,6 +275,8 @@ llm:
|
||||
optimize_prompt: http://36.133.1.230:5123/optimize-prompt
|
||||
|
||||
auto_evaluation: http://36.133.1.230:5123/llm-eval
|
||||
# 文生图
|
||||
text_to_image: http://36.133.1.230:5123/generate-image
|
||||
|
||||
|
||||
--- #################### iot相关配置 TODO 芋艿:再瞅瞅 ####################
|
||||
|
@ -318,6 +318,9 @@ llm:
|
||||
|
||||
auto_evaluation: http://36.133.1.230:5123/llm-eval
|
||||
|
||||
# 文生图
|
||||
text_to_image: http://36.133.1.230:5123/generate-image
|
||||
|
||||
--- #################### iot相关配置 TODO 芋艿:再瞅瞅 ####################
|
||||
iot:
|
||||
emq:
|
||||
|
Loading…
x
Reference in New Issue
Block a user