@@ -9,12 +9,16 @@ import { NoSuchSchemaError } from "./NoSuchSchemaError.js";
9
9
import { SchemaDefinition } from "./SchemaDefinition.js" ;
10
10
import { SchemaValidationError } from "./SchemaValidationError.js" ;
11
11
12
+ // In this file, using 'any' is required to allow for flexibility in the inputs. The actual types are
13
+ // retrieved through lookups such as TOOL["name"], such that any does not affect any client.
14
+ /* eslint-disable @typescript-eslint/no-explicit-any */
15
+
12
16
// [ { name: "n", schema: z.object<SCHEMA> } | { ... } ]
13
17
type SchemaDefinitionArray < T extends SchemaDefinition < any , any > [ ] > = T ;
14
18
15
19
// { n: { name: "n", schema: z.object<SCHEMA> }, ... }
16
20
type ToSchemaDefinitionsMap <
17
- T extends SchemaDefinitionArray < SchemaDefinition < any , any > [ ] >
21
+ T extends SchemaDefinitionArray < SchemaDefinition < any , any > [ ] > ,
18
22
> = {
19
23
[ K in T [ number ] [ "name" ] ] : Extract < T [ number ] , SchemaDefinition < K , any > > ;
20
24
} ;
@@ -27,14 +31,14 @@ type ToSchemaUnion<T> = {
27
31
} [ keyof T ] ;
28
32
29
33
type ToOutputValue <
30
- SCHEMAS extends SchemaDefinitionArray < SchemaDefinition < any , any > [ ] >
34
+ SCHEMAS extends SchemaDefinitionArray < SchemaDefinition < any , any > [ ] > ,
31
35
> = ToSchemaUnion < ToSchemaDefinitionsMap < SCHEMAS > > ;
32
36
33
37
export function generateJsonOrText <
34
38
SCHEMAS extends SchemaDefinition < any , any > [ ] ,
35
39
PROMPT ,
36
40
RESPONSE ,
37
- SETTINGS extends GenerateJsonOrTextModelSettings
41
+ SETTINGS extends GenerateJsonOrTextModelSettings ,
38
42
> (
39
43
model : GenerateJsonOrTextModel < PROMPT , RESPONSE , SETTINGS > ,
40
44
schemaDefinitions : SCHEMAS ,
1 commit comments
vercel[bot] commentedon Jul 26, 2023
Successfully deployed to the following URLs:
ai-utils-js – ./
ai-utils-js-git-main-lgrammel.vercel.app
ai-utils.vercel.app
ai-utils-js-lgrammel.vercel.app
ai-utils.dev