-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Tool add Mono #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Although using |
webflux确实有这样的问题,无法获取到header,之前也webflux项目,实现了WebFilter,chain.filter(exchange).contextWrite(ctx -> ctx.put(ContextHolder.KEY_EXCHANGE, exchange))是可以的,不知道为啥,新建的mcp的项目里面就不行了,你先换成mvc呗,mvc写个拦截器,把header里面的内容取出来,添加到全局上下文,是可以实现的,没必要非要用webflux。 |
Thanks for the answer。Webmvc is too slow, and some models do not support Webmvc, only Webflux. Can Webflux be supported in the tool? |
建议你client端使用python,大模型都使用python那层来做,server端使用java,mvc的模型也都是支持的,你说不支持指的是什么呢? |
谢谢回复, public static Mono<ServerHttpRequest> getRequest() {
return Mono.subscriberContext()
.map(ctx -> ctx.get(ServerHttpRequest.class));
}
@Tool(name = "品质事件查询", description = "根据用户输入内容查询品质事件")
public Mono<String> searchQualityEvent(@ToolParam(description = "查询参数") QualityEventSearch qualityEventSearch) {
QualityEventSearch finalQualityEventSearch = qualityEventSearch;
Mono<R> rMono = getRequest().flatMap(serverHttpRequest -> {
String first = serverHttpRequest.getHeaders().get(HttpHeaders.AUTHORIZATION).getFirst();
return webClient.post().uri("https://xxx")
.header(HttpHeaders.AUTHORIZATION, first)
.accept(MediaType.APPLICATION_JSON)
.body(Mono.just(JackSon2Utils.writeString(finalQualityEventSearch)), String.class)
.retrieve()
.bodyToMono(R.class);
});
return rMono.flatMap(r -> {
if (r.isSuccess()) {
return Mono.just(JackSon2Utils.writeString(r.getData()));
}
return Mono.just("权限不足");
}); 当前 |
在 @GetMapping("/advisor")
public String advisor(@RequestParam(value = "message", defaultValue = "你会做些什么") String message, HttpServletRequest request) {
return chatClient.prompt()
.advisors(advisorSpec ->
advisorSpec.param(AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY,
getIpAddress(request))
)
.messages(new UserMessage(message))
.call()
.content();
}
|
因为你不是从controller里面进的,如果是从controller里面就可以获取到,本来mvc能做的,你非要倔~ |
但是在 |
我的需要在tool中获取我当前权限,然后在api调用的时候放入其中。 |
通义哪个模型必须要webflux,我咋不知道? |
reactor可以在mvc引入webflux包,使用webclient |
no,兄弟,你试试在 |
没办法的,webflux这个坑我已经踩过了 |
通义的,都会支持mvc,你说通义的只支持webflux是不可能的 |
所以我来这里提,能不能让@tool支持mono |
这个问题已经提过了,没人搭理 |
多提几次,需要的人多了,自然会有人开发的。没人愿意的话就只能自己提pr了 |
嗯,所以没人解决,就不必纠结了,用mvc解决吧或者先不用权限了 |
谢谢 |
大佬们能不能指导一下如何在tool中刷新resource list,我现在需要在tool执行完后刷新发布的resource,但是找不到相关资料 |
repeat #2757 |
@xiaolegehaha 你可以重新打开一个新的issues,并附上代码。我不太懂你说的 |
resource为啥要用到这个?我觉得不管是什么,都使用tool来解决就可以了呀 |
I have a requirement. I am using webflux. I need to request my local interface in @tool, but I can't get the header. For example, add the Authorization header in webflux in webClient or restTemplate.
The code is as follows. Can you support it or is there another method?
The text was updated successfully, but these errors were encountered: