Commit Graph

1532 Commits

Author SHA1 Message Date
Christian Tzolov
cdffc72c14 feat(openai) - Support for audio output in OpenAI chat model
- Introduced new options for audio output modalities in ChatCompletionRequest
- Added AudioParameters configuration for voice and audio format selection
- Enhanced OpenAiChatModel to handle audio generation and embedding
- Updated AssistantMessage and Media classes to support audio media
- Added integration tests for audio output functionality
- Implemented support for text and audio multi-modal responses
- Updated Spring AI's chat model comparison table to clarify OpenAI's input/output modalities
- Added new configuration properties for audio output:
  * spring.ai.openai.chat.options.output-modalities
  * spring.ai.openai.chat.options.output-audio
- Extended documentation to explain audio output generation with the gpt-4o-audio-preview model
- Updated Spring Boot configuration metadata to support new audio-related properties
- Included auto-configuration integration test for chat model with audio response generation

Resolves #1841
2024-11-28 20:27:02 +00:00
Christian Tzolov
6a195ee9fe refactor(core): extract common function callback builder functionality
Extracts shared function callback builder functionality into DefaultCommonCallbackInvokingSpec
base class, reducing code duplication across builder implementations.
Makes FunctionInvokingSpec and MethodInvokingSpec extend CommonCallbackInvokingSpec for better
code organization. Also fixes function/description builder order in Anthropic tests.

- Introduced a common base class for function callback builders to centralize shared logic
- Standardized the order of method chaining for function and description in multiple AI model test classes
- Refactored test cases across various AI model integrations
- Corrected builder method order from .description().function() to .function().description()
  and .description().method() to .method().description()
- Updated multiple test files to consistently use .function() before .description()
- Updated documentation examples to reflect new builder method order
- Modified DefaultFunctionCallbackResolver to maintain new builder method order
- Updated DefaultChatClient and ChatClient test classes to reflect new builder pattern
- Simplified callback specification by removing parent spec reference
- Removed cascading getter logic for description, schema type, and other properties
- Minor adjustments to function callback builder and invoking specs
2024-11-28 19:28:08 +00:00
Alexandros Pappas
dcc8d5b620 feat: Add Perplexity AI integration and documentation updates
- Introduced `PerplexityWithOpenAiChatModelIT` integration test for Perplexity AI with OpenAI Chat Model.
  - Includes various test cases for role-based prompts, streaming responses, token usage validation, and output converters.
  - Added tests for function calls and metadata validation.
- Updated Antora navigation (`nav.adoc`) to include Perplexity AI documentation link.
- Enhanced chat model comparison documentation to highlight Perplexity AI integration.
- Added a dedicated `perplexity-chat.adoc` page under `spring-ai-docs` to provide detailed documentation for integrating Perplexity AI.
  - Covers API prerequisites, auto-configuration, and runtime options.
  - Explains configuration properties such as `spring.ai.openai.base-url`, `spring.ai.openai.chat.model`, and `spring.ai.openai.chat.options.*`.
  - Provides examples for environment variable setup and runtime overrides.
  - Highlights limitations like lack of multimodal support and explicit function calling.
  - Includes a sample Spring Boot controller demonstrating integration usage.
  - Links to Perplexity documentation for further reference.
2024-11-28 19:11:27 +01:00
diego
0b00e6f446 feat(vector-store) Add MariaDB Vector Store support to Spring AI
- Updated `org.springframework.boot.autoconfigure.AutoConfiguration.imports` to include MariaDB vector store auto-configuration
- Created MariaDB Vector Store autoconfiguration integration tests (`MariaDbStoreAutoConfigurationIT`)
- Added MariaDB store properties configuration and tests (`MariaDbStorePropertiesTests`)
- Introduced new Maven modules:
  - `spring-ai-mariadb-store`: Core MariaDB vector store implementation
  - `spring-ai-starter-mariadb-store`: Spring Boot starter for MariaDB vector store
- Added `MariaDBFilterExpressionConverter` to support JSON-based metadata filtering in MariaDB
- Implemented filter expression conversion for MariaDB vector store queries
- Added README.md with documentation link for MariaDB Vector Store
- Updated project dependencies to include MariaDB JDBC driver and test containers
- Configured integration testing with TestContainers for MariaDB
- Added observability support for MariaDB vector store operations
2024-11-28 17:25:32 +01:00
Thomas Vitale
d0a0c878f8 Portable ChatOptions ignored by OpenAiChatModel
When calling the OpenAiChatModel with ChatOptions, they are always ignored. Options are considered only when using OpenAiChatOptions or FunctionCallingOptions.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-11-28 16:44:08 +01:00
Christian Tzolov
20ccbca79b update(elastic-vector-store) Update docker image to 8.16.1 2024-11-27 21:49:46 +01:00
Ilayaperumal Gopinathan
9ebc6d2c3c Code cleanup
- Fix javadoc for Qdrant vector store
 - Fix checkstyle errors
2024-11-27 20:35:39 +00:00
dafriz
23a3d13b39 feat(vector-store) Allow underscore characters in IDENTIFIERS as they are allowed in SQL column names
- code changes auto generated by antlr4
- add test case to show that NoViableAltException is no longer thrown
2024-11-27 15:20:07 +01:00
Thomas Vitale
33f431e4a7 feat(openai) - Support audio input and output modality
- Added support for audio input and output in OpenAI Chat Completion API
- Introduced new audio-related parameters, enums, and record types
- Updated ChatCompletionMessage, ChatCompletionChunk, and related classes
- Added new AudioParameters, AudioOutput, and InputAudio record types
- Implemented method to handle audio media content conversion
- Included new model enum for GPT-4o audio preview
- Extended existing API classes to accommodate audio modalities
- Modified usage tracking and metadata classes to handle audio-specific token details
- Improved ModelOptionsUtils with additional JSON utility methods

Tests:
- Updated test classes to validate audio input and output functionality
- Added integration tests for multimodal audio input with streaming and non-streaming methods
- Created parameterized tests for audio-enabled models
- Enhanced OpenAI API integration tests to cover audio-related scenarios

Docs:
- Updated documentation in spring-ai-docs to explain audio multimodality support

Resolves #1560
2024-11-27 12:46:43 +01:00
Ilayaperumal Gopinathan
be0f9fbb67 Fix AnthropicAutoConfiguration
- Fix AnthropicChatModel's dependent bean type to `FunctionCallbackResolver` instead of its implementation concrete class `DefaultFunctionCallbackResolver`
2024-11-26 11:47:17 +00:00
Christian Tzolov
479a095976 refactor: introduce FunctionCallbackResolver interface
- Introduces a new FunctionCallbackResolver interface to define the strategy for
  resolving FunctionCallback instances.
- Renames FunctionCallbackContext to DefaultFunctionCallbackResolver to better reflect its
  implementation role. Updates all related components to use the new interface.
- Update the affected AI model implementations
  - Replaces FunctionCallbackContext parameter with FunctionCallbackResolver in all
    model constructors
  - Updates builder patterns to use functionCallbackResolver() method instead of
    withFunctionCallbackContext()
  - Deprecates old withFunctionCallbackContext() methods in builders to guide
    migration
- Updates integration tests to use DefaultFunctionCallbackResolver
- Improves documentation to clarify the resolver's role in function callbacks
- Moves SchemaType enum from FunctionCallbackContext to FunctionCallback

Resolves #758
2024-11-26 11:34:05 +00:00
GR
308d8d4cc2 fix: incorrect json property annotation for ZhiPuAI 2024-11-26 11:18:45 +00:00
Jemin Huh
7b3f424ae1 Fix correct external link formatting for Ollama documentation
Signed-off-by: Jemin Huh <hjm1980@gmail.com>
2024-11-26 12:07:45 +01:00
Ilayaperumal Gopinathan
a782486b06 chores: Fix checkstyle errors 2024-11-26 10:47:10 +00:00
shown
e7f37a06b8 Remove extraneous file run-integration-tests.sh~ and update .gitignore 2024-11-26 00:34:39 -05:00
Christian Tzolov
f388f5349a Enhance ChatGenerationMetadata with metadata Map and Builder
- ChatGenerationMetadata provides Map for additional metadata
- Add Builder interface and DefaultChatGenerationMetadataBuilder
- Add DefaultChatGenerationMetadata implementation
- Update all AI model implementations to use the new builder pattern
- Deprecate ChatGenerationMetadata.from() factory method
- Remove commented out legacy code from ChatGenerationMetadata interface
- Make metadata and content filter collections immutable via Collections.unmodifiableSet()
- Add null validation in DefaultChatGenerationMetadata constructor
- Improve toString() method with more informative output
2024-11-26 00:25:18 -05:00
Christian Tzolov
e543cd082d Update AnthropicChatModel and Spring AI Documentation for Multimodal Support
- Enhance AnthropicChatModel to support PDF and document content types
- Introduce getContentBlockTypeByMedia method for flexible media type handling
- Update ContentBlock handling to dynamically determine content type for media
- Add multimodal PDF support test case for Claude 3.5 Sonnet
- Update documentation to reflect PDF and multimodal capabilities
- Modify comparison chart to show PDF support for Anthropic Claude

Fixese #1819

review
2024-11-25 23:54:57 -05:00
Ilayaperumal Gopinathan
9d207e37be Refactor SimpleVectorStore
- Remove SimpleVectorStore's dependency on deprecated embeddings from Document object
- Create a custom Content object that represents the SimpleVectorStore's contents and embedding
- Add tests
2024-11-25 23:35:34 -05:00
Mark Pollack
d1735725ad Enable easier debugging of Azure Image and Audio Transcription tests 2024-11-25 16:33:58 -05:00
Christian Tzolov
d030b82b59 Update mavne build with a profile for fast integration tests
- Add new Maven profile 'ci-fast-integration-tests' for running selective ITs
- Remove redundant vector store skip flags from properties section
- Update maven-failsafe-plugin to version 3.5.2
- Configure test exclusions for various components:
  - Most model integration tests (Anthropic and OpenAI)
  - Most vector store tests (except PgVector and Chroma)
  - Most auto-configuration tests
  - All test containers and docker compose tests
  - AI evaluation tests
- Convert the docker-compose tests into ITs
- Convert the testcontainers tests into ITs
- Updated README.md
  - Explain the new profile and also the new integration tests repo
  - Describe ways to run integration tests for specific modules
  - Add badge for https://github.com/spring-projects/spring-ai-integration-tests
2024-11-25 16:07:32 -05:00
Christian Tzolov
979de19162 docs(vertex-ai-gemini): Add Gemini PDF support docs and add IT
- Add test case for PDF document summarization using Gemini multimodal capabilities
- Update documentation to reflect PDF support in model comparison table
- Add PDF format to multimodal capabilities documentation
2024-11-25 14:09:54 +01:00
Christian Tzolov
87ff101946 docs: move Bedrock Converse to chat folder & add to comparison table
- Move bedrock-converse.adoc from api/ to api/chat/ directory
- Add Bedrock Converse to chat models comparison table
- Fix table entry formatting for OCI GenAI/Cohere width values

The move aligns with the documentation structure where chat-related content
is organized under the api/chat/ directory.
2024-11-25 12:41:17 +01:00
Christian Tzolov
64c4567eb1 docs: reorganize and enhance FunctionCallback documentation
* Remove redundant section headers
* Improve builder pattern documentation with hierarchical structure overview
* Add cross-references between related sections
* Restructure function and method invoking sections for better organization
* Adjust heading levels for better document hierarchy
* Move schema generation and common pitfalls under appropriate sections
2024-11-24 18:10:16 +01:00
Christian Tzolov
b3bb541cc9 docs: improve documentation for function callback and tool context
- Add cross-references to tool context documentation section
- Enhance BiFunction section title and description
- Improve readability and consistency of function callback documentation
2024-11-24 17:26:36 +01:00
Christian Tzolov
eaa61cd231 docs: Imporove Function Calling docs 2024-11-24 16:38:43 +01:00
Christian Tzolov
c1f2ec65d3 doc: Fix the Ollama hugging face support documentation 2024-11-24 15:00:20 +01:00
Christian Tzolov
c057148813 chore: Update dependencies and fix OpenAPI client generation
- Upgrade Spring Boot to 3.3.6
- Update swagger-codegen-maven-plugin to 3.0.64
- Add custom template for HttpBasicAuth
- Fix mockwebserver version to 4.12.0
- Fix parent version reference in opensearch-store
2024-11-22 14:22:37 +01:00
jitokim
7feb13b63d fix typos in VertexAiGeminiChatModel class
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-22 12:08:40 +00:00
Virle
357efd0b0b Update function-callback.adoc (#1797)
turn onn => turn on
2024-11-22 11:53:45 +00:00
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