Commit Graph

1886 Commits

Author SHA1 Message Date
Ilayaperumal Gopinathan
2d778e8a0c Update vector store docs for Spring AI starters
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:23 -04:00
Ilayaperumal Gopinathan
ce00204914 Update docs references for the Spring AI model starters
- Update the documentation references to replace the artifact ID name change for the model starters

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:23 -04:00
Ilayaperumal Gopinathan
83ff0133cd Update MCP starters
- Update starters for MCP and docs
2025-03-24 15:34:23 -04:00
Ilayaperumal Gopinathan
962f17915b Spring AI BOM updates
- Update the latest changes to autoconfigurations, starters for the Spring AI autoconfigurations and starters

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:23 -04:00
Ilayaperumal Gopinathan
4ba932b42a Refactor auto-configurations
- Split model autoconfigurations based on the model

    - Change the autoconfiguration class into model specific autoconfigurations - chat, embedding, image etc.,
    - Update/add tests based on this change

 - Make sure the conditional logic to enable the model auto configuration is at the class level so that the configuration properties as well as the models are not enabled when the model is explicitly disabled. By default, the condition will allow enabling the beans if not explicitly overridden.

- Remove spring-ai-spring-boot-autoconfigure as a dedicated auto-configuration module

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:22 -04:00
Soby Chacko
8a1dcfc225 Conditionally enable invidividual vector store implementations
- Introduce top level properties to support conditional logic
- The properties will have the format like "spring.ai.vectorstore.type=<vectorstore provider>" to enable specific vectore store implementation
- By default, these will be enabled when no specific properties are set. To disable, set any value other than the provider name for example, none"

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-24 15:34:22 -04:00
Ilayaperumal Gopinathan
6b12ff5ae1 Refactor autoconfigurations for models
- Conditionally enable invidividual models within the provider
     - Introduce top level properties to support conditional logic
        - The properties will have the format like "spring.ai.model.<chat/embedding/image etc.,>=<provider>" to enable specific chat/embedding/image/audio/moderation models by the provider. By default, these will be enabled when no specific properties are set. To disable, set any value other than the provider name for example, "none"

    - For the auto configurations where the provider has multiple models, split the autoconfiguration into per model auto-configuration classes. This will enable the isolated auto-configurations for each provider and its model.
      - This PR addresses this for OpenAI and others will follow in subsequent PRs

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:22 -04:00
Soby Chacko
31bc8c470d Migrate vector store observation autoconfiguration to dedicated module
Update the vector store starters with the new observation autoconfig dependency

Other maven configuraiton changes

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-24 15:34:22 -04:00
Soby Chacko
fd1f0d9431 Migrate Azure and CosmosDB vector store auto-configurations to dedicated modules
Update dependencies and module names in maven pom.xml files

Update corresponding starter modules

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-24 15:34:22 -04:00
Soby Chacko
505046749f Migrate vector store auto-configurations to dedicated modules
Move vector store auto-configuration classes to dedicated modules under auto-configurations/vector-stores/:
- Creates separate modules for Cassandra, Chroma, Elasticsearch, GemFire, HanaDB, MariaDB, MongoDB Atlas, Neo4j, OpenSearch, Oracle, PGVector, and Redis vector stores
- Updates package names to follow the pattern org.springframework.ai.vectorstore.<implementation>.autoconfigure
- Renames corresponding starter modules to follow the pattern spring-ai-starter-vector-store-<implementation>
- Updates import paths in affected classes
- Relocates test resources alongside their respective implementations
- Updates imports in spring-ai-spring-boot-docker-compose and spring-ai-spring-boot-testcontainers

This change improves modularity by allowing each vector store implementation to be
independently versioned and maintained, following the migration pattern established
with previous vector store autoconfiguraiton and starters .

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-24 15:34:22 -04:00
Ilayaperumal Gopinathan
448a1aecc9 Fix model autoconfiguration updates for vertext ai and zhipuai 2025-03-24 15:34:22 -04:00
Soby Chacko
7f24740690 Migrate vector store auto-configurations to dedicated modules
Move vector store auto-configuration classes to dedicated modules under auto-configurations/vector-stores/:

- Creates separate modules for Milvus, Pinecone, Qdrant, and Typesense vector stores
- Moves CommonVectorStoreProperties to spring-ai-core for better reusability
- Updates pom.xml dependencies to maintain proper relationships between modules
- Name the artifacts based on the pattern spring-ai-autoconfigure-vector-store-<implementation>.
  For example - spring-ai-autoconfigure-vectore-store-milvus
- Package names follow the pattern org.springframework.ai.vectorstore.<implementation>.autoconfigure
- Naming the correspondinbg starter modules accordingly (spring-ai-starter-vector-store-milvus for example).

This change improves modularity by allowing each vector store implementation to be
independently versioned and maintained, continuing the migration pattern established
with previous vector stores.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-24 15:34:22 -04:00
Ilayaperumal Gopinathan
0453fc55d5 Modularise Spring AI Spring Boot autoconfigurations
- Split spring-ai-spring-boot-autoconfigure into modules

     - This PR addresses the restructuring of the following spring boot autoconfigurations:

       - spring-ai retry -> common
       - spring-ai chat client/model/memory -> chat
       - spring-ai chat/embedding/image observation -> observation
       - spring-ai chat/embedding models -> models

     - Update the Spring AI BOM and boot starters with the new autoconfigure modules

     - Rename the autoconfiguration and starters

        - The package name for the models in autoconfiguration classes will have `org.springframework.ai.model.<name>.autoconfigure`
        - Both the autoconfiguration and starters will have the prefix `spring-ai-autoconfigure-model` and `spring-ai-starter-model` respectively

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-24 15:34:22 -04:00
P.Sri Varshan
d8ef6efa9c Fix: Added missing return statement in Couchbase Cluster bean example (#2557)
Signed-off-by: PSriVarshan <psvvarshan@gmail.com>
2025-03-24 11:43:24 +00:00
Alexandros Pappas
29002dfc0d chore: remove unused imports (#2542)
Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-21 12:20:29 +00:00
ghdcksgml1
e4357ba2c1 Refact onFinishReason method to utility class
Test AdvisedResponseStreamUtils

Add java docs

Signed-off-by: ghdcksgml1 <ghdcksgml2@naver.com>
2025-03-21 11:10:07 +00:00
Laurent Doguin
d25d37ab12 GH-938: Add Couchbase vector store support
Fixes: #938

Issue link: https://github.com/spring-projects/spring-ai/issues/938

This commit integrates Couchbase as a vector store option in Spring AI, providing:

- CouchbaseSearchVectorStore implementation with vector similarity search capabilities
- Support for metadata filtering with SQL++ expression conversion
- Spring Boot auto-configuration and starter module for easy integration
- Comprehensive documentation covering setup, configuration, and usage examples
- Integration tests using TestContainers with Couchbase 7.6

The implementation supports configuring dimensions, similarity functions (dot_product/l2_norm),
and optimization strategies (recall/latency). Schema initialization is now opt-in via
the initializeSchema property. Documentation includes both auto-configuration and
manual configuration instructions, along with property configuration details.

Signed-off-by: Abhiraj <abhiraj.official15@gmail.com>

co-authored-by: Laurent Doguin <laurent.doguin@gmail.com>
2025-03-20 18:59:56 -04:00
gongzhongqiang
6b25b62771 fix: Update import and remove qodana configuration
- Update ToolCallback import to use relative package path
- Remove qodana.yaml file from the project

Signed-off-by: gongzhongqiang <gongzhongqiang@apache.org>
2025-03-19 16:17:46 +00:00
gongzhongqiang
f167fd8b3c fix: Update testNonExistingUrl to testNonExistingHtmlResource, use not exist classpath resource
Signed-off-by: gongzhongqiang <gongzhongqiang@apache.org>
2025-03-19 15:43:59 +00:00
Hu Shihao
4c0813dfb3 Update tools.adoc Corrected incorrect punctuation usage (#2503)
Original:
ChatOptions chatOptions = ToolCallingChatOptions.builder()
    .toolCallbacks(customerTools)
    .toolContext(Map.of("tenantId", "acme"))
    .build():

After Change:
ChatOptions chatOptions = ToolCallingChatOptions.builder()
    .toolCallbacks(customerTools)
    .toolContext(Map.of("tenantId", "acme"))
    .build();

Signed-off-by: Hu Shihao <122598964+Hushihaoooooo@users.noreply.github.com>
2025-03-19 11:52:08 +00:00
cc0824
61c60a6126 Update deepseek-chat.adoc (#2515)
Signed-off-by: cc0824 <45746445+cc0824@users.noreply.github.com>
2025-03-19 11:49:15 +00:00
Alexandros Pappas
4fc6edd80c chore: remove unused imports from core - tests - autoconfigure (#2471)
Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-17 15:55:04 +00:00
Alexandros Pappas
1f2713801c chore: remove unused imports (#2470)
Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-17 15:53:52 +00:00
shown
0164b5dcf9 optimize: OpenAI chat model code cleanup (#2483)
* optimize: use already defined variables

Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
2025-03-17 15:51:10 +00:00
gongzhongqiang
3f344a311d fix: Fix validate prefix and toolName logic in prefixedToolName method
Signed-off-by: gongzhongqiang <gongzhongqiang@apache.org>
2025-03-17 15:47:31 +00:00
jonghoon park
77ee57cec0 allow null usage for openai embedding model
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-03-17 15:43:27 +00:00
MagicalConch
cdac6ee42f Update mcp-client-boot-starter-docs.adoc
Signed-off-by: MagicalConch <37917403+git102347501@users.noreply.github.com>
2025-03-17 15:36:46 +00:00
Christian Tzolov
690d242c22 feat: Add AOP proxy support to MethodToolCallbackProvider
This change ensures that @Tool annotated methods can be properly discovered even when the tool objects are wrapped
in Spring AOP proxies, which is common when using aspects or other proxy-based features.

- Enhance MethodToolCallbackProvider to properly handle AOP proxied tool objects by detecting proxies
  and retrieving their target classes when scanning for @Tool annotated methods.
- Add test suite in MethodToolCallbackProviderAopTests.java to verify AOP proxy handling

Resolves #2356

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-14 10:47:53 +01:00
Alexandros Pappas
bc375ab961 This commit enhances AzureOpenAiChatOptions by:
- Adding `equals` and `hashCode` methods for proper object comparison.
- Implementing a deep `copy()` method, creating new instances of mutable collections (List, Set, Map, Metadata) to prevent shared state.
- Adding `AzureOpenAiChatOptionsTests` to verify `copy()`, builders, setters, and default values.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-13 11:39:49 +01:00
Gareth Evans
beb81ef409 chore: add missing toolCallbacks(vargs) to vertex chat options
Signed-off-by: Gareth Evans <gareth@bryncynfelin.co.uk>
2025-03-13 07:57:10 +01:00
Christian Tzolov
9e390c11a8 docs: Update repository configuration in getting-started guide
- Reorganize sections to focus on Milestones vs Snapshots instead of specific versions
- Add Central Portal Snapshots repository configuration for both Maven and Gradle

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-12 14:03:36 -04:00
CChuYong
268248ba3c Fix PgVectorStore doDelete function as batch
Signed-off-by: CChuYong <yeongmin1061@gmail.com>
2025-03-12 17:51:39 +00:00
Soby Chacko
d5203ed038 Fix array comparison and add final modifiers in embedding classes
- Fix Embedding equals() using Arrays.equals() for embedding array comparison
- Fix Embedding hashCode() using Arrays.hashCode() for proper array hashing
- Add final modifiers to fields in Embedding classes

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-03-12 16:56:44 +00:00
ivy
127f7009eb fix: Improve error handling in MCP tool callbacks
- Add null check for isError() method in SyncMcpToolCallback
- Implement consistent error handling in AsyncMcpToolCallback to match SyncMcpToolCallback behavior
- Throw IllegalStateException with error content when tool calls fail

Resolves #2447

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-12 14:17:00 +01:00
Manuel Andreo Garcia
e4853d757a fix azure openai chat model doc OpenAIClientBuilderCustomizer usage example
Signed-off-by: Manuel Andreo Garcia <manuel@magware.dev>
2025-03-12 10:30:49 +00:00
Christian Tzolov
a3b2462f1c Add condition tests for MCP client transport auto-configurations
- Add SseHttpClientTransportAutoConfigurationTests to verify conditional bean creation for HTTP client transports
- Add SseWebFluxTransportAutoConfigurationTests to verify conditional bean creation for WebFlux client transports
- Test both auto-configurations with various conditions including presence/absence of WebFluxSseClientTransport and MCP client enabled/disabled states

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-12 10:27:04 +00:00
Justin Martz
dcc91487b4 Update openai-chat.adoc
Existing example displays a typo in the code example for Runtime Options:

ChatResponse response = chatModel.call(
    new Prompt(
        "Generate the names of 5 famous pirates.",
        OpenAiChatOptions.builder()
            .model("gpt-4-o")
            .temperature(0.4)
        .build()
    ));

Using gpt-4-0 generates this error:
org.springframework.ai.retry.NonTransientAiException: 404 - {
    "error": {
        "message": "The model `gpt-4-o` does not exist or you do not have access to it.",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

Changing the model String in the example to "gpt-4o" resolves this.
2025-03-12 07:28:10 +00:00
虎鸣
66e8d88815 chore: Remove unnecessary public modifier in ToolCallbackProvider.
Signed-off-by: 虎鸣 <hepin.p@alibaba-inc.com>
2025-03-11 21:03:30 +00:00
Alexandros Pappas
e81f64c0fc feat(spring-ai-azure-openai): update azure-open-ai-client to 1.0.0-beta.14
resolves https://github.com/spring-projects/spring-ai/issues/2424

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-11 16:09:37 -04:00
Christian Tzolov
0b5da6b8c8 refactor: replace direct dependencies with ObjectProvider in MCP transports
Replace direct dependencies with ObjectProvider pattern in SSE transport auto-configurations.

- Uses ObjectProvider for ObjectMapper and WebClient.Builder dependencies
- Removes redundant @ConditionalOnMissingBean methods
- Provides fallback instantiation when dependencies are not available

Resolves #2440

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-11 17:44:50 +01:00
Christian Tzolov
3f7f2f1bff fix(mcp): standardize MCP tool name formatting and improve error handling
- Add prefixedToolName utility method to ensure consistent tool name formatting
- E nforce alphanumeric, underscore, and hyphen characters only in tool names
- Limit tool names to 64 characters maximum
- Use original tool name in actual calls while using formatted names in definitions
- Add error handling for tool call responses in SyncMcpToolCallback
- Update tests to reflect the changes

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-11 17:28:47 +01:00
Ilayaperumal Gopinathan
ded9facfe5 Remove deprecations from 1.0.0-M6
- Remove deprecations from models, vector stores and usage
- Deprecations from FunctionCallback and ObservationContext/Convention will be in a separate PR

Models updates
  - Remove AbstractToolCallSupport from the models which use ToolCallingManager
  - Remove deprecated constructors and their usage
  - Remove FunctionCallbackResolver and FunctionCallbacks usage in the models

- Add back deprecations for VectorStoreChatMemoryAdvisor until builder is fixed

- Update OpenAiPaymentTransactionIT to use ToolCallbackResolver in config

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-03-11 10:42:03 -04:00
Ilayaperumal Gopinathan
a1e417f350 Fix McpServerAutoConfigurationIT
- Fix MCP client mock for client info
2025-03-11 14:31:03 +00:00
Christian Tzolov
957150128b feat(mcp): Prefix tool names with client name to avoid naming conflicts
Enhances MCP tool naming by prefixing tool names with their client + transport name
to prevent conflicts when multiple MCP clients expose tools with the same name.

- Modifies client info in McpClientAutoConfiguration to include transport name
- Updates SyncMcpToolCallback and AsyncMcpToolCallback to prefix tool names with client + transport name
- Adds test coverage for tools with identical names but different client info

Resolves #2393

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-11 13:14:52 +01:00
Christian Tzolov
58ed5ea59f feat(mcp): handle ToolContext in MCP tool callbacks
- Implement the new ToolCallback.call(String, ToolContext) method in both Sync and Async MCP tool callbacks.
- Since MCP tools don't support tool context, the implementation ignores the context parameter and
  delegates to the existing call(String) method. Added test to verify the behavior.

Resolves #2378

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-10 15:04:26 +01:00
Dariusz Jędrzejczyk
28bceb3ac5 Prevent blocking event loop calling tools
When streaming happens on an event loop, due to the fact that currently
tools can only be synchronous and blocking, every tool call needs to be
offloaded to a blocking-safe Scheduler.

Resolves #2341

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2025-03-10 14:08:56 +01:00
Thomas Vitale
5a4e9f5108 Request-time filter expressions for RAG
When using the RetrievalAugmentationAdvisor with the VectorStoreDocumentRetriever, it’s now possible to provide a filter expression at request-time as an advisor context variable with key VectorStoreDocumentRetriever.FILTER_EXPRESSION.

Fixes gh-1776

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-03-10 11:45:17 +00:00
Alexandros Pappas
82b46d2182 feat: add JSoup HTML document reader
This commit introduces the `JsoupDocumentReader` and `JsoupDocumentReaderConfig` classes, which provide functionality to read and parse HTML documents using the JSoup library.

The reader supports:
- Extracting text from specific HTML elements using CSS selectors.
- Extracting all text from the body of the document.
- Grouping text by element.
- Extracting metadata, including the document title, meta tags, and link URLs.
- Reading from various resource types (files, URLs, byte arrays).
- Configurable character encoding, selector, separator, and metadata extraction.

This new reader enhances Spring AI's ability to process web content and other HTML-based data sources.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-10 11:34:25 +00:00
CChuYong
a6b4555d45 fix typo in spring-ai-mcp-server
Signed-off-by: CChuYong <yeongmin1061@gmail.com>
2025-03-10 12:11:00 +01:00
Christian Tzolov
72bb5ca296 feat(mcp): Update to MCP SDK 0.8.0-SNAPSHOT and fix client initialization
- Make MCP client initialization blocking with .block() call
- Upgrade MCP SDK version from 0.7.0 to 0.8.0-SNAPSHOT

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-10 10:46:09 +00:00