Skip to content

Commit 67f3f1c

Browse files
authored
Qurator: Switch to Claude 3.7 Sonnet, ensure tools schemas adhere to draft 2020-12 (#4343)
1 parent 7e21c66 commit 67f3f1c

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

catalog/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ where verb is one of
1818

1919
## Changes
2020

21+
- [Changed] Qurator: Switch to Claude 3.7 Sonnet ([#4343](https://github.com/quiltdata/quilt/pull/4343))
22+
- [Fixed] Qurator: Ensure tools schemas adhere to draft 2020-12 ([#4343](https://github.com/quiltdata/quilt/pull/4343))
2123
- [Added] Support setting the location where files are uploaded while creating or promoting packages (using `packageRoot` config property) ([#4384](https://github.com/quiltdata/quilt/pull/4384))
2224
- [Changed] Search: Only show package comment and hash when including historical versions, adjust stylings ([#4371](https://github.com/quiltdata/quilt/pull/4371))
2325
- [Changed] Allow forms and popups in iframes when **Permissive HTML Rendering** enabled ([#4366](https://github.com/quiltdata/quilt/pull/4366))

catalog/app/components/Assistant/Model/Bedrock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as LLM from './LLM'
99

1010
const MODULE = 'Bedrock'
1111

12-
const MODEL_ID = 'us.anthropic.claude-3-5-sonnet-20241022-v2:0'
12+
const MODEL_ID = 'us.anthropic.claude-3-7-sonnet-20250219-v1:0'
1313

1414
const mapContent = (contentBlocks: BedrockRuntime.ContentBlocks | undefined) =>
1515
Eff.pipe(

catalog/app/components/Assistant/Model/GlobalContext/__snapshots__/navigation.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ exports[`components/Assistant/Model/GlobalTools/navigation NavigateSchema produc
203203
"type": "object",
204204
},
205205
},
206-
"$schema": "http://json-schema.org/draft-07/schema#",
206+
"$schema": "https://json-schema.org/draft/2020-12/schema",
207207
"additionalProperties": false,
208208
"description": "navigate to a provided route",
209209
"properties": {
@@ -220,7 +220,7 @@ exports[`components/Assistant/Model/GlobalTools/navigation NavigateSchema produc
220220
"type": "string",
221221
},
222222
"params": {
223-
"$id": "/schemas/{}",
223+
"$id": "/schemas/empty",
224224
"anyOf": [
225225
{
226226
"type": "object",
@@ -248,7 +248,7 @@ exports[`components/Assistant/Model/GlobalTools/navigation NavigateSchema produc
248248
"type": "string",
249249
},
250250
"params": {
251-
"$id": "/schemas/{}",
251+
"$id": "/schemas/empty",
252252
"anyOf": [
253253
{
254254
"type": "object",
@@ -704,7 +704,7 @@ exports[`components/Assistant/Model/GlobalTools/navigation NavigateSchema produc
704704
"type": "string",
705705
},
706706
"params": {
707-
"$id": "/schemas/{}",
707+
"$id": "/schemas/empty",
708708
"anyOf": [
709709
{
710710
"type": "object",

catalog/app/components/Assistant/Model/GlobalContext/navigation.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as Eff from 'effect'
22

3+
import { makeJSONSchema } from '../Tool'
4+
35
import * as nav from './navigation'
46

57
jest.mock(
@@ -11,7 +13,7 @@ describe('components/Assistant/Model/GlobalTools/navigation', () => {
1113
describe('NavigateSchema', () => {
1214
describe('produced JSON Schema', () => {
1315
it('should match the snapshot', () => {
14-
const jsonSchema = Eff.JSONSchema.make(nav.NavigateSchema)
16+
const jsonSchema = makeJSONSchema(nav.NavigateSchema)
1517
expect(jsonSchema).toMatchSnapshot()
1618
})
1719
})

catalog/app/components/Assistant/Model/Tool.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,49 @@ export interface Descriptor<I> {
2929

3030
export type Collection = Record<string, Descriptor<any>>
3131

32+
/**
33+
* Ensure a JSON schema is compatible with draft-2020-12 by:
34+
* 1. Replacing $id: 'schemas/{}' with $id: 'schemas/empty'
35+
* 2. Converting draft-04/07 items/additionalItems to draft-2020 prefixItems/items
36+
*/
37+
function convertSchema(schema: any) {
38+
if (!schema || typeof schema !== 'object') return
39+
40+
// Process arrays
41+
if (Array.isArray(schema)) {
42+
schema.forEach(convertSchema)
43+
return
44+
}
45+
46+
// Process object properties recursively
47+
Object.values(schema).forEach(convertSchema)
48+
49+
// Replace empty schema IDs produced by Effect, which are not valid according to draft-2020
50+
if (schema.$id === '/schemas/{}') schema.$id = '/schemas/empty'
51+
52+
// Handle items and additionalItems conversion for draft-2020
53+
if (Array.isArray(schema.items)) {
54+
schema.prefixItems = schema.items
55+
delete schema.items
56+
if (schema.additionalItems !== undefined) {
57+
schema.items = schema.additionalItems
58+
delete schema.additionalItems
59+
}
60+
}
61+
}
62+
63+
export function makeJSONSchema(schema: Eff.Schema.Schema<any, any>) {
64+
const out = Eff.JSONSchema.make(schema)
65+
out.$schema = 'https://json-schema.org/draft/2020-12/schema'
66+
convertSchema(out)
67+
return out
68+
}
69+
3270
export function make<A, I>(
3371
schema: Eff.Schema.Schema<A, I>,
3472
fn: Executor<A>,
3573
): Descriptor<A> {
36-
const jsonSchema = Eff.JSONSchema.make(schema)
74+
const jsonSchema = makeJSONSchema(schema)
3775

3876
const decode = Eff.Schema.decodeUnknown(schema, {
3977
errors: 'all',

0 commit comments

Comments
 (0)