太湖云医ragflow api
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -56,6 +56,10 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
<!--汉字转拼音-->
|
<!--汉字转拼音-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.promeg</groupId>
|
<groupId>com.github.promeg</groupId>
|
||||||
|
|||||||
@@ -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<String> test3() {
|
||||||
|
Map<String, Object> 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);//输出格式
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user