Bug description Getting Error while doing chatClient.stream(prompt).
This only happens for chatClient.stream(prompt). My finding is it happens due to WebClient CURL and chatClient.call(prompt) work fine. Caused by: java.net.UnknownHostException: Failed to resolve 'api.openai.com' [A(1)]
Caused by: io.netty.resolver.dns.DnsNameResolverTimeoutException: [19766: /192.168.29.1:53] DefaultDnsQuestion(api.openai.com. IN A) query '19766' via UDP timed out after 5000 milliseconds (no stack trace available)
Environment Please provide as many details as possible: Spring AI version - 0.8.1, Java version - 17, vector store - SimpleVectorStore (InMemory)
Steps to reproduce call below method for any prompt. Prompt prompt = new Prompt("tell me something about java"); return this.chatClient.stream(prompt).map((ChatResponse chatResponse) -> {
if (!isValidResponse(chatResponse)) {
logger.warn("ChatResponse or the result output is null!");
return "";
}
AssistantMessage assistantMessage = chatResponse.getResult().getOutput();
this.chatHistory.addMessage(chatId, assistantMessage);
return (assistantMessage.getContent() != null) ? assistantMessage.getContent() : "";
});
Expected behavior Code should stream proper llm response
Minimal Complete Reproducible example Prompt prompt = new Prompt("tell me something about java"); return this.chatClient.stream(prompt).map((ChatResponse chatResponse) -> {
if (!isValidResponse(chatResponse)) {
logger.warn("ChatResponse or the result output is null!");
return "";
}
AssistantMessage assistantMessage = chatResponse.getResult().getOutput();
this.chatHistory.addMessage(chatId, assistantMessage);
return (assistantMessage.getContent() != null) ? assistantMessage.getContent() : "";
});
Comment From: tha2015
@deepakn27 I believe that you want to customize WebClient to make it to connect to an HTTP proxy (instead of resolving the IP address of api.openai.com
and connect directly to that IP address)? Maybe you should update this issue to make it clear that you need WebClient to be customizable. That will be helpful for closing it.