Commit Graph

212 Commits

Author SHA1 Message Date
Mark Pollack
e723c644ae Improve Message object hierarchy
- SystemMessage no longer has Media
- Add MediaContent interface
2024-07-19 12:59:07 -04:00
Veerendra Vellanki
60308eab77 register available modules with the object mapper
add tests
2024-07-19 13:05:20 +02:00
Christian Tzolov
edf943ec97 Adjust tests 2024-07-18 19:39:43 +02:00
Christian Tzolov
018bb2c600 Ensure that ChatClient copies the input chatoptions
- introduce copy() method to the ChatOptions.
 - make sure that the DefaultChatClientRequestSpec takes a copy of the input chat options to prevent multation.
 - add a OpenAiChatClientMultipleFunctionCallsIT to reproduce the problem and verify the solution.

 Resolves #1064
2024-07-18 18:56:28 +02:00
Thomas Vitale
40d8671f3e Improve new function calling strategy
- Streamline the Generation constructors

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-18 14:18:45 +02:00
Mark Pollack
97f443d615 Update to ResponseMetadata design
* Remove inheritance from HashMap
* No more subclasses per model provider
* Builder class for ChatResponse
* Fix the AbstractResponseMetadata#AI_METADATA_STRING parameter order
* ChatResponseMetadata ignore Null values.
2024-07-18 12:48:28 +02:00
mck
4aacab020b Implement CassandraChatMemory
- provides a flexible schema, can be combined with a vector store, and supports time-to-live rows.
 - fix initialize-schema docs and so that it actually works.
 - move CommonVectorStoreProperties to .vectorstore. package
 - add CassandraAutoConfiguration to the AutoConfiguration.imports
2024-07-17 11:42:09 +02:00
Eddú Meléndez
0a42bf01f3 Fix assertions 2024-07-17 11:01:37 +02:00
Johnny Lim
7c26c7bcdf Polish 2024-07-16 10:05:28 +02:00
v891
ed815d8b3d Registering JavaTimeModule to ObjectMapper 2024-07-15 19:37:06 +02:00
Chris Turchin
f07e3911dc Fix system messages handling issue
- re-assign the model on withSystemInstruction return.
 - deprecate the gemini-pro-vision model and replace the default model to gemin-pro-1.5
 - update docs.
 - improve system message handling implementation.

 Resolves #1030

Co-authored-by: Christian Tzolov <ctzolov@vmware.com>
2024-07-15 19:26:12 +02:00
Christian Tzolov
ee19ee1db9 Add high-level function calling support for Anthropic
- simplify and unify the AbstractToolCallSupport::executeFuncitons. Fix filed typos
 - remove old classes
2024-07-15 13:57:38 +02:00
Christian Tzolov
086117effa High-level API function calling support for VertexAI Gemini
- Refactor VertexAiChatModel's function calling handling to use Spring AI abstractions.
2024-07-15 12:24:42 +02:00
Thomas Vitale
e601f14364 Add model name and token usage to EmbeddingResponseMetadata
- Moves these from free-text key/value pairs to interface
- Enables programmatic use for evaluation and observability

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-12 11:18:49 -04:00
Christian Tzolov
41eab270cb Refactor High-level API function calling support
- Add ToolCall to AssistantMessage.
 - Rename FunctionMessage to ToolResponseMessage and add id and name fields.
 - Refactor OpenAiChatModel's function calling handling.
 - Prompt copy now copies the AssistantMessage and ToolResponseMessage contents.

Other ChatModel implementations to adopt these changes in subsequent commits
2024-07-12 00:02:05 -04:00
Christian Tzolov
c70c20b79d Add VertexAI Embedding Model support
- add new spring-ai-vertex-ai-embedding project.
 - add VertexAiTextEmbeddingModel and VertexAiMultimodalEmbeddingMode with related options configuration classes.
 - add ITs
 - add auto-configuraiton and boot starters.
 - register to BOM.
 - add documentation.
 - add multimodal embedding documentation
 - extend the Embedding metdata so that it can keep references to the source document's data, Id, mediatype

 Resolves #1013
 Related to #1009
2024-07-10 15:36:13 -04:00
devholic22
4ff2f1fc06 Add comment in MessageType for readability
- Add comment in MessageType for readability
2024-07-03 15:04:42 +02:00
Mark Pollack
cb6662a61e Various code cleanup
Co-authored-by: Alex Klymenko <alxkm@users.noreply.github.com>
2024-07-02 15:35:01 -04:00
jiwoo
3bec210b80 Add additional tests for Document metadata and TextSplitter 2024-07-02 11:37:10 -04:00
Nicholas Zhan
5417d19d9a Fix prompt template validation if a variable name contains hyphen 2024-07-02 11:13:54 -04:00
Craig Walls
b5cc9db88a Accept response as a String instead of ChatResponse in EvaluationRequest
- Update docs
2024-07-01 12:05:01 -04:00
Lorenzo Caenazzo
0f07b7bb8a :fix: constructor error messages 2024-06-28 12:30:10 +02:00
Thomas Vitale
3227311314 Introduce id and model in ChatResponseMetadata
* Extend ChatResponseMetadata for Anthropic (blocking, streaming)
* Add ChatResponseMetadata for Mistral AI (blocking)
* Extend ChatResponseMetadata for OpenAI (blocking)
* Deprecate gpt-4-vision-preview and replace its usage in tests because OpenAI rejects the calls (see: https://platform.openai.com/docs/deprecations)

Fixes gh-936

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-06-24 14:10:19 +02:00
Mark Pollack
84737ecc01 update some javadoc warnings 2024-06-21 16:29:15 -04:00
Christian Tzolov
dfa3ceb1ab GH-912: Add customizable logger advisor (#913)
* Add customizable logger advisor
* Address review comments
* Use the OutputCaptureExtension to verify the output text

 Resolves #912
2024-06-21 10:26:18 -04:00
Craig Walls
58a30f7223 Fix formatting 2024-06-20 19:54:32 +02:00
Craig Walls
5cf41f5215 Fix FILTER_EXPRESSION typo 2024-06-20 19:54:32 +02:00
luocq3
75d68662ae Change the Prompt's modelOptions() to return ChatOptions instead of ModelOptions. 2024-06-20 15:03:15 +02:00
Christian Tzolov
3cbda5acd8 Enable dynamic filter expressions for QuestionAnswerAdvisor
- Add FILTER_EXPRESSION advisor context parameter to update filter expressions per call/stream
 - Implement dynamic filter expression handling in QuestionAnswerAdvisor
 - Add unit tests for dynamic filter expression functionality
 - Update documentation with usage examples

 Resolves #887
2024-06-18 14:32:38 +02:00
Piotr Olaszewski
06ff651734 Remove duplicated ApiUtils and polish javadocs 2024-06-17 15:39:32 +02:00
Christian Tzolov
476164b6e3 Move the vector expression converters from core to their projects 2024-06-15 20:24:29 +02:00
Christian Tzolov
64378dfcdd Fix the ChatClient call().content() output 2024-06-05 15:25:41 +02:00
Christian Tzolov
9bb2618436 Fix javadoc issues 2024-06-04 14:54:55 +02:00
Christian Tzolov
d6a0dffd3e Add ChatClient support for returning ResponseEntity<ChatResponse, T>
ChatClient already provides the .chatResponse() method to return the entire ChatResponse instance.
 It also provides a set of overloaded .entity(Type) methods to provide Type-converted responses.
 The new .responseEntity(Type) method returns a ResponseEntity<ChatResponse, T> instance, encapsulating
 both the ChatResponse and the requested Type-converted response entity.

 This change allows for more flexibility when handling different response types and facilitates
 easier integration with other components that expect ResponseEntity instances.
2024-06-04 14:36:21 +02:00
Christian Tzolov
6ad36b7653 ChatClient/DefaultChatClient refactoring
Now the ChatClient contains only the Spec interfaces while
   all implementations are moved to the DefaultChatClient
   and the DefaultChatModelBuilder classes.
2024-06-04 14:07:19 +02:00
yinpeng
20c6a1adcf fix: typo 2024-06-03 15:00:19 +02:00
Christian Tzolov
f4c46770ee Widen the PromptSpec param value type from String to Object 2024-06-03 11:39:31 +02:00
Craig Walls
76e7e0bd93 Overload QuestionAnswerAdvisor to use SearchRequest.defaults() 2024-05-30 13:12:42 +02:00
Philipp Gerhard
9286dfb4bd Extend format to improve generate JSON
- Add an additional instruction to the format for the model not to include markdown syntax for JSON quotes.
- Extend the conversion to strip markdown quotes in case the model included them in the response
2024-05-29 15:10:36 +02:00
Mark Pollack
2b2cacce8c Add documentation for ChatClient and Evaluation 2024-05-27 23:04:12 -04:00
Mark Pollack
574138a26a Remove chat.service package and related classes
* This functionality is now provided using the advisors feature in ChatClient
2024-05-27 15:36:30 -04:00
Christian Tzolov
a64dd06c48 Add payment transaction status Function Calling ITs - OpenAI and Vertex AI Gemeini 2024-05-27 18:11:44 +02:00
Christian Tzolov
5226d0b9b3 Enable ZhiPu AI ITs only on ZHIPU_AI_API_KEY env present 2024-05-27 08:40:45 +02:00
Christian Tzolov
22a511a6d7 Fix the ChatClient.Builder.defaultAdvisors() to take var args 2024-05-27 07:59:17 +02:00
Christian Tzolov
42095f011a Remove dots from the prompt template placeholder names
The ST library doesn't permit dots in the placeholder names.
2024-05-27 07:44:56 +02:00
Christian Tzolov
c4784a070f Add ChatClient plugable advisors support
- Add RequestResponseAdvisor interface with adviseReqeust and adviseResponse methods.
    The adviseRequest method takes and returns AdvisedRequest.
    The adviseResponse method takes and returns ChatRequest.
  - Add ChatClient#ChatClientRequets advisor(...) methods to register advisros.
    ChatClient call the registered advisors in order before sealing the ChatClientRequest into a Prompt and call the model
    and after the model response.
  - Implement PromptChatMemoryAdvisor that uses the ChatMemory and the systemem prompt.
  - Implement MessageChatMemoryAdvisor that usees the ChatMemory and the prompt messages.
  - Implement VectorStoreChatMemoryAdvisor that uses VecrStore for long term message history.
  - Add tests.
  - Add shared context to the RequestResponseAdvisor's flow, Context is shared between the request and the  response
  - Add advisor parameters that are passed through the context
2024-05-26 23:23:52 -04:00
Mark Pollack
ac518df4db Rename method 'created' to 'getCreated' in OpenAiImageResponseMetadata
In the ImageResponseMetadata interfaces and its implementations, the method 'created' has been renamed to 'getCreated' to support JSON ser/deser

Fixes #625
2024-05-24 10:50:14 -04:00
Christian Tzolov
8257c0dc43 Improve ChatClient impl. parameter cohesion 2024-05-24 15:00:03 +02:00
Christian Tzolov
cd3b374dab Extend ChatClient API
- add support for custom StructuredOutputConverters usng entity(outputConverterInstance)
  - add mutate() method that returns ChatClient.Builder to create a new ChatClient whose
    settings are replicated from the ChatClient's default settings.
  - add prompt().mutate() method that returns ChatClient.Builder to create a new ChatClient
    whose settings are replicated from the current default and prompt settings.
2024-05-24 14:33:26 +02:00
Mark Pollack
4a2ad60059 Package refactoring
* Move ChatClient and related classes into the chat.client package
* Move ChatModel and related class into the chat.model package
* Smaller refactorings to remove DSM cycles
* Update README.md
2024-05-23 17:52:27 -04:00