Commit Graph

1453 Commits

Author SHA1 Message Date
Christian Tzolov
e5410d7e8d undo last commit 2024-11-21 09:13:45 +01:00
Christian Tzolov
68f8113098 Prevent skipping integration tests by default 2024-11-21 08:01:05 +01:00
Mark Pollack
67a8896422 Next development version 2024-11-20 18:03:30 -05:00
Mark Pollack
33c05c399c Release version 1.0.0-M4 2024-11-20 18:02:47 -05:00
Thomas Vitale
175dc9b721 Improve translation test
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-11-20 12:45:38 -05:00
Christian Tzolov
5dbfbf98aa feat: Add Pixtral and new Llama 3.2 Vision models to MistralAi and Ollama integrations
- Add Pixtral models (PIXTRAL and PIXTRAL_LARGE) to MistralAiApi.ChatModel
- Update MistralAiChatClientIT to use Pixtral model for testing
- Add new Ollama models:
  * QWEN_2_5_7B
  * LLAMA3_2_VISION_11b
  * LLAMA3_2_VISION_90b
2024-11-20 17:59:45 +01:00
Thomas Vitale
d759fb294b Modular RAG: Orchestration and Post-Retrieval
Pre-Retrieval:
* Consolidated naming and documentation

Retrieval:
* Consolidated naming and documentation
* Introduced DocumentJoiner sub-module and CompositionDocumentJoiner operator

Post-Retrieval:
* Introduced main interfaces for sub-modules. Implementation waiting for missing features in Document APIs

Orchestration:
* Introduced QueryRouter sub-module and AllDocumentRetrieversQueryRouter operator

Generation:
* Consolidated naming and documentation

Advisor:
* Introduced BaseAdvisor to reduce boilerplate when implementing Advisors
* Extended RetrievalAugmentationAdvisor to include the new sub-modules

Relates to #gh-1603
2024-11-20 11:43:30 -05:00
Mark Pollack
c783c6b2db Add deprecation in Document of embeddings and content formatter 2024-11-20 10:21:46 -05:00
Christian Tzolov
52999b44b5 Align with the latest Chroma API
- Added Jackson annotations for JSON property handling in Chroma API request/response records.
  Use @JsonInclude(JsonInclude.Include.NON_NULL) to ignore empty fields such as null where.
  Use @JsonProperty(XYZ) to provide a strong contract with the Cohere API.
- Updated the Docker image for running Chroma locally and in tests to version 0.5.20.
- Enhanced  methods with non-null assertions for improved code safety.
- Added a simple search test to verify document similarity search functionality.

Fixes #1749
2024-11-20 10:11:41 -05:00
Soby Chacko
1abfd9ab96 Add truncation support for Cohere embeddings
Fixes: #1753

https://github.com/spring-projects/spring-ai/issues/1753

- Add character-based truncation (max 2048 chars) for Cohere embedding requests
- Support both START and END truncation strategies
- Add unit tests verifying truncation behavior for both strategies

Truncation is applied before sending requests to Bedrock API to avoid
ValidationException when text exceeds maximum length. The END strategy
(default) keeps the first 2048 characters while START keeps the last
2048 characters.
2024-11-20 10:06:38 -05:00
Christian Tzolov
551206feb0 fix(bedrock-converse): Update tool use handling and add usage aggregation tests (#1777)
- Replace hardcoded "tool_use" with StopReason enum value
- Add tests for token usage aggregation with tool calls
- Add handling for null response metadata
2024-11-20 12:37:30 +00:00
Christian Tzolov
00ede3f564 Fix Bedrock Converse streaming/call and token handling
- Modify stream method to support recursive tool call handling
     - Update token tracking and metadata merging for streamed responses
     - Improve token usage calculation for tool use events
     - Update test cases to handle new response processing

    - Modify call method to support recursive tool call handling
     - Add support for cumulative token tracking across tool call iterations
     - Introduce internal call method to track and aggregate token usage
     - Merge previous chat response tokens with current response tokens

Resolves #1743
2024-11-20 10:59:40 +00:00
Christian Tzolov
13d207415f feat(spring-ai): add operation type and provider metrics to advisor observations
Add AI_OPERATION_TYPE and AI_PROVIDER as low cardinality key names to advisor observations.
The advisor AI_OPERATION_TYPE is set to 'framework' and the AI_PROVIDER to 'spring_ai'.

Resolves #1660
2024-11-20 09:59:20 +00:00
Christian Tzolov
379f21235a Update chroma.adoc 2024-11-20 01:13:02 +01:00
Ilayaperumal Gopinathan
3b95dfd87f Fix checkstyle errors 2024-11-19 23:29:36 +00:00
Ilayaperumal Gopinathan
3812d2e6d8 Remove explicit ChatOptions for the models using FunctionCallingOptions
- Since FunctionCallingOptions already extends ChatOptions,
   removing explicit usage of ChatOptions in the Model Options classes
2024-11-19 18:02:54 -05:00
Christian Tzolov
0eacc9193b feat(tools): Add tool call history to ToolContext
- Add TOOL_CALL_HISTORY constant to store tool call history
- Extend ToolContext with getToolConversationHistory method
- Include tool call history in tool context during function execution
- Add test coverage for tool call history verification

Resolves #1202
2024-11-19 22:50:38 +00:00
Soby Chacko
edc70031dc Remove Boot dependency from core anthropic and watson modules
Fixes: #1591
2024-11-19 17:05:41 -05:00
Mark Pollack
66886346fa Group together deps that are also managed by boot in pom.xml See issue #1212 2024-11-19 17:05:09 -05:00
Mark Pollack
a4462420d8 Add support for optional keyless authentication.
Implemented a new configuration property 'useKeylessAuth' to toggle
between API key and Azure default credential authentication.

Added necessary dependencies and updated tests to reflect the new changes.

co-authored-by: mattgotteiner <mattgotteiner@users.noreply.github.com>
2024-11-19 16:15:07 -05:00
Gareth Evans
a7b5652790 Upgrade azure-openai library to beta.12
- Correct merge utils after lib update
2024-11-19 15:11:23 -05:00
Ilayaperumal Gopinathan
de53e64bfd Fix OpenSearch vector store configuration and update mapping defaults
- Fix the embedding dimension configuration for opensearch client indices mapping
  The dimension config is obtained by the underlying embedding model's dimension
- Updated OpenSearch mapping JSON to include dynamic embedding dimension.
- Changed default mapping for OpenSearch vector store to use generic dimension placeholder.
- Fixed OpenSearchVectorStoreAutoConfiguration to fallback to new default mapping if no custom mapping is provided.
- Added test for verifying mapping configuration with OpenSearch vector store.
- Added test dependencies for Ollama integration.
- Refactored OpenSearch integration tests to use new mapping and dimension logic.

Add tests

- Verify the mappingJson field is correctly set - verify the override works fine
- Add integration tests with Ollama embedding model

Resolves #1589
2024-11-19 20:55:36 +01:00
Mark Pollack
aff18bfca9 Fixes for Azure OpenAI ITs 2024-11-19 14:43:22 -05:00
heqiang
d2e9e55d25 Fix TokenCountBatchingStrategy example. (#1702) 2024-11-19 13:10:21 -05:00
Christian Tzolov
c529c839ee Update chroma.adoc 2024-11-19 17:16:06 +01:00
jitokim
1298a28216 add OllamaChatModelTests
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-19 16:13:47 +00:00
jitokim
08b0c30c9e Fix duplicate keys in ChatResponseMetadata for OllamaApi.ChatResponse metadata
Fix assertion in contructor of OllamaChatModel

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-19 16:13:47 +00:00
Eddú Meléndez
6261ce02ff Add LocalStack OpenSearch Service Connection support for Docker Compose and Testcontainers
* Add property `spring.ai.vectorstore.opensearch.aws.domain-name`
* Require `AwsCredentialsProvider` to enable `AwsOpenSearchConfiguration`
* Add Testcontainers Service Connection support
* Add Docker Compose Service Connection support
2024-11-19 11:58:37 +00:00
Ilayaperumal Gopinathan
c8dc342b30 Add test for prompt copy 2024-11-19 11:33:03 +00:00
wanglei
79ce1c1193 fix: prompt deep copy 2024-11-19 11:12:46 +00:00
Soby Chacko
3b430a5bee Fix Kotlin test deprecation warning 2024-11-19 11:07:41 +00:00
jitokim
d8583271c7 fix callback merging in AzureOpenAiChatModel constructor
and minor fixes

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-19 09:12:51 +01:00
Soby Chacko
f5b00a027c Various checkstyle fixes 2024-11-18 19:17:09 -05:00
Christian Tzolov
c038526dd1 refactor(openai): consolidate token usage details and add audio tokens support
The commit restructures OpenAI token usage tracking by:
- Adding audio_tokens support in PromptTokensDetails
- Deprecating individual token getter methods in favor of consolidated records
- Introducing new PromptTokensDetails and CompletionTokenDetails records
- Updating tests to reflect the new structure

Resolves #1369 , #1720
2024-11-18 23:12:30 +01:00
jitokim
fb2e7528d0 Fix Anthropic issue using unsubscribed response body in exception message
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-18 16:44:21 -05:00
jitokim
a7a1804fac Rename Cassandra TTL Property for Clarity
Rename `timeToLiveSeconds` to `timeToLive` in
`CassandraChatMemoryProperties` and associated code to prevent
misleading interpretation. This change addresses issue #1728, as
the property previously suggested values in seconds but expected
milliseconds.

Improve readability and ensure accurate configuration by aligning
the name with its behavior. Include updates to test cases to
validate the new property name and verify ISO 8601 format handling.

Fixes #1728

Signed-off-by: Jihoon Kim <pigberger70@gmail.com>
2024-11-18 16:24:08 -05:00
Christian Tzolov
432954dad7 Add Supplier and Consumer function callback support in function calling
Add support for no-argument Supplier and single-argument Consumer function
callbacks in the Spring AI core module. This enhancement allows:
- Registration of Supplier<O> callbacks with no input (Void) type
- Registration of Consumer<I> callbacks with no output (Void) type
- Support for Kotlin Function0 (equivalent to Java Supplier)
- Handle empty properties for Void input types in schema generation
- Enhance FunctionCallback builder to support Supplier/Consumer patterns

Additional changes:
- Add test coverage for both Supplier and Consumer callbacks in various scenarios
- Enhance TypeResolverHelper to support Consumer input type resolution
- Support lambda-style function declarations for improved ergonomics
- Add test cases for void input/output handling in OpenAI chat model
- Include examples of function calls without return values
- Add support for parameterless functions through Supplier interface

Add comprehensive documentation for the FunctionCallback API:
- Overview of the interface and its key methods
- Builder pattern usage with function and method invocation approaches
- Examples for different function types (Function, BiFunction, Supplier, Consumer)
- Best practices and common pitfalls
- Schema generation and customization options

Resolves #1718 , #1277 , #1118, #860
2024-11-18 15:54:21 -05:00
Emmanuel Ferdman
f9a9c02e2b Update Message.java reference
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-11-18 11:20:05 +01:00
Ilayaperumal Gopinathan
4e3955eee9 Fix typo 2024-11-18 10:14:20 +00:00
coderamittad
24096b04bf Update getting-started.adoc 2024-11-18 07:49:53 +05:30
Christian Tzolov
bc24b4c45d docs: Clarify function calling concepts and usage patterns
Improves function calling documentation with clearer organization and examples:

- Reorganizes content into server-side and client-side registration sections
- Adds detailed examples for both function-invoking and method-invoking approaches
- Enhances tool context documentation with diagrams and usage examples
- Updates function-calling diagrams to reflect current implementation
2024-11-17 17:23:21 +01:00
Christian Tzolov
018257a605 fix: Resolve javadoc and maven confiuration issues 2024-11-16 12:43:27 +01:00
Christian Tzolov
0ca91b2ed9 fix: Resolve various javadoc and checkstyle issues 2024-11-16 11:06:14 +01:00
Christian Tzolov
75e3a08d7d refactor: revise function callback API deprecation messages and documentation
- Update deprecated annotation messages to correctly reference functions() instead of function()
- Add detailed documentation for FunctionCallback.Builder hierarchy
- Deprecate FunctionCallbackWrapper class in favor of Builder pattern
- Fix typos and improve code documentation
2024-11-16 07:28:56 +01:00
Josh Long
944fb996e4 Add extension function for Chatclient.CalLResponseSpec.entity(Class<?>)
- This makes ChatClient easier to use from Kotlin
2024-11-15 17:06:52 -05:00
Christian Tzolov
fb0d99dc37 Revamp function callback builder API
Introduces a simplified, type-safe builder pattern for function callbacks to
improve developer experience and code reliability. The new hierarchical API
separates concerns between direct function invocation and method reflection,
while providing better compile-time safety.

This change deprecates the older FunctionCallbackWrapper in favor of a more
intuitive FunctionCallback.Builder that better handles generic types via
ParameterizedTypeReference. It also adds automatic function description
generation as a fallback when none is provided, though explicit descriptions
are still recommended.

The update standardizes function callback handling across all AI model
implementations (OpenAI, Ollama, Minimax, etc.) and improves response
handling with configurable converters.

Core API Enhancements:

- New Builder Interface: Replaced FunctionCallbackWrapper.builder() with
   FunctionCallback.builder(), introducing a hierarchical approach that improves
   customization and type safety.
- Specialized Builders: Introduced FunctionInvokerBuilder for direct Function/BiFunction
   implementations and MethodInvokerBuilder for reflection-based invocations.
- Generic Type Support: Added ParameterizedTypeReference for better handling of generic parameters.
- Unified Method Definition: Merged method() and argumentTypes() into a single method() call
   for simplicity and type safety.
- Automatic Descriptions: Implemented auto-generation of function descriptions, with warnings
   to encourage explicit descriptions.
- Configurable Response Converters: Enhanced response handling with support for custom
   converters, reducing unnecessary JSON conversions.

Architecture Improvements:

- Established common Builder interface for shared properties
- Separated function object handling from constructor
- Added method-specific configuration (name, arg types, target)
- Added JSON schema generation support for ResolvableType
- Moved to standardized schema types across AI providers
- Set OPEN_API_SCHEMA as default for Vertex AI Gemini

Builder Pattern Standardization:

- Standardized builder method ordering across implementations
- Moved function() call after description() for consistency
- Improved function callback configuration with unified patterns
- Enhanced error handling and validation in DefaultFunctionCallbackBuilder

Deprecations:

- FunctionCallbackWrapper.Builder replaced by DefaultFunctionCallbackBuilder
- Removed CustomizedTypeReference in favor of ParameterizedTypeReference
- Deprecated older ChatClient API methods for function handling

Testing & Documentation:

- Updated all AI model implementations (OpenAI, Ollama, Minimax, Moonshot, ZhiPuAI)
- Added comprehensive integration tests for static/instance methods
- Added integration tests for auto-generated descriptions
- Updated documentation to reflect new builder pattern usage
- Added Kotlin extension for inputType() support

Co-authored-by: Sébastien Deleuze <sebastien.deleuze@broadcom.com>
2024-11-15 15:32:59 -05:00
Ilayaperumal Gopinathan
72c84fe8b8 Remove deprecated code from 1.0 M2 and before
- Remove deprecated types,methods and references
 - Remove usage of "Generation(String text)" and replace with
  "Generation(AssistantMessage)"
 - Remove MiniMaxApi,MootShotApi,OpenAiApi,ZhiPuAiApi
   ChatCompletionFinishReason's FUNCTION_CALL
 - Remove OllamaApi's deprecated types
 - Remove deprecated constructors from PostgresMlEmbeddingModel
 - Remove deprecated constructor from Media
 - Remove tokenNames usage from antlr4 FiltersLexer and FiltersParser
 - Remove deprecated methods from CassandraVectorStoreProperties
 - Remove deprecated constructor and static config class from QdrantVectorStore
 - Minor cleanups on removing deprecated models and versions
 - Remove old name for mixtral models

Resolves #1599
2024-11-15 14:28:21 -05:00
Gareth Evans
ea1871041c docs: document how to programatically configure vertex embeddings to use a service account 2024-11-15 17:49:10 +01:00
Sébastien Deleuze
f9734a35aa Add support for @Component to TypeResolverHelper 2024-11-15 17:21:20 +01:00
Gareth Evans
01fa511339 docs: correct code in vertex chat functions doc 2024-11-15 13:22:23 +00:00