diff --git a/pom.xml b/pom.xml index 4d35ab8a..02644484 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,10 @@ + + org.springframework.boot + spring-boot-starter-webflux + com.github.promeg diff --git a/src/main/java/com/peanut/modules/common/controller/RagFlowApiController.java b/src/main/java/com/peanut/modules/common/controller/RagFlowApiController.java new file mode 100644 index 00000000..fcea1da8 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/controller/RagFlowApiController.java @@ -0,0 +1,41 @@ +package com.peanut.modules.common.controller; + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@RestController("commonRagFlowApi") +@RequestMapping("common/ragFlowApi") +public class RagFlowApiController { + + //获取地址 + @RequestMapping(value = "/test2", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux test3() { + Map entity = new HashMap<>(); + entity.put("question", "更年期怎么改善"); + entity.put("stream", true); + entity.put("session_id", "397ea7f9033947c3b32296ad4f7688b8"); + return WebClient.create().post() + .uri("http://125.39.141.154:81/api/v1/chats/3f35f41e233111f080cd8a56b889fe93/completions") + .header("Authorization", "Bearer ragflow-kyM2JjZWM4MjFiNDExZjA5MTgzOGE1Nm") + .header("Content-Type", "application/json;chartset=utf-8") + .bodyValue(JSONObject.toJSONString(entity)) + .retrieve() + .bodyToFlux(String.class);//输出格式 + + } + + + + +}