SpringAI-RC1正式發(fā)布:移除千帆大模型!
續(xù) Spring AI M8 版本之后(5.1 發(fā)布),前幾日 Spring AI 悄悄的發(fā)布了最新版 Spring AI 1.0.0 RC1(5.13 發(fā)布),此版本也將是 GA(Generally Available,正式版)發(fā)布前的最后一個(gè)版本,正式版計(jì)劃在 5.20 日發(fā)布。
這個(gè)版本的改動(dòng)相比于上一個(gè)版本 M8 來(lái)說(shuō),改動(dòng)不算很大,但也有一些讓我們意想不到的版本更新,接下來(lái)一起來(lái)看。
移除千帆大模型 SDK
和國(guó)內(nèi)開(kāi)發(fā)者關(guān)系比較大的一個(gè)更新就是 Spring AI RC1 移除了百度的千帆大模型,給出的原因是中國(guó)境外無(wú)法訪問(wèn),所以被移除了,官方文檔中千帆的對(duì)接文檔也被刪除了,變成這個(gè)樣子了:
這樣一來(lái),Spring AI 直接對(duì)接國(guó)內(nèi)的大模型就剩下 DeepSeek 和智普 AI 這兩家公司了。
國(guó)內(nèi)的阿里的百煉平臺(tái)也沒(méi)有直接提供 SDK 對(duì)接,算是比較遺憾的,因?yàn)閲?guó)內(nèi)使用通義大模型的公司是非常多的,并且百煉平臺(tái)內(nèi)置了 200+ 家大模型,對(duì)接百煉相當(dāng)于對(duì)接了 200+ 大模型。當(dāng)然我們可以使用 OpenAI 協(xié)議接入它,但這就意味著,我們?cè)谶@個(gè)項(xiàng)目中不能同時(shí)在接入 OpenAI 大模型了,希望后期官方能提供百煉平臺(tái)的 SDK 對(duì)接方式。
其他重要更新
- VectorStoreChatMemoryAdvisor 更新:
a.常量 CHAT_MEMORY_RETRIEVE_SIZE_KEY 被重命名為 TOP_K。
b.常量 DEFAULT_CHAT_MEMORY_RESPONSE_SIZE 被重命名為 DEFAULT_TOP_K,并且其默認(rèn)值從 100 調(diào)成為 20。
- 常量 CHAT_MEMORY_CONVERSATION_ID_KEY 被重命名為 CONVERSATION_ID,并從 AbstractChatMemoryAdvisor 移動(dòng)到 ChatMemory。請(qǐng)更新您的導(dǎo)入以使用 org.springframework.ai.chat.memory.ChatMemory.CONVERSATION_ID。
- 問(wèn)答中增加了自包含模版,例如:
- query 用于接收用戶問(wèn)題的占位符。
- 用于接收檢索到的上下文的占位符 question_answer_context。
- 使用示例如下:
- QuestionAnswerAdvisor 具有以下占位符:
PromptTemplate customPromptTemplate = PromptTemplate.builder()
.renderer(StTemplateRenderer.builder().startDelimiterToken('<').endDelimiterToken('>').build())
.template("""
<query>
Context information is below.
---------------------
<question_answer_context>
---------------------
Given the context information and no prior knowledge, answer the query.
Follow these rules:
1. If the answer is not in the context, just say that you don't know.
2. Avoid statements like "Based on the context..." or "The provided information...".
""")
.build();
String question = "Where does the adventure of Anacletus and Birba take place?";
QuestionAnswerAdvisor qaAdvisor = QuestionAnswerAdvisor.builder(vectorStore)
.promptTemplate(customPromptTemplate)
.build();
String response = ChatClient.builder(chatModel).build()
.prompt(question)
.advisors(qaAdvisor)
.call()
.content();
- PromptChatMemoryAdvisor 具有以下占位符:
* instructions 接收原始系統(tǒng)消息的占位符。
* memory用于接收檢索到的對(duì)話記憶的占位符。
- VectorStoreChatMemoryAdvisor 具有以下占位符:
* instructions 接收原始系統(tǒng)消息的占位符。
* long_term_memory 用于接收檢索到的對(duì)話記憶的占位符。
組件重命名:
- spring-ai-model-chat-memory- → spring-ai-model-chat-memory-repository-
- spring-ai-autoconfigure-model-chat-memory- → spring-ai-autoconfigure-model-chat-memory-repository-
- spring-ai-starter-model-chat-memory- → spring-ai-starter-model-chat-memory-repository-
- org.springframework.ai.chat.memory.jdbc → org.springframework.ai.chat.memory.repository.jdbc
- JdbcChatMemoryAutoConfiguration → JdbcChatMemoryRepositoryAutoConfiguration
- spring.ai.chat.memory.… → spring.ai.chat.memory.repository.…
其他升級(jí)請(qǐng)查看官方更新日志:https://docs.spring.io/spring-ai/reference/upgrade-notes.html#upgrading-to-1-0-0-RC1
小結(jié)
AI 發(fā)展速度很快,對(duì)各行各業(yè)的影響也很大。充分了解和掌握 AI 知識(shí),對(duì)日常工作提效或以后跳槽都有很大的幫助,讓我們一起行動(dòng)起來(lái),擁抱這場(chǎng) AI 盛宴吧。