Commit Graph

2021 Commits

Author SHA1 Message Date
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
magicgone
206b9e220a Add Context Support to Query in RetrievalAugmentationAdvisor
Signed-off-by: magicgone <magic4gone@gmail.com>
2025-03-10 10:40:02 +00:00
Alexandros Pappas
6512ec4257 Fix property name in Redis documentation
Fixes #2414

resolves: https://github.com/spring-projects/spring-ai/issues/2414

Current implementation of RedisProperties: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisProperties.java#L49

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-10 07:53:26 +00:00
hungrytech
bed1db352a fix vertordbs opensearch.adoc
Signed-off-by: hungrytech <xorals9448@gmail.com>
2025-03-08 18:52:54 +00:00
Ahoo Wang
1ca4709e39 fix(mcp-server): improve code quality and readability
- Remove unused imports
- Fix typos in variable names (e.g., toolResgistrations -> toolRegistrations)

Signed-off-by: Ahoo Wang <ahoowang@qq.com>
2025-03-08 18:46:08 +00:00
jonghoon park
2903b2019d fix typo in rag doc
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-03-07 12:34:53 +00:00
Christian Tzolov
87f45d0dac Improve referenced doc navigation
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-07 10:28:50 +01:00
jonghoon park
bf0558bb79 fix typo in McpToolUtils.java
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-03-06 16:34:34 +09:00
waileong
e128a39ec3 Updates the SearchRequest class to be non-final and adds a MilvusSearchRequest subclass that includes Milvus-specific fields for native expressions and search parameters.
- Updated `SearchRequest.java` to make the class non-final.
- Added `MilvusSearchRequest` with specific Milvus parameters such as `nativeExpression` and `searchParamsJson`.
- Modified `doSimilaritySearch` method in `MilvusVectorStore` to handle these new fields from `MilvusSearchRequest`.

Add unit tests for MilvusVectorStore and MilvusSearchRequest

Introduce comprehensive unit tests to validate the functionality of MilvusVectorStore and MilvusSearchRequest, including scenarios for native and filter expressions. Refactor MilvusVectorStore to improve filter expression handling by introducing a helper method for converted expressions.

Add detailed documentation for MilvusSearchRequest usage

Introduced sections explaining MilvusSearchRequest's parameters, `nativeExpression`, and `searchParamsJson`, with examples for enhanced clarity. This update provides guidance on leveraging Milvus-specific features for precise filtering and optimal search performance.

Signed-off-by: waileong <wai_leong1015@hotmail.com>
2025-03-05 11:33:07 +00:00
magicgone
bb7c52cdb1 Add documentFormatter parameter to ContextualQueryAugmenter
This enhancement adds a documentFormatter parameter to ContextualQueryAugmenter,
allowing users to customize how documents are formatted in the context.
If not specified, the original document formatting logic is preserved.

Signed-off-by: magicgone <magic4gone@gmail.com>
2025-03-05 08:57:19 +00:00
jonghoonpark
747524b815 update anthropic model version in example code
Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-03-05 08:53:19 +00:00
shahbazaamir
2394ac82ad Added test cases to cover usage of ExtractedTextFormatter
Signed-off-by: shahbazaamir <shahbaz07dbit@gmail.com>
2025-03-03 13:30:50 +00:00
pavel
608b29cf93 small code improvements/clean-ups, deleted unused method 'withEmbedding' from SimpleVectorStoreContent class
Signed-off-by: pavel <ppetrashov.dev@gmail.com>
2025-03-03 11:12:14 +00:00
jonghoon park
29fde4f7f1 Make allow negative keep alive value with OllamaEmbeddingModel
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-03-03 10:33:32 +00:00
Alexandros Pappas
092bbae5a1 feat: Add equals, hashCode, deep copy, and tests to AnthropicChatOptions
This commit enhances `AnthropicChatOptions` 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 `AnthropicChatOptionsTests` to verify `copy()`, builders, setters, and default values.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-03-02 12:43:09 +01:00
Christian Tzolov
53bb6a5b00 feat(mcp): add support for custom MIME types in tool responses
Add capability to specify MIME types for MCP tool responses, with special handling for image content.

This enhancement allows tools to return different content types, particularly images, by:
- Adding a new toolResponseMimeType map property to configure response MIME types per tool
- Extending tool registration methods to accept and use MIME type information
- Adding special handling for image content in tool responses
- Updating documentation with the new configuration options

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-03-01 19:55:26 +01:00