Skip to content

Commit

Permalink
[9.0] Fix calling Sonnet 3.7 (elastic#212372) (elastic#212399)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `9.0`:
- [Fix calling Sonnet 3.7
(elastic#212372)](elastic#212372)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Patryk
Kopyciński","email":"contact@patrykkopycinski.com"},"sourceCommit":{"committedDate":"2025-02-25T15:41:55Z","message":"Fix
calling Sonnet 3.7 (elastic#212372)\n\n## Summary\n\nFixes \n<img
width=\"1509\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ba409fde-f52b-4864-a81a-70025ef61f2f\"\n/>","sha":"8c456d1e1eb172a2550455caa42cc503cf589e27","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.17.3"],"title":"Fix
calling Sonnet
3.7","number":212372,"url":"https://github.com/elastic/kibana/pull/212372","mergeCommit":{"message":"Fix
calling Sonnet 3.7 (elastic#212372)\n\n## Summary\n\nFixes \n<img
width=\"1509\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ba409fde-f52b-4864-a81a-70025ef61f2f\"\n/>","sha":"8c456d1e1eb172a2550455caa42cc503cf589e27"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.17"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212372","number":212372,"mergeCommit":{"message":"Fix
calling Sonnet 3.7 (elastic#212372)\n\n## Summary\n\nFixes \n<img
width=\"1509\"
alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/ba409fde-f52b-4864-a81a-70025ef61f2f\"\n/>","sha":"8c456d1e1eb172a2550455caa42cc503cf589e27"}},{"branch":"8.17","label":"v8.17.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Patryk Kopyciński <contact@patrykkopycinski.com>
  • Loading branch information
kibanamachine and patrykkopycinski authored Feb 25, 2025
1 parent fd5b0af commit c757a4b
Showing 1 changed file with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ export const BedrockToolChoiceSchema = schema.object({
name: schema.maybe(schema.string()),
});

export const BedrockUsageSchema = schema.maybe(
schema.object(
{
input_tokens: schema.number(),
output_tokens: schema.number(),
// added with Sonnet 3.7
cache_creation_input_tokens: schema.maybe(schema.number()),
},
{ unknowns: 'allow' }
)
);

export const InvokeAIActionParamsSchema = schema.object({
messages: schema.arrayOf(BedrockMessageSchema),
model: schema.maybe(schema.string()),
Expand All @@ -82,12 +94,7 @@ export const InvokeAIActionParamsSchema = schema.object({

export const InvokeAIActionResponseSchema = schema.object({
message: schema.string(),
usage: schema.maybe(
schema.object({
input_tokens: schema.number(),
output_tokens: schema.number(),
})
),
usage: BedrockUsageSchema,
});

export const InvokeAIRawActionParamsSchema = schema.object({
Expand Down Expand Up @@ -125,10 +132,7 @@ export const InvokeAIRawActionResponseSchema = schema.object({}, { unknowns: 'al
export const RunApiLatestResponseSchema = schema.object(
{
stop_reason: schema.maybe(schema.string()),
usage: schema.object({
input_tokens: schema.number(),
output_tokens: schema.number(),
}),
usage: BedrockUsageSchema,
content: schema.arrayOf(
schema.object(
{ type: schema.string(), text: schema.maybe(schema.string()) },
Expand All @@ -143,12 +147,7 @@ export const RunActionResponseSchema = schema.object(
{
completion: schema.string(),
stop_reason: schema.maybe(schema.string()),
usage: schema.maybe(
schema.object({
input_tokens: schema.number(),
output_tokens: schema.number(),
})
),
usage: BedrockUsageSchema,
},
{ unknowns: 'ignore' }
);
Expand Down

0 comments on commit c757a4b

Please sign in to comment.