搶佔先機
VMware 提供培訓和認證,助力您的發展。
瞭解更多Amazon Bedrock Nova 模型代表著新一代的基礎模型,支援從文字和影像理解到影片轉文字分析等廣泛的用例。
透過 Spring AI Bedrock Converse API 整合,開發人員可以輕鬆連線到這些先進的 Nova 模型,並以最少的精力構建複雜的對話式應用程式。
這篇博文介紹了 Amazon Nova 模型的主要特性,演示了它們與 Spring AI 的 Bedrock Converse API 的整合,並提供了文字、影像、影片、文件處理和函式呼叫的實際示例。
Amazon Nova 提供三個層級的模型——Nova Pro、Nova Lite 和 Nova Micro——以滿足不同的效能和成本需求。
規格 | Nova Pro | Nova Lite | Nova Micro |
---|---|---|---|
模態 | 文字、影像、影片轉文字 | 文字、影像、影片轉文字 | 文字 |
模型 ID | amazon.nova-pro-v1:0 | amazon.nova-lite-v1:0 | amazon.nova-micro-v1:0 |
最大 token 數 | 300K | 300K | 128K |
Nova Pro 和 Lite 支援多模態功能,包括文字、影像和影片輸入,而 Nova Micro 針對純文字互動進行了最佳化,成本更低。
AWS 配置: 您需要
Spring AI 依賴: 將 Spring AI Bedrock Converse starter 新增到您的 Spring Boot 專案中
Maven:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bedrock-converse-spring-boot-starter</artifactId>
</dependency>
Gradle:
dependencies {
implementation 'org.springframework.ai:spring-ai-bedrock-converse-spring-boot-starter'
}
應用程式配置: 為 Amazon Bedrock 配置 application.properties
spring.ai.bedrock.aws.region=us-east-1
spring.ai.bedrock.aws.access-key=${AWS_ACCESS_KEY_ID}
spring.ai.bedrock.aws.secret-key=${AWS_SECRET_ACCESS_KEY}
spring.ai.bedrock.aws.session-token=${AWS_SESSION_TOKEN}
spring.ai.bedrock.converse.chat.options.model=amazon.nova-pro-v1:0
spring.ai.bedrock.converse.chat.options.temperature=0.8
spring.ai.bedrock.converse.chat.options.max-tokens=1000
有關更多詳細資訊,請參考聊天屬性文件。
基於文字的聊天補全非常簡單
String response = ChatClient.create(chatModel)
.prompt("Tell me a joke about AI.")
.call()
.content();
Nova Pro 和 Lite 支援多模態輸入,支援處理文字和視覺資料。Spring AI 提供了一個可移植的 多模態 API,支援 Bedrock Nova 模型。
Nova Pro 和 Lite 支援多種影像模態。這些模型可以分析影像、回答關於影像的問題、對影像進行分類,並根據提供的說明生成摘要。它們支援 image/jpeg
、image/png
、image/gif
和 image/webp
格式的 base64 編碼影像。
使用者文字與影像結合的示例
String response = ChatClient.create(chatModel)
.prompt()
.user(u -> u.text("Explain what do you see on this picture?")
.media(Media.Format.IMAGE_PNG, new ClassPathResource("/test.png")))
.call()
.content();
此程式碼處理 test.png
影像:,以及文字訊息
"Explain what do you see on this picture?"
,並生成如下響應:
影像顯示了裝有幾塊水果的金屬水果籃的特寫檢視...
Amazon Nova Pro/Lite 模型支援負載中的單個影片模態,可以 base64 格式或透過 Amazon S3 URI 提供。
支援的影片格式包括 video/x-matros
、video/quicktime
、video/mp4
、video/webm
、video/x-flv
、video/mpeg
、video/x-ms-wmv
和 image/3gpp
。
使用者文字與影片結合的示例
String response = ChatClient.create(chatModel)
.prompt()
.user(u -> u.text("Explain what do you see in this video?")
.media(Media.Format.VIDEO_MP4, new ClassPathResource("/test.video.mp4")))
.call()
.content();
此程式碼處理 test.video.mp4
影片 ,以及文字訊息
"Explain what do you see in this video?"
,並生成如下響應:
影片顯示了一群小雞(也稱為雛雞)擠在一起,在某個表面上...
Nova Pro/Lite 支援兩種文件模態變體
使用者文字與媒體文件結合的示例
String response = ChatClient.create(chatModel)
.prompt()
.user(u -> u.text(
"You are a very professional document summarization specialist. Please summarize the given document.")
.media(Media.Format.DOC_PDF, new ClassPathResource("/spring-ai-reference-overview.pdf")))
.call()
.content();
此程式碼處理 spring-ai-reference-overview.pdf
文件:,以及文字訊息,並生成如下響應:
簡介
- Spring AI 旨在簡化開發具有人工智慧 (AI) 功能的應用程式,目標是避免不必要的複雜性...
Nova 模型支援工具/函式呼叫,用於與外部工具整合。
@Bean
@Description("Get the weather in a location. Return temperature in Celsius or Fahrenheit.")
public Function<WeatherRequest, WeatherResponse> weatherFunction() {
return new MockWeatherService();
}
String response = ChatClient.create(this.chatModel)
.prompt("What's the weather like in Boston?")
.function("weatherFunction") // bean name
.inputType(WeatherRequest.class)
.call()
.content();
VMware Tanzu Platform 10 透過 VMware Tanzu AI Server(由 Spring AI 提供支援)集成了 Amazon Bedrock Nova 模型。此整合提供
有關使用 Tanzu AI Server 部署 AI 應用程式的更多資訊,請訪問 VMware Tanzu AI 文件。
透過 Converse API 將 Spring AI 與 Amazon Bedrock Nova 模型整合,為構建先進的對話式應用程式提供了強大的功能。Nova Pro 和 Lite 為開發跨文字、影像、影片和文件的多模態體驗提供了全面的工具。函式呼叫透過支援與外部工具和服務互動,進一步擴充套件了這些功能。
立即開始使用 Nova 模型和 Spring AI 構建先進的 AI 應用程式!