pi-requesty-discover 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/models-json.ts +26 -11
package/package.json
CHANGED
package/src/models-json.ts
CHANGED
|
@@ -14,13 +14,17 @@ const DEFAULT_NAME = 'Requesty'
|
|
|
14
14
|
/** Resolves the API key for a provider through Pi's model registry. */
|
|
15
15
|
export type GetApiKey = (providerId: string) => Promise<string | undefined>
|
|
16
16
|
|
|
17
|
+
const ProviderModelSchema = z
|
|
18
|
+
.object({ id: z.string(), thinkingLevelMap: z.record(z.string(), z.unknown()).optional() })
|
|
19
|
+
.catchall(z.unknown())
|
|
20
|
+
|
|
17
21
|
const ProviderSchema = z
|
|
18
22
|
.object({
|
|
19
23
|
name: z.string().optional(),
|
|
20
24
|
baseUrl: z.string().optional(),
|
|
21
25
|
apiKey: z.string().optional(),
|
|
22
26
|
api: z.string().optional(),
|
|
23
|
-
models: z.array(
|
|
27
|
+
models: z.array(ProviderModelSchema).optional(),
|
|
24
28
|
})
|
|
25
29
|
.catchall(z.unknown())
|
|
26
30
|
|
|
@@ -38,6 +42,7 @@ const ModelsJsonSchema = z
|
|
|
38
42
|
|
|
39
43
|
export type ModelsJson = z.infer<typeof ModelsJsonSchema>
|
|
40
44
|
type ModelsJsonProvider = z.infer<typeof ProviderSchema>
|
|
45
|
+
type ModelsJsonModel = z.infer<typeof ProviderModelSchema>
|
|
41
46
|
|
|
42
47
|
export type RequestyProvider = ModelsJsonProvider & {
|
|
43
48
|
name: string
|
|
@@ -102,6 +107,13 @@ export function formatModelsDiffSummary(diff: ModelsDiff): string {
|
|
|
102
107
|
].join('\n')
|
|
103
108
|
}
|
|
104
109
|
|
|
110
|
+
function thinkingLevelMap(model: ChatModelConfig, existingModelConfig: ModelsJsonModel | undefined) {
|
|
111
|
+
if (existingModelConfig?.thinkingLevelMap) {
|
|
112
|
+
return { thinkingLevelMap: existingModelConfig.thinkingLevelMap }
|
|
113
|
+
}
|
|
114
|
+
return model.thinkingLevelMap ? { thinkingLevelMap: model.thinkingLevelMap } : {}
|
|
115
|
+
}
|
|
116
|
+
|
|
105
117
|
export function updateModelsJson(
|
|
106
118
|
data: ModelsJson,
|
|
107
119
|
models: ChatModelConfig[],
|
|
@@ -116,16 +128,19 @@ export function updateModelsJson(
|
|
|
116
128
|
api,
|
|
117
129
|
apiKey,
|
|
118
130
|
...passthrough,
|
|
119
|
-
models: models.map(model =>
|
|
120
|
-
id
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
models: models.map(model => {
|
|
132
|
+
const existingModelConfig = provider.models?.find(m => m.id === model.id)
|
|
133
|
+
return {
|
|
134
|
+
id: model.id,
|
|
135
|
+
name: model.name,
|
|
136
|
+
reasoning: model.reasoning,
|
|
137
|
+
...thinkingLevelMap(model, existingModelConfig),
|
|
138
|
+
input: model.input,
|
|
139
|
+
cost: model.cost,
|
|
140
|
+
contextWindow: model.contextWindow,
|
|
141
|
+
maxTokens: model.maxTokens,
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
129
144
|
} satisfies ProviderConfig
|
|
130
145
|
|
|
131
146
|
writeModelsJson(data, envConfig)
|