Commit Graph

1745 Commits

Author SHA1 Message Date
ogbozoyan
cd871eaddc VectorStoreChatMemoryAdvisor constructors cleanup
- Deprecate all constructors except one with all fields
 - Update the build method to include order in the VectorStoreChatMemoryAdvisor's constructor
2025-02-06 17:32:42 +00:00
Soby Chacko
6035516044 GH-2165: Simplify VectorStore delete method to return void
- Change VectorStore.delete() and related implementations to return void instead of Optional<Boolean>
- Remove unnecessary boolean return values and success status checks across all vector store implementations
- Clean up tests by removing redundant assertions
- Implementations continue using runtime exceptions for error signaling

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-02-06 15:10:47 +00:00
Ilayaperumal Gopinathan
b46615921d Getting started page cleanup 2025-02-06 11:40:29 +00:00
Chris Bailey
e1fdef1240 docs: fix grammatical issue in API provider description 2025-02-06 11:26:49 +00:00
Xiaojie Wang
325fa97f51 Fix document formatting to correctly display code blocks
Use proper Markdown syntax to wrap code blocks, enabling correct syntax highlighting when rendered.
2025-02-06 11:25:37 +00:00
Ilayaperumal Gopinathan
58e05dc0e0 Fix FunctionCallbackKotlinIT.kt
- Update to use ToolCallingChatOptions as functionOptions
2025-02-06 11:08:38 +00:00
Ilayaperumal Gopinathan
f3c0ea0266 Fix MariaDB java client version in Spring AI Spring Boot Autoconfiguration 2025-02-06 10:17:13 +00:00
Thomas Vitale
01632c5d20 Add merge for missing Ollama options
When fields in OllamaOptions are marked as ignored in Jackson, they require explicit merge of runtime and default options.
Added tests to validate the different merge combinations for all tool-related options.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-06 10:13:40 +01:00
Thomas Vitale
ecae493704 Fix handling of nullable fields in OllamaChatModel deprecated constructor (#2174)
Fix gh-2172

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-05 23:29:01 -05:00
Ilayaperumal Gopinathan
1c6132caf4 Update to Spring Boot 3.4.2 for dependency management (#2176)
- Spring AI's dependencies management to derive from Spring Boot 3.4.2
    - Remove explicit versioning of dependencies
  - Update upgrade notes for Spring Boot 3.4.2
  - Fix ElasticSearch client changes with the latest dependency derived from Spring Boot 3.4.2
2025-02-05 23:25:18 -05:00
Ilayaperumal Gopinathan
54f49b5580 Fix PgVectorAutoconfiguration to use PgIDType 2025-02-05 23:39:34 +00:00
jitokim
4dbe73433a Refactor ID handling for different IdType formats
- Add handling for UUID, TEXT, INTEGER, SERIAL, BIGSERIAL formats in `convertIdToPgType` function.
- Implemented type conversion logic based on the IdType value (UUID, TEXT, INTEGER, SERIAL, BIGSERIAL).
- Add unit tests to validate correct conversion for UUID and non-UUID IdType formats.
  - `testToPgTypeWithUuidIdType`: Validates UUID handling.
  - `testToPgTypeWithNonUuidIdType`: Validates handling for non-UUID IdTypes.

Signed-off-by: jitokim <pigberger70@gmail.com>
2025-02-05 23:39:34 +00:00
Christian Tzolov
f40945bd63 Add Spring AI MCP Integration
Adds comprehensive Model Context Protocol (MCP) integration to Spring AI, including:

Core Features:
- MCP client implementation with Spring AI tool calling capabilities
- Spring-friendly abstractions for MCP clients and servers
- Both synchronous and asynchronous MCP server operation modes
- Add MCP client autoconfiguration with support for STDIO, WebMVC and WebFlux transports
- Auto-configuration for MCP server components
- Spring Boot starter (spring-ai-starter-mcp) with WebFlux and WebMVC support
- MCP dependency management with BOM
- Add close() method to McpToolCallback for proper resource cleanup
- Add initialize flag to control MCP client initialization
- Add comprehensive integration tests and documentation for MCP client configuration

Technical Improvements:
- Split WebMvc and WebFlux configurations into separate auto-configuration classes
- Server type configurable via 'spring.ai.mcp.server.type' property (SYNC/ASYNC)
- Comprehensive test coverage including McpServerAutoConfigurationIT
- Utility classes for converting between Spring AI tools and MCP tools
- MCP SDK version management in parent pom

Reorganize MCP tool utilities and client configuration

- Rename ToolUtils to McpToolUtils for better MCP-specific naming
- Rename McpToolCallbackProvider to SyncMcpToolCallbackProvider
- Add utility methods for handling tool callbacks in McpToolUtils
- Extract client configuration logic into new McpClientDefinitions class
- Add tool callback support to ChatClient interface and implementations
- Remove redundant integration test

Introduce MCP client customization support

- Add McpSyncClientCustomizer interface for customizing MCP sync clients
- Replace McpClientDefinitions with McpSyncClientConfigurer
- Refactor MCP client initialization to support customization
- Remove redundant close() method from McpToolCallback
- Fix conditional class dependencies in WebMvc/Flux configurations

Add MCP AOT hints

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-02-05 15:54:48 -05:00
Mark Pollack
fc2690cdf8 Add flexible API key management for OpenAI
Introduces a new API key interface that allows users to customize how
API keys are provided and managed in their Spring AI applications. This
change improves security and flexibility by:

- Adding core ApiKey interface and SimpleApiKey implementation
- Adding builder pattern for OpenAiApi creation
- Deprecating public constructors in favor of builder API (since 1.0.0.M6)
- Added docs

The new system enables users to implement their own key management
strategies while maintaining backward compatibility with property-based
configuration.
2025-02-05 14:57:41 -05:00
Ricken Bazolo
45421b1c93 improved ability to use openAiApi to support DeepSeek
Signed-off-by: Ricken Bazolo <ricken.bazolo@gmail.com>
2025-02-05 16:13:50 +00:00
Alexandros Pappas
35101e75ae feat: Add reasoningEffort parameter to OpenAI API and Chat Options
This commit introduces the `reasoningEffort` parameter to the OpenAI API integration, allowing control over the reasoning effort used by models like `o1-mini`.

Changes:
- Adds `reasoningEffort` field to `OpenAiApi.ChatCompletionRequest`.
- Adds `reasoningEffort` field and builder method to `OpenAiChatOptions`.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-02-05 13:01:29 +00:00
Konstantin Pavlov
b525309e8c Introduce PII marker for logging sensitive data
Introduce a utility class `LoggingMarkers` providing an SLF4J marker for tagging log entries with Personally Identifiable Information (PII). Update `BeanOutputConverter` to use the `PII_MARKER` in error logs for invalid JSON conversions. Enhance tests to verify PII marker usage in logging.

 - Set Java version dynamically and configure Kotlin compiler

 - Updated Maven configurations to dynamically reference the Java version using `${java.version}`. Added Kotlin compiler settings, including `jvmTarget` alignment with Java version and enabling `javaParameters`. This ensures consistency and better compatibility across builds.

 - Fix log assertion in BeanOutputConverterTest to use Java 17

 - Updated the test to assert log size explicitly before accessing the first log entry. This ensures the test is more robust and avoids potential issues with accessing logs unexpectedly.

 - Use placeholders in logger.error to prevent string concatenation.

 - Replaced string concatenation with a placeholder in the logger.error call to improve performance and maintain consistency with logging best practices. This helps avoid unnecessary overhead when logging is disabled.

 - Update logging markers and improve data classification

 - Replaced `PII_MARKER` with `SENSITIVE_DATA_MARKER`. Introduced `RESTRICTED_DATA_MARKER`, `REGULATED_DATA_MARKER` and `PUBLIC_DATA_MARKER`

 - Updated associated logging logic and tests to reflect these changes.

 - Fix punctuation in Javadoc comments for LoggingMarkers.

 - Added missing periods to improve consistency and clarity in the Javadoc comments. This change ensures proper formatting and adheres to standard writing conventions.

Signed-off-by: Konstantin Pavlov <{ID}+{username}@users.noreply.github.com>
2025-02-05 11:09:24 +00:00
Alexandros Pappas
74178b9f0e feat: Update OpenAI Chat Models to Latest Versions and Improve Documentation
This commit comprehensively updates the OpenAiApi `ChatModel` enum to include all the latest OpenAI chat completion models and enhances the documentation.

Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-02-05 10:40:09 +00:00
Thomas Vitale
2c8579278a Advancing Tool Support - Part 6
* Completed new documentation for Tool Calling
* Added deprecation notes and migration guide to documentation
* Made “call” methods explicit in ToolCallback API
* Consolidated naming: ToolCallExceptionConverter -> ToolExecutionExceptionProcessor
* Consolidated naming: ToolCallResultConvert.apply() -> ToolCallResultConvert.convert()
* Redraw diagrams for consistency

Relates to gh-2049

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-05 10:30:30 +01:00
themanojshukla
c92f2d3096 Fix spell error and updated gemma model name
Signed-off-by: themanojshukla <themanojshukla@gmail.com>
2025-02-04 16:15:07 +00:00
Thomas Vitale
560baaae5a Advancing Tool Support - Part 5
* Introduced new ToolParam annotation for defining a description for tool parameters and marking them as (non)required.
* Improved the JSON Schema generation for tools, solving inconsistencies between methods and functions, and ensuring a predictable outcome.
* Added support for returning tool results directly to the user instead of passing them back to the model. Introduced new ToolExecutionResult API to propagate this information.
* Consolidated naming of tool-related options in ToolCallingChatOptions.
* Fixed varargs issue in ChatClient when passing ToolCallback[].
* Introduced new documentation for the tool calling capabilities in Spring AI, and deprecated the old one.
* Bumped jsonschema dependency to 4.37.0.

Relates to gh-2049

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-04 12:59:17 +01:00
Ilayaperumal Gopinathan
854e5458e4 Re-enable WeaviateDockerComposeConnectionDetailsFactoryIT
- An attempt to fix the underlying issue with this IT test was made via https://github.com/spring-projects/spring-ai-integration-tests/pull/7
2025-02-04 00:09:56 +00:00
Ilayaperumal Gopinathan
c5becf7429 Fixes for Integration Tests
- Multi modality image tests to assert with containsAny instead of contains specific values
 - Expand Mistral functionCall test's usage metrics range
2025-02-03 23:42:37 +00:00
Mark Pollack
4e1358a954 Remove target_test-classes directory that was accidentally added 2025-02-03 16:06:00 -05:00
Mark Pollack
a562b8d8cb Remove explicit versioning of slf4j in pom.xml 2025-02-03 15:38:29 -05:00
Ilayaperumal Gopinathan
2932769883 Switch back to use slf4j logging
- Revert the changes to update to use Apache Commons Logging and re-add the previously used slf4j logging
2025-02-03 15:31:43 -05:00
Ilayaperumal Gopinathan
b86772d44c Add reference doc for Usage changes
- Add documentation for the recent changes on Usage handling
- Add details on how to refer model specific native usage
- Update upgrade notes
2025-02-03 15:05:50 -05:00
Soby Chacko
16a596f8b7 Add getNativeClient API to VectorStore interface
Adds getNativeClient API to VectorStore interface allowing access to the underlying native client implementation.

This change:
- Adds getNativeClient() default method to VectorStore interface returning Optional<T>
- Implements getNativeClient() in all vector store implementations exposing their respective native clients
- Adds integration tests verifying native client access for all implementations

Fixes: #2137

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-02-03 14:49:36 -05:00
Ilayaperumal Gopinathan
54463e6622 Fix EmbeddingIT#defaultEmbedding test
- Use text-embedding-ada-002-v2 as OpenAI routes to text-embedding-ada-002-v2 by default
2025-02-03 14:03:42 +00:00
yunjun-lee-kurly
3d3c20d42d Fix typo in deepseek model name in deepseek-chat.adoc
Signed-off-by: yunjun-lee-kurly <yunjun.lee@kurlycorp.com>
2025-02-01 12:38:42 +00:00
Ilayaperumal Gopinathan
ca27895da4 Remove deprecated Amazon Bedrock chat models
- Amzon Bedrock chat models were deprecated to support Amazon Bedrock Converse API for the chat models.
 - This PR removes all the references of the deprecated Amazon Bedrock chat models
   - Remove Amazon Bedrock chat models for anthropic, anthropic3, cohere, jurassic2, titan
      - Remove API, chat options and model
      - Remove tests and doc references
   - Update the doc to reflect the changes
   - Update upgrade notes

Resolves #2124

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-01-31 16:11:52 -05:00
Soby Chacko
69200e621d Introduce Step Builder pattern for PineconeVectorStore
Replace the existing builder implementation with a type-safe Step Builder pattern
to enforce required field initialization in a specific order. This change:

- Introduces a new builder() method that guides users through required fields
- Deprecates the old builder method with all parameters
- Makes field configuration more explicit and type-safe
- Updates all usage points to use the new builder pattern

The required fields must now be provided in sequence:
1. embeddingModel
2. apiKey
3. projectId
4. environment
5. indexName

This change improves API usability by preventing parameter confusion and ensuring
all required fields are set before optional configuration.
2025-01-31 16:07:54 -05:00
Soby Chacko
8162029cc6 Add filter-based deletion to Weaviate vector store (#2150)
Implement filter-based deletion for WeaviateVectorStore by leveraging the
existing ID-based deletion mechanism.

Key changes:

- Add doDelete(Filter.Expression) implementation that delegates to the existing
  ID-based deletion method
- Use similarity search with filter to find matching documents first
- Delete matched documents by their IDs
- Add integration tests for filter deletion scenarios:
  * Deleting by simple equality filter
  * Deleting by string-based filter expression

This maintains consistency with other vector store implementations while
working around Weaviate's limitations in direct filtered deletion.
2025-01-31 15:46:54 -05:00
Mark Pollack
cc730268e7 Fix race condition waiting for status of ollama model pull success status 2025-01-31 11:11:44 -05:00
Ilayaperumal Gopinathan
a61437df6e Fix usage metrics for the MistralAiChatModelIT tests 2025-01-31 14:40:46 +00:00
Thomas Vitale
b902ca2afb Advancing Tool Support - Part 4
* Adopted new tool calling logic in OllamaChatModel, while maintaining full API backward compatibility thanks to the LegacyToolCallingManager.
* Improved efficiency and robustness of merging options in prompts for Ollama.
* Update Ollama Autoconfiguration to use the new ToolCallingManager.
* Improved troubleshooting for new tool calling APIs and finalised changes for full backward compatibility.
* Updated Ollama Testcontainers dependency to 0.5.7.

Relates to gh-2049

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-01-30 17:34:24 +01:00
Ilayaperumal Gopinathan
76ab91fab8 Maven central release workflow cleanup 2025-01-30 10:41:24 +00:00
Soby Chacko
b9549d5ed2 Add filter-based deletion to Cassandra Vector Store (#2143)
Implement filter-based deletion for CassandraVectorStore to support more
    flexible document removal based on metadata filters.

    Key changes:

    - Add doDelete(Filter.Expression) implementation
    - Implement workaround for Cassandra's limitations in direct filtered deletion
    - Fetch matching documents first, then delete by IDs
    - Add integration tests for various filter deletion scenarios
    - Support simple and complex filter expressions
    - Includes tests for:
      * Deleting by simple equality filter
      * Deleting by string-based filter expression
      * Deleting by complex AND filter expression

    Provides consistent deletion capabilities across vector store implementations
    while addressing Cassandra-specific constraints.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-01-29 15:42:55 -05:00
Soby Chacko
bd52786de7 Add filter-based deletion and refactor tests for Pinecone vector store (#2142)
Add string-based filter deletion alongside the Filter.Expression-based deletion
for Pinecone vector store and improve test organization through refactoring.

Key changes:
- Add delete(Filter.Expression) implementation using two-step process:
  * Search for documents matching filter
  * Delete matching documents by ID
- Leverage existing search functionality to maintain filter consistency
- Extract common test patterns into helper methods
- Create reusable document factory methods for test data
- Add comprehensive integration tests for filter deletion
- Standardize test cleanup and verification patterns

This maintains consistency with other vector store implementations while
working within Pinecone's API limitations. The test refactoring improves
maintainability and makes the test patterns clearer and more consistent.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-01-29 15:34:16 -05:00
Soby Chacko
49f2320c38 Add filter-based deletion to Typesense vector store (#2140)
Add string-based filter deletion alongside the Filter.Expression-based deletion
for Typesense vector store, providing consistent deletion capabilities with
other vector store implementations.

Key changes:
- Add delete(Filter.Expression) implementation using Typesense filter expressions
- Leverage existing TypesenseFilterExpressionConverter for filter translation
- Use Typesense's DeleteDocumentsParameters for filtered deletion
- Add comprehensive integration tests for filter deletion
- Support both simple and complex filter expressions

This maintains consistency with other vector store implementations while
utilizing Typesense's native filtering capabilities for efficient metadata-based
deletion.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-01-29 15:29:51 -05:00
Ilayaperumal Gopinathan
8cf33fe664 Cleanup artifactory and maven release actions
- Delete the old maven central release workflow and replace it with the new workflow which uses nexus staging plugin
 - Delete the artifactory staging release workflow as it is no longer needed
     - This was used to push the artifacts into repo.spring.io libs-staging-local before pushing into sonatype staging. With the nexus staging plugin, we directly push the artifacts into sonatype staging
 - Delete maven central staging release workflow as it is no longer needed as well
2025-01-29 18:58:38 +00:00
Ilayaperumal Gopinathan
97f7768054 Fix required POM attributes for maven staging deployment 2025-01-29 18:58:38 +00:00
Ilayaperumal Gopinathan
bac8fcc24b Remove documentation upload from the new maven central release workflow 2025-01-29 18:58:38 +00:00
Christian Tzolov
bb3fde3622 Fix logger reformating error 2025-01-29 19:57:46 +01:00
Christian Tzolov
f36b73cce2 refactor: migrate from functions to tools terminology
Refactors the test codebase to use tools instead of functions.

- Rename FunctionCallback to FunctionToolCallback
- Rename FunctionCallingOptions to ToolCallingChatOptions
- Update API methods from functions() to tools()
- Deprecate function-related methods in favor of tool alternatives
- Refactor MethodToolCallback implementation with improved builder pattern
- Update all tests to use new tool-based APIs
- Add funcs to tools migration guide

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-01-29 19:50:41 +01:00
Ilayaperumal Gopinathan
ff287a5457 Add maven central release GH Action workflow 2025-01-29 17:26:32 +00:00
Mark Pollack
6c5df08c3b Add javadoc .jar generation, remove javadoc profile 2025-01-29 17:25:36 +00:00
Assassinxc
62ce753b12 Add dimensions option for ZhiPuAi embedding model
- Add dimentions options
 - Add doc for ZhiPuAi embedding dimensions option

Signed-off-by: Assassinxc <330109311@qq.com>
2025-01-29 11:51:30 +00:00
Ilayaperumal Gopinathan
14ec6b2dc0 Use Usage#getCompletionTokens instead of deprecated Usage#getGenerationTokens 2025-01-29 10:58:57 +00:00
Ilayaperumal Gopinathan
78a58a15e8 Update commons logging for the latest changes 2025-01-29 10:21:20 +00:00