ChatClient返回响应:流式响应:适用于打字机效果
This commit is contained in:
parent
d147777795
commit
c0f04beab2
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -63,4 +64,15 @@ public class ResController {
|
|||||||
});
|
});
|
||||||
return R.ok(actorFilms);
|
return R.ok(actorFilms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/fluxRes")
|
||||||
|
@Operation(summary = "流式响应:适用于打字机效果")
|
||||||
|
public R<Flux<String>> fluxRes(@RequestBody String question) {
|
||||||
|
Flux<String> output = chatClient.prompt()
|
||||||
|
.user(question)
|
||||||
|
.stream()
|
||||||
|
.content();
|
||||||
|
return R.ok(output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user