pi-requesty-discover 3.1.2 → 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 +4 -4
- package/src/discovery.ts +3 -3
- package/src/health-check.ts +3 -3
- package/src/models-json.ts +30 -11
- package/src/requesty-api.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-requesty-discover",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Discover available Requesty models for the Pi Coding Agent",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
54
|
-
"@earendil-works/pi-tui": "^0.
|
|
53
|
+
"@earendil-works/pi-coding-agent": "^1.0.0",
|
|
54
|
+
"@earendil-works/pi-tui": "^1.0.0",
|
|
55
55
|
"@eslint/js": "^10.0.1",
|
|
56
56
|
"@types/node": "^26.1.0",
|
|
57
57
|
"@vitest/coverage-v8": "^4.1.9",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"vitest": "^4.1.9"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"openai": "^7.10.0",
|
|
71
70
|
"json5": "^2.2.3",
|
|
71
|
+
"openai": "^7.10.0",
|
|
72
72
|
"zod": "^4.4.3"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/discovery.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChatModelConfig } from './models-json'
|
|
2
2
|
import { type Env } from './env'
|
|
3
3
|
import {
|
|
4
4
|
type GetApiKey,
|
|
@@ -38,7 +38,7 @@ export type DiscoveryEvaluation = {
|
|
|
38
38
|
modelCount: number
|
|
39
39
|
failedCount: number
|
|
40
40
|
warningCount: number
|
|
41
|
-
passing:
|
|
41
|
+
passing: ChatModelConfig[]
|
|
42
42
|
diff: ModelsDiff
|
|
43
43
|
healthCheckSummary: string
|
|
44
44
|
logNote: string
|
|
@@ -73,7 +73,7 @@ export async function evaluateDiscovery(
|
|
|
73
73
|
let diff: ModelsDiff
|
|
74
74
|
let failedCount = 0
|
|
75
75
|
let warningCount = 0
|
|
76
|
-
let passing:
|
|
76
|
+
let passing: ChatModelConfig[] = []
|
|
77
77
|
let logNote = ''
|
|
78
78
|
let healthCheckSummary = ''
|
|
79
79
|
|
package/src/health-check.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChatModelConfig } from './models-json'
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import OpenAI from 'openai'
|
|
@@ -59,7 +59,7 @@ type ResolvedHealthCheckOptions = Required<Omit<HealthCheckOptions, 'onProgress'
|
|
|
59
59
|
|
|
60
60
|
export async function checkModels(
|
|
61
61
|
provider: Provider,
|
|
62
|
-
models:
|
|
62
|
+
models: ChatModelConfig[],
|
|
63
63
|
checkReasoning: boolean,
|
|
64
64
|
options: HealthCheckOptions = {},
|
|
65
65
|
): Promise<HealthCheckResult[]> {
|
|
@@ -248,7 +248,7 @@ async function verifyFirstStreamChunk(
|
|
|
248
248
|
|
|
249
249
|
async function checkModel(
|
|
250
250
|
provider: Provider,
|
|
251
|
-
model:
|
|
251
|
+
model: ChatModelConfig,
|
|
252
252
|
checkReasoning: boolean,
|
|
253
253
|
options: ResolvedHealthCheckOptions,
|
|
254
254
|
): Promise<ModelCheckResult> {
|
package/src/models-json.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ProviderConfig, ProviderModelConfig } from '@earendil-works/pi-coding-agent'
|
|
2
|
+
|
|
3
|
+
// chat-only model shape; the package only exports the mixed chat/image/classifier union type
|
|
4
|
+
export type ChatModelConfig = Extract<ProviderModelConfig, { type?: 'chat' }>
|
|
2
5
|
import fs from 'node:fs'
|
|
3
6
|
import path from 'node:path'
|
|
4
7
|
import { z } from 'zod'
|
|
@@ -11,13 +14,17 @@ const DEFAULT_NAME = 'Requesty'
|
|
|
11
14
|
/** Resolves the API key for a provider through Pi's model registry. */
|
|
12
15
|
export type GetApiKey = (providerId: string) => Promise<string | undefined>
|
|
13
16
|
|
|
17
|
+
const ProviderModelSchema = z
|
|
18
|
+
.object({ id: z.string(), thinkingLevelMap: z.record(z.string(), z.unknown()).optional() })
|
|
19
|
+
.catchall(z.unknown())
|
|
20
|
+
|
|
14
21
|
const ProviderSchema = z
|
|
15
22
|
.object({
|
|
16
23
|
name: z.string().optional(),
|
|
17
24
|
baseUrl: z.string().optional(),
|
|
18
25
|
apiKey: z.string().optional(),
|
|
19
26
|
api: z.string().optional(),
|
|
20
|
-
models: z.array(
|
|
27
|
+
models: z.array(ProviderModelSchema).optional(),
|
|
21
28
|
})
|
|
22
29
|
.catchall(z.unknown())
|
|
23
30
|
|
|
@@ -35,6 +42,7 @@ const ModelsJsonSchema = z
|
|
|
35
42
|
|
|
36
43
|
export type ModelsJson = z.infer<typeof ModelsJsonSchema>
|
|
37
44
|
type ModelsJsonProvider = z.infer<typeof ProviderSchema>
|
|
45
|
+
type ModelsJsonModel = z.infer<typeof ProviderModelSchema>
|
|
38
46
|
|
|
39
47
|
export type RequestyProvider = ModelsJsonProvider & {
|
|
40
48
|
name: string
|
|
@@ -99,9 +107,16 @@ export function formatModelsDiffSummary(diff: ModelsDiff): string {
|
|
|
99
107
|
].join('\n')
|
|
100
108
|
}
|
|
101
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
|
+
|
|
102
117
|
export function updateModelsJson(
|
|
103
118
|
data: ModelsJson,
|
|
104
|
-
models:
|
|
119
|
+
models: ChatModelConfig[],
|
|
105
120
|
settings: DiscoverySettings,
|
|
106
121
|
envConfig = getEnv(),
|
|
107
122
|
): void {
|
|
@@ -113,15 +128,19 @@ export function updateModelsJson(
|
|
|
113
128
|
api,
|
|
114
129
|
apiKey,
|
|
115
130
|
...passthrough,
|
|
116
|
-
models: models.map(model =>
|
|
117
|
-
id
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
}),
|
|
125
144
|
} satisfies ProviderConfig
|
|
126
145
|
|
|
127
146
|
writeModelsJson(data, envConfig)
|
package/src/requesty-api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChatModelConfig } from './models-json'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
|
|
4
4
|
const DEFAULT_CONTEXT_WINDOW = 128000
|
|
@@ -34,7 +34,7 @@ type Provider = {
|
|
|
34
34
|
export async function discoverModels(
|
|
35
35
|
provider: Provider,
|
|
36
36
|
options: { timeoutMs?: number } = {},
|
|
37
|
-
): Promise<
|
|
37
|
+
): Promise<ChatModelConfig[]> {
|
|
38
38
|
const timeoutMs = options.timeoutMs ?? 5_000
|
|
39
39
|
const response = await fetch(`${provider.baseUrl}/models`, {
|
|
40
40
|
headers: { Authorization: `Bearer ${provider.apiKey}` },
|
|
@@ -56,6 +56,8 @@ export async function discoverModels(
|
|
|
56
56
|
id: model.id,
|
|
57
57
|
name: model.name && model.name.length > 0 ? model.name : model.id,
|
|
58
58
|
reasoning: model.supports_reasoning === true,
|
|
59
|
+
// Requesty rejects the 'minimal' reasoning effort; null marks the level unsupported
|
|
60
|
+
...(model.supports_reasoning === true ? { thinkingLevelMap: { minimal: null } } : {}),
|
|
59
61
|
input: model.supports_vision === true ? ['text', 'image'] : ['text'],
|
|
60
62
|
cost: {
|
|
61
63
|
input: pricePerMillionTokens(model.input_price),
|