mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
refactor: rename arktype schemas to match types
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
import { type } from "arktype"
|
import { type } from "arktype"
|
||||||
|
|
||||||
const syntheticItemSchema = type({
|
const SyntheticItem = type({
|
||||||
id: "string",
|
id: "string",
|
||||||
type: "string",
|
type: "string",
|
||||||
text: "string",
|
text: "string",
|
||||||
})
|
})
|
||||||
|
|
||||||
const enhancementResultSchema = type({
|
const EnhancementResult = type({
|
||||||
slotFills: "Record<string, Record<string, string | null>>",
|
slotFills: "Record<string, Record<string, string | null>>",
|
||||||
syntheticItems: syntheticItemSchema.array(),
|
syntheticItems: SyntheticItem.array(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type SyntheticItem = typeof syntheticItemSchema.infer
|
export type SyntheticItem = typeof SyntheticItem.infer
|
||||||
export type EnhancementResult = typeof enhancementResultSchema.infer
|
export type EnhancementResult = typeof EnhancementResult.infer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON Schema passed to OpenRouter's structured output.
|
* JSON Schema passed to OpenRouter's structured output.
|
||||||
* OpenRouter doesn't support arktype, so this is maintained separately.
|
* OpenRouter doesn't support arktype, so this is maintained separately.
|
||||||
*
|
*
|
||||||
* ⚠️ Must stay in sync with enhancementResultSchema above.
|
* ⚠️ Must stay in sync with EnhancementResult above.
|
||||||
* If you add/remove fields, update both schemas.
|
* If you add/remove fields, update both schemas.
|
||||||
*/
|
*/
|
||||||
export const enhancementResultJsonSchema = {
|
export const enhancementResultJsonSchema = {
|
||||||
@@ -76,7 +76,7 @@ export function parseEnhancementResult(json: string): EnhancementResult | null {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = enhancementResultSchema(parsed)
|
const result = EnhancementResult(parsed)
|
||||||
if (result instanceof type.errors) {
|
if (result instanceof type.errors) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user