升級注意事項
升級至 1.0.0.M2
-
為了與其他向量資料庫的命名慣例保持一致,Chroma 向量資料庫的組態前綴已從
spring.ai.vectorstore.chroma.store
變更為spring.ai.vectorstore.chroma
。 -
現在,能夠初始化結構描述的向量資料庫上的
initialize-schema
屬性預設值已設定為false
。這表示如果預期在應用程式啟動時建立結構描述,則應用程式現在需要明確選擇加入支援的向量資料庫上的結構描述初始化。並非所有向量資料庫都支援此屬性。有關更多詳細資訊,請參閱相應的向量資料庫文件。以下是目前不支援initialize-schema
屬性的向量資料庫。-
Hana
-
Pinecone
-
Weaviate
-
-
在 Bedrock Jurassic 2 中,聊天選項
countPenalty
、frequencyPenalty
和presencePenalty
已重新命名為countPenaltyOptions
、frequencyPenaltyOptions
和presencePenaltyOptions
。此外,聊天選項stopSequences
的類型已從String[]
變更為List<String>
。 -
在 Azure OpenAI 中,聊天選項
frequencyPenalty
和presencePenalty
的類型已從Double
變更為Float
,與所有其他實作保持一致。
升級至 1.0.0.M1
在我們邁向發布 1.0.0 M1 的過程中,我們進行了一些重大變更。抱歉,但這是為了更好!
ChatClient 變更
進行了一項重大變更,將「舊」的 ChatClient
功能移至 ChatModel
中。「新」的 ChatClient
現在採用 ChatModel
的實例。這樣做的目的是為了支援流暢的 API,以類似於 Spring 生態系統中其他用戶端類別(例如 RestClient
、WebClient
和 JdbcClient
)的風格建立和執行提示詞。有關 Fluent API 的更多資訊,請參閱 [JavaDoc](docs.spring.io/spring-ai/docs/api),適當的參考文件即將推出。
我們將「舊」的 ModelClient
重新命名為 Model
,並重新命名了實作類別,例如 ImageClient
重新命名為 ImageModel
。Model
實作代表可移植性層,可在 Spring AI API 和底層 AI 模型 API 之間進行轉換。
適應變更
ChatClient 類別現在位於 org.springframework.ai.chat.client 套件中 |
方法 1
現在,您將獲得 ChatModel
實例,而不是取得自動組態的 ChatClient
實例。重新命名後的 call
方法簽章保持不變。為了適應您的程式碼,您應該重構程式碼,將 ChatClient
類型的使用變更為 ChatModel
。以下是變更前現有程式碼的範例
@RestController
public class OldSimpleAiController {
private final ChatClient chatClient;
public OldSimpleAiController(ChatClient chatClient) {
this.chatClient = chatClient;
}
@GetMapping("/ai/simple")
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of("generation", this.chatClient.call(message));
}
}
現在變更後會變成這樣
@RestController
public class SimpleAiController {
private final ChatModel chatModel;
public SimpleAiController(ChatModel chatModel) {
this.chatModel = chatModel;
}
@GetMapping("/ai/simple")
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of("generation", this.chatModel.call(message));
}
}
重新命名也適用於以下類別:* StreamingChatClient → StreamingChatModel * EmbeddingClient → EmbeddingModel * ImageClient → ImageModel * SpeechClient → SpeechModel * 以及其他 <XYZ>Client 類別的類似情況 |
方法 2
在此方法中,您將使用「新」ChatClient
上提供的新流暢 API
以下是變更前現有程式碼的範例
@RestController
class OldSimpleAiController {
ChatClient chatClient;
OldSimpleAiController(ChatClient chatClient) {
this.chatClient = chatClient;
}
@GetMapping("/ai/simple")
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of(
"generation",
this.chatClient.call(message)
);
}
}
現在變更後會變成這樣
@RestController
class SimpleAiController {
private final ChatClient chatClient;
SimpleAiController(ChatClient.Builder builder) {
this.chatClient = builder.build();
}
@GetMapping("/ai/simple")
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of(
"generation",
this.chatClient.prompt().user(message).call().content()
);
}
}
ChatModel 實例透過自動組態提供給您。 |
方法 3
GitHub 儲存庫中有名為 [v1.0.0-SNAPSHOT-before-chatclient-changes](github.com/spring-projects/spring-ai/tree/v1.0.0-SNAPSHOT-before-chatclient-changes) 的標籤,您可以檢出並進行本機建置,以避免更新任何程式碼,直到您準備好遷移程式碼庫。
git checkout tags/v1.0.0-SNAPSHOT-before-chatclient-changes
./mvnw clean install -DskipTests
Artifact 名稱變更
重新命名 POM artifact 名稱: - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-cassandra → spring-ai-cassandra-store - spring-ai-pinecone → spring-ai-pinecone-store - spring-ai-redis → spring-ai-redis-store - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-gemfire → spring-ai-gemfire-store - spring-ai-azure-vector-store-spring-boot-starter → spring-ai-azure-store-spring-boot-starter - spring-ai-redis-spring-boot-starter → spring-ai-redis-store-spring-boot-starter
升級至 0.8.1
先前的 spring-ai-vertex-ai
已重新命名為 spring-ai-vertex-ai-palm2
,而 spring-ai-vertex-ai-spring-boot-starter
已重新命名為 spring-ai-vertex-ai-palm2-spring-boot-starter
。
因此,您需要將依賴項從
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai</artifactId>
</dependency>
變更為
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2</artifactId>
</dependency>
以及 Palm2 模型的相關 Boot starter 已從
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-spring-boot-starter</artifactId>
</dependency>
變更為
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2-spring-boot-starter</artifactId>
</dependency>
-
重新命名類別 (2024年1月3日)
-
VertexAiApi → VertexAiPalm2Api
-
VertexAiClientChat → VertexAiPalm2ChatClient
-
VertexAiEmbeddingClient → VertexAiPalm2EmbeddingClient
-
VertexAiChatOptions → VertexAiPalm2ChatOptions
-
升級至 0.8.0
2024年1月24日更新
-
將
prompt
、messages
和metadata
套件移至org.sf.ai.chat
的子套件 -
新功能是文字轉影像用戶端。類別為
OpenAiImageModel
和StabilityAiImageModel
。有關用法,請參閱整合測試,文件即將推出。 -
一個新的「model」套件,其中包含介面和基礎類別,以支援為任何輸入/輸出資料類型組合建立 AI 模型用戶端。目前,聊天和影像模型套件實作了此功能。我們將很快將嵌入套件更新為這個新模型。
-
一種新的「可攜式選項」設計模式。我們希望在
ModelCall
中為不同的基於聊天的 AI 模型提供盡可能多的可移植性。有一組通用的產生選項,然後是特定於模型提供者的選項。使用了一種「鴨子類型」方法。「model」套件中的ModelOptions
是一個標記介面,指示此類別的實作將為模型提供選項。請參閱ImageOptions
,這是一個子介面,定義了跨所有文字→影像ImageModel
實作的可攜式選項。然後StabilityAiImageOptions
和OpenAiImageOptions
提供了特定於每個模型提供者的選項。所有選項類別都是透過流暢的 API 建立器建立的,所有選項類別都可以傳遞到可攜式ImageModel
API 中。這些選項資料類型用於ImageModel
實作的自動組態/組態屬性中。
2024年1月13日更新
以下 OpenAi 自動組態聊天屬性已變更
-
從
spring.ai.openai.model
變更為spring.ai.openai.chat.options.model
。 -
從
spring.ai.openai.temperature
變更為spring.ai.openai.chat.options.temperature
。
查找有關 OpenAi 屬性的更新文件:docs.spring.io/spring-ai/reference/api/chat/openai-chat.html
2023年12月27日更新
將 SimplePersistentVectorStore
和 InMemoryVectorStore
合併到 SimpleVectorStore
中 * 將 InMemoryVectorStore
替換為 SimpleVectorStore
2023年12月20日更新
重構 Ollama 用戶端以及相關類別和套件名稱
-
將
org.springframework.ai.ollama.client.OllamaClient
替換為org.springframework.ai.ollama.OllamaModelCall
。 -
OllamaChatClient
方法簽章已變更。 -
將
org.springframework.ai.autoconfigure.ollama.OllamaProperties
重新命名為org.springframework.ai.autoconfigure.ollama.OllamaChatProperties
,並將後綴變更為:spring.ai.ollama.chat
。某些屬性也已變更。
2023年12月19日更新
重新命名 AiClient 以及相關類別和套件名稱
-
將
AiClient
重新命名為ChatClient
-
將
AiResponse
重新命名為ChatResponse
-
將
AiStreamClient
重新命名為StreamingChatClient
-
將套件
org.sf.ai.client
重新命名為org.sf.ai.chat
重新命名 artifact ID
-
transformers-embedding
變更為spring-ai-transformers
將 Maven 模組從頂層目錄和 embedding-clients
子目錄移至單個 models
目錄下。
2023年12月1日
我們正在轉換專案的 Group ID
-
從:
org.springframework.experimental.ai
-
至:
org.springframework.ai
Artifact 仍將託管在快照儲存庫中,如下所示。
主分支將移至版本 0.8.0-SNAPSHOT
。在一兩週內將不穩定。如果您不想使用最前沿的版本,請使用 0.7.1-SNAPSHOT
。
您可以像以前一樣存取 0.7.1-SNAPSHOT
artifact,並且仍然可以存取 0.7.1-SNAPSHOT 文件。
0.7.1-SNAPSHOT 依賴項
-
Azure OpenAI
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>
-
OpenAI
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>