From 326bd21a098201b8f9c14e7a7ed50e28ba8a1632 Mon Sep 17 00:00:00 2001 From: GR Date: Tue, 10 Sep 2024 08:20:20 +0800 Subject: [PATCH] Minimax doc fixes - Add web search docs - Fix minimax chat docs links --- .../functions/minimax-chat-functions.adoc | 4 +- .../ROOT/pages/api/chat/minimax-chat.adoc | 47 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/functions/minimax-chat-functions.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/functions/minimax-chat-functions.adoc index 3b5be6c34b..039c3f8d98 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/functions/minimax-chat-functions.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/functions/minimax-chat-functions.adoc @@ -112,7 +112,7 @@ public record Request(String location, Unit unit) {} It is a best practice to annotate the request object with information such that the generates JSON schema of that function is as descriptive as possible to help the AI model pick the correct function to invoke. -The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/minimax/tool/FunctionCallbackWithPlainFunctionBeanIT.java[FunctionCallbackWithPlainFunctionBeanIT.java] demonstrates this approach. +The link:https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/minimax/FunctionCallbackWithPlainFunctionBeanIT.java[FunctionCallbackWithPlainFunctionBeanIT.java] demonstrates this approach. ==== FunctionCallback Wrapper @@ -197,7 +197,7 @@ NOTE: The in-prompt registered functions are enabled by default for the duration This approach allows to dynamically chose different functions to be called based on the user input. -The https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/minimax/tool/FunctionCallbackInPromptIT.java[FunctionCallbackInPromptIT.java] integration test provides a complete example of how to register a function with the `MiniMaxChatModel` and use it in a prompt request. +The https://github.com/spring-projects/spring-ai/blob/main/spring-ai-spring-boot-autoconfigure/src/test/java/org/springframework/ai/autoconfigure/minimax/FunctionCallbackInPromptIT.java[FunctionCallbackInPromptIT.java] integration test provides a complete example of how to register a function with the `MiniMaxChatModel` and use it in a prompt request. // // === Register Functions with Default Options // diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/minimax-chat.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/minimax-chat.adoc index c0bfcce0a3..5628a115d1 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/minimax-chat.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/minimax-chat.adoc @@ -1,4 +1,4 @@ -= MiniMax Chat +<= MiniMax Chat Spring AI supports the various AI language models from MiniMax. You can interact with MiniMax language models and create a multilingual conversational assistant based on MiniMax models. @@ -121,8 +121,8 @@ ChatResponse response = chatModel.call( new Prompt( "Generate the names of 5 famous pirates.", MiniMaxChatOptions.builder() - .withModel(MiniMaxApi.ChatModel.ABAB_5_5_Chat.getValue()) - .withTemperature(0.5) + .withModel(MiniMaxApi.ChatModel.ABAB_6_5_S_Chat.getValue()) + .withTemperature(0.5f) .build() )); ---- @@ -204,8 +204,8 @@ Next, create a `MiniMaxChatModel` and use it for text generations: var miniMaxApi = new MiniMaxApi(System.getenv("MINIMAX_API_KEY")); var chatModel = new MiniMaxChatModel(miniMaxApi, MiniMaxChatOptions.builder() - .withModel(MiniMaxApi.ChatModel.ABAB_5_5_Chat.getValue()) - .withTemperature(0.4) + .withModel(MiniMaxApi.ChatModel.ABAB_6_5_S_Chat.getValue()) + .withTemperature(0.4f) .withMaxTokens(200) .build()); @@ -236,16 +236,47 @@ ChatCompletionMessage chatCompletionMessage = // Sync request ResponseEntity response = miniMaxApi.chatCompletionEntity( - new ChatCompletionRequest(List.of(chatCompletionMessage), MiniMaxApi.ChatModel.ABAB_5_5_Chat.getValue(), 0.7, false)); + new ChatCompletionRequest(List.of(chatCompletionMessage), MiniMaxApi.ChatModel.ABAB_6_5_S_Chat.getValue(), 0.7f, false)); // Streaming request Flux streamResponse = miniMaxApi.chatCompletionStream( - new ChatCompletionRequest(List.of(chatCompletionMessage), MiniMaxApi.ChatModel.ABAB_5_5_Chat.getValue(), 0.7, true)); + new ChatCompletionRequest(List.of(chatCompletionMessage), MiniMaxApi.ChatModel.ABAB_6_5_S_Chat.getValue(), 0.7f, true)); ---- Follow the https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/main/java/org/springframework/ai/minimax/api/MiniMaxApi.java[MiniMaxApi.java]'s JavaDoc for further information. + +=== WebSearch chat [[web-search]] + +The MiniMax model supported the web search feature. The web search feature allows you to search the web for information and return the results in the chat response. + +About web search follow the https://platform.minimaxi.com/document/ChatCompletion%20v2[MiniMax ChatCompletion] for further information. + +Here is a simple snippet how to use the web search: + +[source,java] +---- +UserMessage userMessage = new UserMessage( + "How many gold medals has the United States won in total at the 2024 Olympics?"); + +List messages = new ArrayList<>(List.of(userMessage)); + +List functionTool = List.of(MiniMaxApi.FunctionTool.webSearchFunctionTool()); + +MiniMaxChatOptions options = MiniMaxChatOptions.builder() + .withModel(MiniMaxApi.ChatModel.ABAB_6_5_S_Chat.value) + .withTools(functionTool) + .build(); + + +// Sync request +ChatResponse response = chatModel.call(new Prompt(messages, options)); + +// Streaming request +Flux streamResponse = chatModel.stream(new Prompt(messages, options)); +---- + ==== MiniMaxApi Samples * The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiIT.java[MiniMaxApiIT.java] test provides some general examples how to use the lightweight library. -* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiToolFunctionCallIT.java.java[MiniMaxApiToolFunctionCallIT.java] test shows how to use the low-level API to call tool functions. \ No newline at end of file +* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiToolFunctionCallIT.java[MiniMaxApiToolFunctionCallIT.java] test shows how to use the low-level API to call tool functions.> \ No newline at end of file