-
Notifications
You must be signed in to change notification settings - Fork 240
add additionalProperties
across clients
#836
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
Conversation
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.
Pull Request Overview
This PR adds support for additionalProperties
across all LLM clients, enabling developers to pass custom parameters that are not explicitly supported in the request models. The feature allows custom properties to be seamlessly merged into the final JSON request while preserving the ability to deserialize them back during response processing.
Key Changes
- Added
additionalProperties
field to coreLLMParams
class with helper functions for type conversion - Implemented
AdditionalPropertiesSerializer
for handling JSON serialization/deserialization - Updated all client implementations to support and pass through additional properties
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.
Show a summary per file
File | Description |
---|---|
LLMParams.kt | Added additionalProperties field and utility functions for JSON element conversion |
AdditionalPropertiesSerializer.kt | Core serializer implementing flattening/collecting logic for additional properties |
Various client request models | Added additionalProperties field to all request DTOs |
Various client implementations | Updated to use custom serializers and pass additional properties |
Test files | Comprehensive serialization tests for all clients verifying round-trip behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
...client/src/commonMain/kotlin/ai/koog/prompt/executor/clients/anthropic/AnthropicLLMClient.kt
Show resolved
Hide resolved
...-client/src/jvmTest/kotlin/ai/koog/prompt/executor/clients/google/GoogleSerializationTest.kt
Outdated
Show resolved
Hide resolved
.../jvmTest/kotlin/ai/koog/prompt/executor/clients/deepseek/models/DeepSeekSerializationTest.kt
Outdated
Show resolved
Hide resolved
Qodana for JVM846 new problems were found
@@ Code coverage @@
+ 69% total lines covered
12337 lines analyzed, 8592 lines covered
# Calculated according to the filters of your coverage tool ☁️ View the detailed Qodana report Contact Qodana teamContact us at qodana-support@jetbrains.com
|
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.
Thank you, @devcrocod
I like the design approach, but some more testing is needed: AdditionalParams got lost during the copy operation
* @param pairs A variable number of key-value pairs, where the keys are strings and the values are any type. | ||
* @return A map with the provided keys associated with their corresponding JsonElement representations as values. | ||
*/ | ||
public fun additionalPropertiesOf(vararg pairs: Pair<String, Any>): Map<String, JsonElement> = |
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.
Maybe it make sense to define the type/typealias for Map<String, JsonElement>
. I am introducing the utils module, where this type and it's serializer may live.
prompt/prompt-model/src/commonMain/kotlin/ai/koog/prompt/params/LLMParams.kt
Show resolved
Hide resolved
...nMain/kotlin/ai/koog/prompt/executor/clients/serialization/AdditionalPropertiesSerializer.kt
Outdated
Show resolved
Hide resolved
- Introduced a unit test to validate that the `copy()` function on `LLMParams` retains all property values without changes.
…latteningSerializer`
b0b8784
to
1a7ec71
Compare
…nd deserialization strategies, update dependencies, and improve Anthropic client tests with JSON assertion using Kotest.
…geRequest` - Annotated `maxTokens` and `stream` with `@EncodeDefault` for consistent serialization defaults. - Introduced `@SerialName` for the `max_tokens` and `tool_choice` properties.
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.
Thank you, @devcrocod
…zation` and inline JSON strings for improved readability and consistency.
Need more tests... |
…urrentLinkedQueue` for logs, and enable parallel test execution in JUnit; update dependencies.
[KG-313](https://youtrack.jetbrains.com/issue/KG-313) Ability to pass (really) custom LLM params ## Motivation and Context Passing properties to the LLM client that are not supported in requests --- Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
KG-313 Ability to pass (really) custom LLM params
Motivation and Context
Passing properties to the LLM client that are not supported in requests
Breaking Changes
No
Type of the changes
Checklist
develop
as the base branchAdditional steps for pull requests adding a new feature