-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
When I use the builder method of ChatModel to build the model, I get a 400 error because I don't know the model parameters.
Is this how it's supposed to be designed?
I see openai docs: https://docs.spring.io/spring-ai/reference/api/chat/openai-chat.html#_custom_api_key_configuration
@GetMapping("/call/openai")
public String call() {
OpenAiChatModel chatModel = OpenAiChatModel.builder()
.openAiApi(OpenAiApi.builder()
.apiKey("sk-xxxxx")
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions")
.build()
).defaultOptions(OpenAiChatOptions.builder()
.temperature(0.7)
.maxTokens(1000)
.build()
).build();
return chatModel.call("hi");
}
log:
org.springframework.ai.retry.NonTransientAiException: 400 - {"error":{"message":"you must provide a model parameter. ","type":"invalid_request_error","param":null,"code":null},"request_id":"c39eba3c-2766-473c-a4c2-46c73d3470ee"}
at org.springframework.ai.retry.RetryUtils$1.handleError(RetryUtils.java:73) ~[spring-ai-retry-1.1.0.jar:1.1.0]
at org.springframework.ai.retry.RetryUtils$1.handleError(RetryUtils.java:57) ~[spring-ai-retry-1.1.0.jar:1.1.0]
at org.springframework.web.client.StatusHandler.lambda$fromErrorHandler$1(StatusHandler.java:71) ~[spring-web-6.2.6.jar:6.2.6]
guanxuc