Commit Graph

626 Commits

Author SHA1 Message Date
Ilayaperumal Gopinathan
b46615921d Getting started page cleanup 2025-02-06 11:40:29 +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
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
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
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
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
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
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
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
b08b9e8cf4 Support store and metadata OpenAI chat options
- Add store and metadata as OpenAI Chat options
 - Add test
 - Add docs

Resolves #2103
2025-01-28 12:51:34 -05:00
Alexandros Pappas
c33edc7bae Update SpringAI - DeepSeek image (#2135)
Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-28 09:18:25 -05:00
Alexandros Pappas
bada403643 Add documentation how to use the OpenAI client to access DeepSeek
Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-27 16:45:00 -05:00
Lee Won Jun
8f21c8db2b Update index.adoc 2025-01-27 16:34:53 -05:00
Ilayaperumal Gopinathan
4b64aa0ca6 Refactor Usage handling
- Remove model specific Usage implementations
- Add `Object getNativeUsage()` to Usage interface
  - This will allow the model specific Usage data to be returned
  - At the client side, client needs to cast the return type of `getNativeUsage` into the corresponding Usage returned by the model API
- Rename `generationTokens` to `completionTokens`
  - Since `completion` token name is more common among the models, renaming generation tokens into completion tokens
  - Maintain JSON deserialization compatibility for legacy `generationTokens` field
  - Remove deprecated Long-based constructors to avoid API ambiguity
- Change the prompt, completion and total token return types from Long to Integer
  - This is a breaking change that requires updating all constructor calls
  - Integer is sufficient for token counts and aligns better with most model APIs
- Use DefaultUsage for most of the model specific usage handling
  - When initializing set the native usage to the model specific usage type
  - Ensure immutability by making all fields final and removing setters
  - Add comprehensive test coverage for all functionality including edge cases

Resolves #1407
2025-01-27 16:29:07 -05:00
Eddú Meléndez
840304955e Use TypesenseContainer for Service Connection
Testcontainers 1.20.4 provides a new module for typesense with
TypesenseContainer implementation.

Signed-off-by: Eddú Meléndez <eddu.melendez@gmail.com>
2025-01-27 13:57:22 -05:00
Soby Chacko
f588716b41 Add filter-based deletion and string filter API to VectorStore
Add string-based filter deletion alongside the Filter.Expression-based deletion
for vector stores. This provides a more convenient API for simple filter cases
while maintaining the full flexibility of expression-based filtering.

Key changes:
- Add delete(Filter.Expression) and delete(String) methods to VectorStore
- Add default string filter implementation in VectorStore interface
- Implement filter deletion in Chroma/Elasticsearch/PgVector stores
- Add integration tests for both filter APIs across implementations

This extends vector store deletion capabilities while maintaining consistent
behavior across implementations.
2025-01-24 14:15:46 -05:00
Mark Pollack
7521cab9db Remove deprecated methods/classes from spring-ai-core 2025-01-24 13:37:14 -05:00
Alexandros Pappas
bb6b8cc20f Refactor OpenAIAudio builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.

Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-24 11:47:04 +00:00
Bruno Oliveira
1c41c6a802 Update index.adoc
Signed-off-by: Bruno Oliveira <olivbruno8@gmail.com>
2025-01-20 16:11:04 +00:00
Linar Abzaltdinov
ac8629c5b6 Fix(typo): add missing closing bracket in docs 2025-01-17 16:19:02 +00:00
Alexandros Pappas
7d53ef2056 chore: replace all instances of 'final static' with 'static final' 2025-01-15 15:16:12 +00:00
wellCh4n
cd5684a66e Fix sample code indent 2025-01-15 11:51:23 +00:00
Sébastien Deleuze
34ac31910d Kotlin updates (#2006)
* Update Kotlin documentation

This commit updates the Kotlin documentation to
showcase the new Kotlin reflection capabilities
allowing to identify required properties.

* Update Kotlin integration tests

This commit updates the Kotlin integration tests to
leverage the new Kotlin reflection capabilities
allowing to identify required properties.

It also adds a missing jackson-module-kotlin
dependency and refine test implementation to be
closer to the Java ones and use more idiomatic
Kotlin code.
2024-12-24 11:11:18 -05:00
Mark Pollack
86b155d6ff Update VectorStore docs to use inner builder class
Updated the manual configuration examples in the following docs to show
the correct usage of the inner builder class:

- azure.adoc: Show builder(searchIndexClient, embeddingModel) with all available options
- chroma.adoc: Show builder(chromaApi, embeddingModel) with collection config
- oracle.adoc: Show builder(jdbcTemplate, embeddingModel) with database options

The examples now reflect the current implementation where the builder takes
both the client and embedding model as constructor arguments.
2024-12-21 20:22:59 -05:00
Christian Tzolov
8ad90621c4 docs(mcp) Update the MCP documentation to latewt 0.2.0 release 2024-12-21 19:44:56 +01:00
Soby Chacko
d697e58c05 Update vector store builder examples
Update documentation examples to show correct builder usage across all vector store implementations.
Demonstrate passing required parameters directly in builder() method.
2024-12-21 11:28:39 -05:00
Ilayaperumal Gopinathan
a55d09aa7a Update document for SearchRequest builder changes 2024-12-21 11:18:06 -05:00
Ilayaperumal Gopinathan
2804604933 Refactor SearchRequest builder methods
- Add a new Builder inner class to move all the builder methods and deprecate the existing builder methods
 - Update docs and references
2024-12-20 19:35:17 +00:00
Sylvain Blanc
699a075e1c Update prompt.adoc
Remove `this.` in code example as it's local variables and not fields
2024-12-20 14:33:10 -05:00
Thomas Vitale
c7fd7c729e Refine and document initial Modular RAG
* Introduce CompressionQueryTransformer and RewriteQueryTransformer in the Pre-Retrieval Module.
* Extend Query with conversation history and context.
* Remove QueryRouter sub-module. New design will be considered in the next milestone.
* Update RetrievalAugmentationAdvisor accordingly.
* Add initial documentation for Modular RAG, and establish dedicated page for RAG content.

Fixes gh-1850

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-20 13:43:12 -05:00
Thomas Vitale
f2820cd8af Mistral: Support Vision Modality
Introduce multimodality support for Mistral AI, which currently supports text and vision modalities.
Added integration tests and documentation for the new capability.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-20 14:41:01 +01:00
Soby Chacko
d4a6e1e619 CosmosDB vector store builder refactoring 2024-12-19 13:40:18 -05:00
Soby Chacko
71584e5238 Add builder pattern to HanaCloudVectorStore and refactor package name 2024-12-19 13:21:29 -05:00
Ilayaperumal Gopinathan
7e4a187f0d Refactor Ollama builder API
The Ollama options builder API has been refactored to follow standard Java
builder pattern conventions. This change deprecates all builder methods
prefixed with 'with' in favor of more concise method names, improving API
consistency and usability.

The deprecated methods are marked for removal in version 1.0.0-M5, giving
users time to migrate to the new builder pattern. This change aligns with
our goal of providing a more intuitive and maintainable API surface.

Breaking Changes:

* builder() method now returns Builder instead of OllamaOptions
* Clients using the old fluent API will need to migrate to the new builder pattern
Refactor Ollama options builder methods
2024-12-18 22:39:42 -05:00
Thomas Vitale
6ab7e20616 Support Ollama JSON Structured Output
Ollama has recently introduced native support for JSON structured output, as described in https://ollama.com/blog/structured-outputs.
This PR introduces support for it, both for directly passing a JSON schema and when using the Spring AI output conversion APIs.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-18 11:43:57 +01:00
Alexandros Pappas
eccf33a6ec Refactor WatsonxAiChatOptions builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.
- Update WatsonxAi documentation
2024-12-17 22:00:36 +00:00
Alexandros Pappas
1d38fd11fd Refactor AnthropicChatOptions builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.
- Update AnthropicChatOptions builder documentation
2024-12-17 21:51:10 +00:00
Alexandros Pappas
de29df7c58 Refactor MistralAiChatOptions builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.
- Update MistralAiChatOptions builder documentation
2024-12-17 21:48:10 +00:00
Soby Chacko
48bcbd1555 Add builder pattern to QdrantVectorStore
Introduces a builder pattern for configuring QdrantVectorStore instances to
provide a more flexible and type-safe way to create and configure vector stores.
This change:

- Makes configuration more intuitive through fluent builder methods
- Improves validation by enforcing required parameters at compile time
- Deprecates old constructors in favor of the builder pattern
- Adds comprehensive builder tests to ensure reliability
- Updates reference documentation with builder usage examples
- Maintains backward compatibility while providing a clear migration path

The builder pattern simplifies QdrantVectorStore configuration by providing
clear method names, proper validation, and better IDE support through method
chaining. This makes the API more user-friendly and helps prevent configuration
errors at compile time rather than runtime.
2024-12-17 16:44:08 -05:00
Alexandros Pappas
8c51f7a84c Refactor MoonshotChatOptions builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.
- Update the `copy()` method to use the new builder methods.
- Update MoonshotChatOptions builder documentation
2024-12-17 21:10:24 +00:00
Soby Chacko
8edf1bea47 Add builder pattern to MariaDBVectorStore and refactor package name
Introduces a builder pattern for configuring MariaDBVectorStore instances and
improves the overall implementation. This change:

- Makes configuration more flexible and type-safe through builder methods
- Deprecates old constructors and builder in favor of the new builder pattern
- Adds comprehensive validation of configuration options
- Improves documentation with clear examples and better structure
- Updates all test classes to use the new builder pattern
- Adds comprehensive builder tests
- Updated reference documentation

The builder pattern provides a more maintainable and user-friendly way to
configure vector stores while ensuring configuration validity at compile time.
This aligns with the project's move towards using builder patterns across all
vector store implementations.
2024-12-17 15:56:45 -05:00
Soby Chacko
8877672846 Add builder pattern to TypesenseVectorStore and refactor package name
Introduces a builder pattern for configuring TypesenseVectorStore instances and
moves the implementation to the org.springframework.ai.vectorstore.typesense
package. This change:

- Makes configuration more flexible and type-safe through builder methods
- Improves code organization by moving to a dedicated vector store package
- Deprecates old constructors in favor of the builder pattern
- Adds comprehensive validation of configuration options
- Enhances documentation with clear usage examples
- Adds dedicated builder test class for better test coverage
- Add builder tests
- update reference docs

The builder pattern simplifies TypesenseVectorStore configuration while ensuring
proper validation of all settings. The package move aligns with Spring AI's
architectural patterns and improves maintainability by grouping related classes
together.

review
2024-12-17 15:09:16 -05:00
Ilayaperumal Gopinathan
18bc0cff25 Refactor QianFan model option builder methods
- Deprecate the builder methods with the prefix `with` and add the new methods
 - Update docs and references
2024-12-17 11:51:59 -05:00
Ilayaperumal Gopinathan
071b897951 Refactor Zhipu AI options builder methods
- Deprecate builder methods with the prefix `with`
 - Update docs and references
2024-12-17 11:46:27 -05:00
Ilayaperumal Gopinathan
3e82e3117f Refactor Vertex AI embedding/Gemini options builder methods
- Deprecate the builder methods with the prefix `with`
 - Update references and docs
2024-12-17 11:41:36 -05:00