-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Add tool_calls support to JdbcChatMemoryRepository #3343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add tool_calls support to JdbcChatMemoryRepository #3343
Conversation
cbf3844
to
f11ac75
Compare
- Add tool_calls column to all database schemas (PostgreSQL, MySQL, SQL Server, HSQLDB) - Implement JSON serialization/deserialization for AssistantMessage.ToolCall objects - Update all dialect classes to include tool_calls in SELECT and INSERT queries - Add PostgreSQL JSONB type support with explicit casting (::jsonb) - Add comprehensive unit tests for tool calls functionality - Add integration tests for tool calls across all supported databases - Maintain backward compatibility with existing chat memory data This enhancement allows the JDBC chat memory repository to persist and retrieve tool call information from AI assistant messages, enabling full conversation context preservation including function calls and their metadata. Signed-off-by: astor-dev <orangnlp@gmail.com>
f11ac75
to
18eda40
Compare
Thanks for this, I need to spend more time reviewing this, but in the 1.0.x branch we won't be able to merge any schema breaking changed, we can for 1.1.x No firm timeline on the 1.1.x release date yet, just starting to review what we can do and publish a public roadmap. |
case ASSISTANT -> new AssistantMessage(content); | ||
case ASSISTANT -> { | ||
List<AssistantMessage.ToolCall> toolCalls = List.of(); | ||
if (toolCallsJson != null && !toolCallsJson.trim().isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim()
is not aware of unicode whitespace characters and so strip()
is the preferred way to remove whitespace characters since Java 11.
For this specific case, you can use isBlank()
which is available since Java 11 and also unicode aware.
Suggested modification:
- !toolCallsJson.trim().isEmpty()
+ !toolCallsJson.isBlank()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, updated to isBlank() as suggested. Thanks!
…icode whitespace in JdbcChatMemoryRepository Signed-off-by: astor-dev <orangnlp@gmail.com>
d4aee39
to
54da813
Compare
Description
This PR implements support for persisting
tool_calls
inJdbcChatMemoryRepository
to resolve issues with tool calling functionality in JDBC-based chat memory implementations.Issues Addressed
Fixes #3342 - Support persisting tool_calls in JdbcChatMemoryRepository
It can also serve as a preliminary step to fix the issues below:
#3339 - ToolResponseMessage results in null content, causing SQLIntegrityConstraintViolationException
Changes
Database Schema
tool_calls
column to all database schemas (PostgreSQL, MySQL, SQL Server, HSQLDB)JSONB
type with explicit::jsonb
castingTEXT
/LONGVARCHAR
for JSON storageImplementation
List<AssistantMessage.ToolCall>
to JSON on inserttool_calls
in SELECT and INSERT queriesDatabase Dialects Updated
PostgresChatMemoryRepositoryDialect
MysqlChatMemoryRepositoryDialect
SqlServerChatMemoryRepositoryDialect
HsqldbChatMemoryRepositoryDialect