How to use other Chat Models in spring ai, such as chatglm . There are no relevant usage instructions in the project documentation。Using code examples。Please provide a code example using another Chat Models Or corresponding documents

Comment From: fanjia1024

I think Chatglm can use the official OpenAI protocol mode. The new Chatglm3 is adapted to the new interface specification of OpenAI. You can use OpenAI's chatmodel to configure your baseUrl and set your model name to 'chatglm3-6b'. Set up apikey and test the corresponding client capabilities eg: OpenAiApi chatgmOpenAiApi = new OpenAiApi("http://127.0.0.1:8000/","xxxx");

@Test
void chatCompletionEntity() {
    ChatCompletionMessage chatCompletionMessage = new ChatCompletionMessage("Hello world", Role.USER);
    ResponseEntity<ChatCompletion> response = chatgmOpenAiApi.chatCompletionEntity(
            new ChatCompletionRequest(List.of(chatCompletionMessage), "chtglm3-6b", 0.8f, false));

    assertThat(response).isNotNull();
    assertThat(response.getBody()).isNotNull();
}