notdiamond 2.0.0-rc1 → 2.0.0-rc4

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.
Files changed (167) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +19 -21
  3. package/client.d.mts +21 -35
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +21 -35
  6. package/client.d.ts.map +1 -1
  7. package/client.js +23 -39
  8. package/client.js.map +1 -1
  9. package/client.mjs +23 -39
  10. package/client.mjs.map +1 -1
  11. package/internal/tslib.js +17 -17
  12. package/internal/utils/env.d.mts.map +1 -1
  13. package/internal/utils/env.d.ts.map +1 -1
  14. package/internal/utils/env.js +4 -2
  15. package/internal/utils/env.js.map +1 -1
  16. package/internal/utils/env.mjs +4 -2
  17. package/internal/utils/env.mjs.map +1 -1
  18. package/package.json +10 -11
  19. package/resources/index.d.mts +6 -6
  20. package/resources/index.d.mts.map +1 -1
  21. package/resources/index.d.ts +6 -6
  22. package/resources/index.d.ts.map +1 -1
  23. package/resources/index.js +8 -8
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs +4 -4
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/model-router.d.mts +311 -0
  28. package/resources/model-router.d.mts.map +1 -0
  29. package/resources/model-router.d.ts +311 -0
  30. package/resources/model-router.d.ts.map +1 -0
  31. package/resources/model-router.js +97 -0
  32. package/resources/model-router.js.map +1 -0
  33. package/resources/model-router.mjs +93 -0
  34. package/resources/model-router.mjs.map +1 -0
  35. package/resources/models.d.mts +50 -25
  36. package/resources/models.d.mts.map +1 -1
  37. package/resources/models.d.ts +50 -25
  38. package/resources/models.d.ts.map +1 -1
  39. package/resources/models.js +5 -0
  40. package/resources/models.js.map +1 -1
  41. package/resources/models.mjs +5 -0
  42. package/resources/models.mjs.map +1 -1
  43. package/resources/preferences.d.mts +49 -47
  44. package/resources/preferences.d.mts.map +1 -1
  45. package/resources/preferences.d.ts +49 -47
  46. package/resources/preferences.d.ts.map +1 -1
  47. package/resources/preferences.js +30 -33
  48. package/resources/preferences.js.map +1 -1
  49. package/resources/preferences.mjs +30 -33
  50. package/resources/preferences.mjs.map +1 -1
  51. package/resources/prompt/adapt.d.mts +352 -0
  52. package/resources/prompt/adapt.d.mts.map +1 -0
  53. package/resources/prompt/adapt.d.ts +352 -0
  54. package/resources/prompt/adapt.d.ts.map +1 -0
  55. package/resources/prompt/adapt.js +154 -0
  56. package/resources/prompt/adapt.js.map +1 -0
  57. package/resources/prompt/adapt.mjs +150 -0
  58. package/resources/prompt/adapt.mjs.map +1 -0
  59. package/resources/prompt/index.d.mts +3 -0
  60. package/resources/prompt/index.d.mts.map +1 -0
  61. package/resources/prompt/index.d.ts +3 -0
  62. package/resources/prompt/index.d.ts.map +1 -0
  63. package/resources/prompt/index.js +9 -0
  64. package/resources/prompt/index.js.map +1 -0
  65. package/resources/prompt/index.mjs +4 -0
  66. package/resources/prompt/index.mjs.map +1 -0
  67. package/resources/prompt/prompt.d.mts +338 -0
  68. package/resources/prompt/prompt.d.mts.map +1 -0
  69. package/resources/prompt/prompt.d.ts +338 -0
  70. package/resources/prompt/prompt.d.ts.map +1 -0
  71. package/resources/prompt/prompt.js +128 -0
  72. package/resources/prompt/prompt.js.map +1 -0
  73. package/resources/prompt/prompt.mjs +123 -0
  74. package/resources/prompt/prompt.mjs.map +1 -0
  75. package/resources/prompt.d.mts +2 -0
  76. package/resources/prompt.d.mts.map +1 -0
  77. package/resources/prompt.d.ts +2 -0
  78. package/resources/prompt.d.ts.map +1 -0
  79. package/resources/prompt.js +6 -0
  80. package/resources/prompt.js.map +1 -0
  81. package/resources/prompt.mjs +3 -0
  82. package/resources/prompt.mjs.map +1 -0
  83. package/resources/pzn.d.mts +225 -0
  84. package/resources/pzn.d.mts.map +1 -0
  85. package/resources/pzn.d.ts +225 -0
  86. package/resources/pzn.d.ts.map +1 -0
  87. package/resources/{routing.js → pzn.js} +28 -71
  88. package/resources/pzn.js.map +1 -0
  89. package/resources/{routing.mjs → pzn.mjs} +26 -69
  90. package/resources/pzn.mjs.map +1 -0
  91. package/resources/report/index.d.mts +3 -0
  92. package/resources/report/index.d.mts.map +1 -0
  93. package/resources/report/index.d.ts +3 -0
  94. package/resources/report/index.d.ts.map +1 -0
  95. package/resources/report/index.js +9 -0
  96. package/resources/report/index.js.map +1 -0
  97. package/resources/report/index.mjs +4 -0
  98. package/resources/report/index.mjs.map +1 -0
  99. package/resources/report/metrics.d.mts +87 -0
  100. package/resources/report/metrics.d.mts.map +1 -0
  101. package/resources/report/metrics.d.ts +87 -0
  102. package/resources/report/metrics.d.ts.map +1 -0
  103. package/resources/report/metrics.js +57 -0
  104. package/resources/report/metrics.js.map +1 -0
  105. package/resources/report/metrics.mjs +53 -0
  106. package/resources/report/metrics.mjs.map +1 -0
  107. package/resources/report/report.d.mts +10 -0
  108. package/resources/report/report.d.mts.map +1 -0
  109. package/resources/report/report.d.ts +10 -0
  110. package/resources/report/report.d.ts.map +1 -0
  111. package/resources/report/report.js +17 -0
  112. package/resources/report/report.js.map +1 -0
  113. package/resources/report/report.mjs +12 -0
  114. package/resources/report/report.mjs.map +1 -0
  115. package/resources/report.d.mts +1 -244
  116. package/resources/report.d.mts.map +1 -1
  117. package/resources/report.d.ts +1 -244
  118. package/resources/report.d.ts.map +1 -1
  119. package/resources/report.js +2 -82
  120. package/resources/report.js.map +1 -1
  121. package/resources/report.mjs +1 -80
  122. package/resources/report.mjs.map +1 -1
  123. package/src/client.ts +71 -120
  124. package/src/internal/utils/env.ts +4 -2
  125. package/src/resources/index.ts +24 -34
  126. package/src/resources/model-router.ts +356 -0
  127. package/src/resources/models.ts +55 -32
  128. package/src/resources/preferences.ts +61 -70
  129. package/src/resources/prompt/adapt.ts +402 -0
  130. package/src/resources/prompt/index.ts +16 -0
  131. package/src/resources/prompt/prompt.ts +398 -0
  132. package/src/resources/prompt.ts +3 -0
  133. package/src/resources/pzn.ts +273 -0
  134. package/src/resources/report/index.ts +4 -0
  135. package/src/resources/report/metrics.ts +99 -0
  136. package/src/resources/report/report.ts +19 -0
  137. package/src/resources/report.ts +1 -298
  138. package/src/version.ts +1 -1
  139. package/version.d.mts +1 -1
  140. package/version.d.ts +1 -1
  141. package/version.js +1 -1
  142. package/version.mjs +1 -1
  143. package/resources/admin.d.mts +0 -4
  144. package/resources/admin.d.mts.map +0 -1
  145. package/resources/admin.d.ts +0 -4
  146. package/resources/admin.d.ts.map +0 -1
  147. package/resources/admin.js +0 -9
  148. package/resources/admin.js.map +0 -1
  149. package/resources/admin.mjs +0 -5
  150. package/resources/admin.mjs.map +0 -1
  151. package/resources/prompt-adaptation.d.mts +0 -574
  152. package/resources/prompt-adaptation.d.mts.map +0 -1
  153. package/resources/prompt-adaptation.d.ts +0 -574
  154. package/resources/prompt-adaptation.d.ts.map +0 -1
  155. package/resources/prompt-adaptation.js +0 -289
  156. package/resources/prompt-adaptation.js.map +0 -1
  157. package/resources/prompt-adaptation.mjs +0 -285
  158. package/resources/prompt-adaptation.mjs.map +0 -1
  159. package/resources/routing.d.mts +0 -391
  160. package/resources/routing.d.mts.map +0 -1
  161. package/resources/routing.d.ts +0 -391
  162. package/resources/routing.d.ts.map +0 -1
  163. package/resources/routing.js.map +0 -1
  164. package/resources/routing.mjs.map +0 -1
  165. package/src/resources/admin.ts +0 -5
  166. package/src/resources/prompt-adaptation.ts +0 -700
  167. package/src/resources/routing.ts +0 -476
@@ -0,0 +1,225 @@
1
+ import { APIResource } from "../core/resource.mjs";
2
+ import { APIPromise } from "../core/api-promise.mjs";
3
+ import { type Uploadable } from "../core/uploads.mjs";
4
+ import { RequestOptions } from "../internal/request-options.mjs";
5
+ export declare class Pzn extends APIResource {
6
+ /**
7
+ * Submit a survey response for personalized routing setup.
8
+ *
9
+ * This admin endpoint processes survey responses to set up personalized routing
10
+ * configurations for users based on their use case, LLM preferences, and
11
+ * constraints.
12
+ *
13
+ * **Survey Data:**
14
+ *
15
+ * - User information and use case description
16
+ * - Preferred LLM providers and models
17
+ * - Constraint priorities (quality, cost, latency)
18
+ * - Optional prompts and evaluation datasets
19
+ *
20
+ * **File Uploads:**
21
+ *
22
+ * - `prompt_file`: Optional CSV file with prompts
23
+ * - `dataset_file`: Optional CSV file with evaluation dataset
24
+ *
25
+ * **Note:** This is an admin-only endpoint for internal use.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const response = await client.pzn.submitSurveyResponse({
30
+ * constraint_priorities: 'constraint_priorities',
31
+ * email: 'email',
32
+ * llm_providers: 'llm_providers',
33
+ * use_case_desc: 'use_case_desc',
34
+ * user_id: 'user_id',
35
+ * 'x-token': 'x-token',
36
+ * });
37
+ * ```
38
+ */
39
+ submitSurveyResponse(params: PznSubmitSurveyResponseParams, options?: RequestOptions): APIPromise<unknown>;
40
+ /**
41
+ * Train a custom router on your evaluation data to optimize routing for your
42
+ * specific use case.
43
+ *
44
+ * This endpoint allows you to train a domain-specific router that learns which
45
+ * models perform best for different types of queries in your application. The
46
+ * router analyzes your evaluation dataset, clusters similar queries, and learns
47
+ * model performance patterns.
48
+ *
49
+ * **Training Process:**
50
+ *
51
+ * 1. Upload a CSV file with your evaluation data
52
+ * 2. Specify which models to route between
53
+ * 3. Define the evaluation metric (score column)
54
+ * 4. The system trains asynchronously and returns a preference_id
55
+ * 5. Use the preference_id in model_select() calls once training completes
56
+ *
57
+ * **Dataset Requirements:**
58
+ *
59
+ * - Format: CSV file
60
+ * - Minimum samples: 25 (more is better for accuracy)
61
+ * - Required columns:
62
+ * - Prompt column (specified in prompt_column parameter)
63
+ * - For each model: `{provider}/{model}/score` and `{provider}/{model}/response`
64
+ *
65
+ * **Example CSV structure:**
66
+ *
67
+ * ```
68
+ * prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-sonnet-4-5-20250929/score,anthropic/claude-sonnet-4-5-20250929/response
69
+ * "Explain quantum computing",0.95,"Quantum computing uses...",0.87,"Quantum computers leverage..."
70
+ * "Write a Python function",0.82,"def my_function()...",0.91,"Here's a Python function..."
71
+ * ```
72
+ *
73
+ * **Model Selection:**
74
+ *
75
+ * - Specify standard models: `{"provider": "openai", "model": "gpt-4o"}`
76
+ * - Or custom models with pricing:
77
+ * `{"provider": "custom", "model": "my-model", "is_custom": true, "input_price": 10.0, "output_price": 30.0, "context_length": 8192, "latency": 1.5}`
78
+ *
79
+ * **Training Time:**
80
+ *
81
+ * - Training is asynchronous and typically takes 5-15 minutes
82
+ * - Larger datasets or more models take longer
83
+ * - You'll receive a preference_id immediately
84
+ * - Check training status by attempting to use the preference_id in model_select()
85
+ *
86
+ * **Best Practices:**
87
+ *
88
+ * 1. Use diverse, representative examples from your production workload
89
+ * 2. Include at least 50-100 samples for best results
90
+ * 3. Ensure consistent evaluation metrics across all models
91
+ * 4. Use the same models you plan to route between in production
92
+ *
93
+ * **Related Documentation:** See
94
+ * https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
95
+ * guide.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const response = await client.pzn.trainCustomRouter({
100
+ * dataset_file: fs.createReadStream('path/to/file'),
101
+ * language: 'english',
102
+ * llm_providers:
103
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-sonnet-4-5-20250929"}]',
104
+ * maximize: true,
105
+ * prompt_column: 'prompt',
106
+ * });
107
+ * ```
108
+ */
109
+ trainCustomRouter(body: PznTrainCustomRouterParams, options?: RequestOptions): APIPromise<PznTrainCustomRouterResponse>;
110
+ }
111
+ export type PznSubmitSurveyResponseResponse = unknown;
112
+ /**
113
+ * Response model for POST /v2/pzn/trainCustomRouter endpoint.
114
+ *
115
+ * Returned immediately after submitting a custom router training request. The
116
+ * training process runs asynchronously (typically 5-15 minutes), so use the
117
+ * returned preference_id to make routing calls once training completes.
118
+ *
119
+ * **Next steps:**
120
+ *
121
+ * 1. Store the preference_id
122
+ * 2. Wait for training to complete (typically 5-15 minutes)
123
+ * 3. Use this preference_id in POST /v2/modelRouter/modelSelect requests
124
+ * 4. The router will use your custom-trained model to make routing decisions
125
+ *
126
+ * **How to use the preference_id:**
127
+ *
128
+ * - Include it in the 'preference_id' field of model_select() calls
129
+ * - The system automatically uses your custom router once training is complete
130
+ * - No need to poll status - you can start using it immediately (will use default
131
+ * until ready)
132
+ */
133
+ export interface PznTrainCustomRouterResponse {
134
+ /**
135
+ * Unique identifier for the custom router. Use this in model_select() calls to
136
+ * enable routing with your custom-trained router
137
+ */
138
+ preference_id: string;
139
+ }
140
+ export interface PznSubmitSurveyResponseParams {
141
+ /**
142
+ * Body param: JSON string of constraint priorities object
143
+ */
144
+ constraint_priorities: string;
145
+ /**
146
+ * Body param: User email address
147
+ */
148
+ email: string;
149
+ /**
150
+ * Body param: JSON string of LLM providers array
151
+ */
152
+ llm_providers: string;
153
+ /**
154
+ * Body param: Description of the user's use case
155
+ */
156
+ use_case_desc: string;
157
+ /**
158
+ * Body param: User ID from Supabase
159
+ */
160
+ user_id: string;
161
+ /**
162
+ * Header param:
163
+ */
164
+ 'x-token': string;
165
+ /**
166
+ * Body param: Optional additional preferences text
167
+ */
168
+ additional_preferences?: string | null;
169
+ /**
170
+ * Body param: Optional CSV file with evaluation dataset
171
+ */
172
+ dataset_file?: Uploadable | null;
173
+ /**
174
+ * Body param: Optional preference name
175
+ */
176
+ name?: string | null;
177
+ /**
178
+ * Body param: Optional CSV file with prompts
179
+ */
180
+ prompt_file?: Uploadable | null;
181
+ /**
182
+ * Body param: Optional JSON string of prompts array
183
+ */
184
+ prompts?: string | null;
185
+ }
186
+ export interface PznTrainCustomRouterParams {
187
+ /**
188
+ * CSV file containing evaluation data with prompt column and score/response
189
+ * columns for each model
190
+ */
191
+ dataset_file: Uploadable;
192
+ /**
193
+ * Language of the evaluation data. Use 'english' for English-only data or
194
+ * 'multilingual' for multi-language support
195
+ */
196
+ language: string;
197
+ /**
198
+ * JSON string array of LLM providers to train the router on. Format:
199
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model":
200
+ * "claude-sonnet-4-5-20250929"}]'
201
+ */
202
+ llm_providers: string;
203
+ /**
204
+ * Whether higher scores are better. Set to true if higher scores indicate better
205
+ * performance, false otherwise
206
+ */
207
+ maximize: boolean;
208
+ /**
209
+ * Name of the column in the CSV file that contains the prompts
210
+ */
211
+ prompt_column: string;
212
+ /**
213
+ * Whether to override an existing custom router for this preference_id
214
+ */
215
+ override?: boolean | null;
216
+ /**
217
+ * Optional preference ID to update an existing router. If not provided, a new
218
+ * preference will be created
219
+ */
220
+ preference_id?: string | null;
221
+ }
222
+ export declare namespace Pzn {
223
+ export { type PznSubmitSurveyResponseResponse as PznSubmitSurveyResponseResponse, type PznTrainCustomRouterResponse as PznTrainCustomRouterResponse, type PznSubmitSurveyResponseParams as PznSubmitSurveyResponseParams, type PznTrainCustomRouterParams as PznTrainCustomRouterParams, };
224
+ }
225
+ //# sourceMappingURL=pzn.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pzn.d.mts","sourceRoot":"","sources":["../src/resources/pzn.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,UAAU,EAAE;OAEnB,EAAE,cAAc,EAAE;AAGzB,qBAAa,GAAI,SAAQ,WAAW;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,oBAAoB,CAAC,MAAM,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IAW1G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,iBAAiB,CACf,IAAI,EAAE,0BAA0B,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,4BAA4B,CAAC;CAM5C;AAED,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,4BAA4B;IAC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CACH"}
@@ -0,0 +1,225 @@
1
+ import { APIResource } from "../core/resource.js";
2
+ import { APIPromise } from "../core/api-promise.js";
3
+ import { type Uploadable } from "../core/uploads.js";
4
+ import { RequestOptions } from "../internal/request-options.js";
5
+ export declare class Pzn extends APIResource {
6
+ /**
7
+ * Submit a survey response for personalized routing setup.
8
+ *
9
+ * This admin endpoint processes survey responses to set up personalized routing
10
+ * configurations for users based on their use case, LLM preferences, and
11
+ * constraints.
12
+ *
13
+ * **Survey Data:**
14
+ *
15
+ * - User information and use case description
16
+ * - Preferred LLM providers and models
17
+ * - Constraint priorities (quality, cost, latency)
18
+ * - Optional prompts and evaluation datasets
19
+ *
20
+ * **File Uploads:**
21
+ *
22
+ * - `prompt_file`: Optional CSV file with prompts
23
+ * - `dataset_file`: Optional CSV file with evaluation dataset
24
+ *
25
+ * **Note:** This is an admin-only endpoint for internal use.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const response = await client.pzn.submitSurveyResponse({
30
+ * constraint_priorities: 'constraint_priorities',
31
+ * email: 'email',
32
+ * llm_providers: 'llm_providers',
33
+ * use_case_desc: 'use_case_desc',
34
+ * user_id: 'user_id',
35
+ * 'x-token': 'x-token',
36
+ * });
37
+ * ```
38
+ */
39
+ submitSurveyResponse(params: PznSubmitSurveyResponseParams, options?: RequestOptions): APIPromise<unknown>;
40
+ /**
41
+ * Train a custom router on your evaluation data to optimize routing for your
42
+ * specific use case.
43
+ *
44
+ * This endpoint allows you to train a domain-specific router that learns which
45
+ * models perform best for different types of queries in your application. The
46
+ * router analyzes your evaluation dataset, clusters similar queries, and learns
47
+ * model performance patterns.
48
+ *
49
+ * **Training Process:**
50
+ *
51
+ * 1. Upload a CSV file with your evaluation data
52
+ * 2. Specify which models to route between
53
+ * 3. Define the evaluation metric (score column)
54
+ * 4. The system trains asynchronously and returns a preference_id
55
+ * 5. Use the preference_id in model_select() calls once training completes
56
+ *
57
+ * **Dataset Requirements:**
58
+ *
59
+ * - Format: CSV file
60
+ * - Minimum samples: 25 (more is better for accuracy)
61
+ * - Required columns:
62
+ * - Prompt column (specified in prompt_column parameter)
63
+ * - For each model: `{provider}/{model}/score` and `{provider}/{model}/response`
64
+ *
65
+ * **Example CSV structure:**
66
+ *
67
+ * ```
68
+ * prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-sonnet-4-5-20250929/score,anthropic/claude-sonnet-4-5-20250929/response
69
+ * "Explain quantum computing",0.95,"Quantum computing uses...",0.87,"Quantum computers leverage..."
70
+ * "Write a Python function",0.82,"def my_function()...",0.91,"Here's a Python function..."
71
+ * ```
72
+ *
73
+ * **Model Selection:**
74
+ *
75
+ * - Specify standard models: `{"provider": "openai", "model": "gpt-4o"}`
76
+ * - Or custom models with pricing:
77
+ * `{"provider": "custom", "model": "my-model", "is_custom": true, "input_price": 10.0, "output_price": 30.0, "context_length": 8192, "latency": 1.5}`
78
+ *
79
+ * **Training Time:**
80
+ *
81
+ * - Training is asynchronous and typically takes 5-15 minutes
82
+ * - Larger datasets or more models take longer
83
+ * - You'll receive a preference_id immediately
84
+ * - Check training status by attempting to use the preference_id in model_select()
85
+ *
86
+ * **Best Practices:**
87
+ *
88
+ * 1. Use diverse, representative examples from your production workload
89
+ * 2. Include at least 50-100 samples for best results
90
+ * 3. Ensure consistent evaluation metrics across all models
91
+ * 4. Use the same models you plan to route between in production
92
+ *
93
+ * **Related Documentation:** See
94
+ * https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
95
+ * guide.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const response = await client.pzn.trainCustomRouter({
100
+ * dataset_file: fs.createReadStream('path/to/file'),
101
+ * language: 'english',
102
+ * llm_providers:
103
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-sonnet-4-5-20250929"}]',
104
+ * maximize: true,
105
+ * prompt_column: 'prompt',
106
+ * });
107
+ * ```
108
+ */
109
+ trainCustomRouter(body: PznTrainCustomRouterParams, options?: RequestOptions): APIPromise<PznTrainCustomRouterResponse>;
110
+ }
111
+ export type PznSubmitSurveyResponseResponse = unknown;
112
+ /**
113
+ * Response model for POST /v2/pzn/trainCustomRouter endpoint.
114
+ *
115
+ * Returned immediately after submitting a custom router training request. The
116
+ * training process runs asynchronously (typically 5-15 minutes), so use the
117
+ * returned preference_id to make routing calls once training completes.
118
+ *
119
+ * **Next steps:**
120
+ *
121
+ * 1. Store the preference_id
122
+ * 2. Wait for training to complete (typically 5-15 minutes)
123
+ * 3. Use this preference_id in POST /v2/modelRouter/modelSelect requests
124
+ * 4. The router will use your custom-trained model to make routing decisions
125
+ *
126
+ * **How to use the preference_id:**
127
+ *
128
+ * - Include it in the 'preference_id' field of model_select() calls
129
+ * - The system automatically uses your custom router once training is complete
130
+ * - No need to poll status - you can start using it immediately (will use default
131
+ * until ready)
132
+ */
133
+ export interface PznTrainCustomRouterResponse {
134
+ /**
135
+ * Unique identifier for the custom router. Use this in model_select() calls to
136
+ * enable routing with your custom-trained router
137
+ */
138
+ preference_id: string;
139
+ }
140
+ export interface PznSubmitSurveyResponseParams {
141
+ /**
142
+ * Body param: JSON string of constraint priorities object
143
+ */
144
+ constraint_priorities: string;
145
+ /**
146
+ * Body param: User email address
147
+ */
148
+ email: string;
149
+ /**
150
+ * Body param: JSON string of LLM providers array
151
+ */
152
+ llm_providers: string;
153
+ /**
154
+ * Body param: Description of the user's use case
155
+ */
156
+ use_case_desc: string;
157
+ /**
158
+ * Body param: User ID from Supabase
159
+ */
160
+ user_id: string;
161
+ /**
162
+ * Header param:
163
+ */
164
+ 'x-token': string;
165
+ /**
166
+ * Body param: Optional additional preferences text
167
+ */
168
+ additional_preferences?: string | null;
169
+ /**
170
+ * Body param: Optional CSV file with evaluation dataset
171
+ */
172
+ dataset_file?: Uploadable | null;
173
+ /**
174
+ * Body param: Optional preference name
175
+ */
176
+ name?: string | null;
177
+ /**
178
+ * Body param: Optional CSV file with prompts
179
+ */
180
+ prompt_file?: Uploadable | null;
181
+ /**
182
+ * Body param: Optional JSON string of prompts array
183
+ */
184
+ prompts?: string | null;
185
+ }
186
+ export interface PznTrainCustomRouterParams {
187
+ /**
188
+ * CSV file containing evaluation data with prompt column and score/response
189
+ * columns for each model
190
+ */
191
+ dataset_file: Uploadable;
192
+ /**
193
+ * Language of the evaluation data. Use 'english' for English-only data or
194
+ * 'multilingual' for multi-language support
195
+ */
196
+ language: string;
197
+ /**
198
+ * JSON string array of LLM providers to train the router on. Format:
199
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model":
200
+ * "claude-sonnet-4-5-20250929"}]'
201
+ */
202
+ llm_providers: string;
203
+ /**
204
+ * Whether higher scores are better. Set to true if higher scores indicate better
205
+ * performance, false otherwise
206
+ */
207
+ maximize: boolean;
208
+ /**
209
+ * Name of the column in the CSV file that contains the prompts
210
+ */
211
+ prompt_column: string;
212
+ /**
213
+ * Whether to override an existing custom router for this preference_id
214
+ */
215
+ override?: boolean | null;
216
+ /**
217
+ * Optional preference ID to update an existing router. If not provided, a new
218
+ * preference will be created
219
+ */
220
+ preference_id?: string | null;
221
+ }
222
+ export declare namespace Pzn {
223
+ export { type PznSubmitSurveyResponseResponse as PznSubmitSurveyResponseResponse, type PznTrainCustomRouterResponse as PznTrainCustomRouterResponse, type PznSubmitSurveyResponseParams as PznSubmitSurveyResponseParams, type PznTrainCustomRouterParams as PznTrainCustomRouterParams, };
224
+ }
225
+ //# sourceMappingURL=pzn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pzn.d.ts","sourceRoot":"","sources":["../src/resources/pzn.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,UAAU,EAAE;OAEnB,EAAE,cAAc,EAAE;AAGzB,qBAAa,GAAI,SAAQ,WAAW;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,oBAAoB,CAAC,MAAM,EAAE,6BAA6B,EAAE,OAAO,CAA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,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,OAAO,EACL,KAAK,+BAA+B,IAAI,+BAA+B,EACvE,KAAK,4BAA4B,IAAI,4BAA4B,EACjE,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
@@ -1,17 +1,35 @@
1
1
  "use strict";
2
2
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Routing = void 0;
4
+ exports.Pzn = void 0;
5
5
  const resource_1 = require("../core/resource.js");
6
6
  const headers_1 = require("../internal/headers.js");
7
7
  const uploads_1 = require("../internal/uploads.js");
8
- class Routing extends resource_1.APIResource {
8
+ class Pzn extends resource_1.APIResource {
9
9
  /**
10
- * Survey Response
10
+ * Submit a survey response for personalized routing setup.
11
+ *
12
+ * This admin endpoint processes survey responses to set up personalized routing
13
+ * configurations for users based on their use case, LLM preferences, and
14
+ * constraints.
15
+ *
16
+ * **Survey Data:**
17
+ *
18
+ * - User information and use case description
19
+ * - Preferred LLM providers and models
20
+ * - Constraint priorities (quality, cost, latency)
21
+ * - Optional prompts and evaluation datasets
22
+ *
23
+ * **File Uploads:**
24
+ *
25
+ * - `prompt_file`: Optional CSV file with prompts
26
+ * - `dataset_file`: Optional CSV file with evaluation dataset
27
+ *
28
+ * **Note:** This is an admin-only endpoint for internal use.
11
29
  *
12
30
  * @example
13
31
  * ```ts
14
- * const response = await client.routing.createSurveyResponse({
32
+ * const response = await client.pzn.submitSurveyResponse({
15
33
  * constraint_priorities: 'constraint_priorities',
16
34
  * email: 'email',
17
35
  * llm_providers: 'llm_providers',
@@ -21,71 +39,10 @@ class Routing extends resource_1.APIResource {
21
39
  * });
22
40
  * ```
23
41
  */
24
- createSurveyResponse(params, options) {
42
+ submitSurveyResponse(params, options) {
25
43
  const { 'x-token': xToken, ...body } = params;
26
44
  return this._client.post('/v2/pzn/surveyResponse', (0, uploads_1.multipartFormRequestOptions)({ body, ...options, headers: (0, headers_1.buildHeaders)([{ 'x-token': xToken }, options?.headers]) }, this._client));
27
45
  }
28
- /**
29
- * Select the optimal LLM to handle your query based on Not Diamond's routing
30
- * algorithm.
31
- *
32
- * This endpoint analyzes your messages and returns the best-suited model from your
33
- * specified providers. The router considers factors like query complexity, model
34
- * capabilities, cost, and latency based on your preferences.
35
- *
36
- * **Key Features:**
37
- *
38
- * - Intelligent routing across multiple LLM providers
39
- * - Support for custom routers trained on your evaluation data
40
- * - Optional cost/latency optimization
41
- * - Function calling support for compatible models
42
- * - Privacy-preserving content hashing
43
- *
44
- * **Usage:**
45
- *
46
- * 1. Pass your messages in OpenAI format (array of objects with 'role' and
47
- * 'content')
48
- * 2. Specify which LLM providers you want to route between
49
- * 3. Optionally provide a preference_id for personalized routing
50
- * 4. Receive a recommended model and session_id
51
- * 5. Use the session_id to submit feedback and improve routing
52
- *
53
- * **Related Endpoints:**
54
- *
55
- * - `POST /v2/preferences/userPreferenceCreate` - Create a preference ID for
56
- * personalized routing
57
- * - `POST /v2/report/metrics/feedback` - Submit feedback on routing decisions
58
- * - `POST /v2/pzn/trainCustomRouter` - Train a custom router on your evaluation
59
- * data
60
- *
61
- * @example
62
- * ```ts
63
- * const response = await client.routing.selectModel({
64
- * llm_providers: [
65
- * { provider: 'openai', model: 'gpt-4o' },
66
- * {
67
- * provider: 'anthropic',
68
- * model: 'claude-3-5-sonnet-20241022',
69
- * },
70
- * { provider: 'google', model: 'gemini-1.5-pro' },
71
- * ],
72
- * messages: [
73
- * {
74
- * role: 'system',
75
- * content: 'You are a helpful assistant.',
76
- * },
77
- * {
78
- * role: 'user',
79
- * content: 'Explain quantum computing in simple terms',
80
- * },
81
- * ],
82
- * });
83
- * ```
84
- */
85
- selectModel(params, options) {
86
- const { type, ...body } = params;
87
- return this._client.post('/v2/modelRouter/modelSelect', { query: { type }, body, ...options });
88
- }
89
46
  /**
90
47
  * Train a custom router on your evaluation data to optimize routing for your
91
48
  * specific use case.
@@ -114,7 +71,7 @@ class Routing extends resource_1.APIResource {
114
71
  * **Example CSV structure:**
115
72
  *
116
73
  * ```
117
- * prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-3-5-sonnet-20241022/score,anthropic/claude-3-5-sonnet-20241022/response
74
+ * prompt,openai/gpt-4o/score,openai/gpt-4o/response,anthropic/claude-sonnet-4-5-20250929/score,anthropic/claude-sonnet-4-5-20250929/response
118
75
  * "Explain quantum computing",0.95,"Quantum computing uses...",0.87,"Quantum computers leverage..."
119
76
  * "Write a Python function",0.82,"def my_function()...",0.91,"Here's a Python function..."
120
77
  * ```
@@ -145,11 +102,11 @@ class Routing extends resource_1.APIResource {
145
102
  *
146
103
  * @example
147
104
  * ```ts
148
- * const response = await client.routing.trainCustomRouter({
105
+ * const response = await client.pzn.trainCustomRouter({
149
106
  * dataset_file: fs.createReadStream('path/to/file'),
150
107
  * language: 'english',
151
108
  * llm_providers:
152
- * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-3-5-sonnet-20241022"}]',
109
+ * '[{"provider": "openai", "model": "gpt-4o"}, {"provider": "anthropic", "model": "claude-sonnet-4-5-20250929"}]',
153
110
  * maximize: true,
154
111
  * prompt_column: 'prompt',
155
112
  * });
@@ -159,5 +116,5 @@ class Routing extends resource_1.APIResource {
159
116
  return this._client.post('/v2/pzn/trainCustomRouter', (0, uploads_1.multipartFormRequestOptions)({ body, ...options }, this._client));
160
117
  }
161
118
  }
162
- exports.Routing = Routing;
163
- //# sourceMappingURL=routing.js.map
119
+ exports.Pzn = Pzn;
120
+ //# sourceMappingURL=pzn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pzn.js","sourceRoot":"","sources":["../src/resources/pzn.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,oDAAmD;AAEnD,oDAAkE;AAElE,MAAa,GAAI,SAAQ,sBAAW;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,oBAAoB,CAAC,MAAqC,EAAE,OAAwB;QAClF,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,wBAAwB,EACxB,IAAA,qCAA2B,EACzB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,EACtF,IAAI,CAAC,OAAO,CACb,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACH,iBAAiB,CACf,IAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB,2BAA2B,EAC3B,IAAA,qCAA2B,EAAC,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAChE,CAAC;IACJ,CAAC;CACF;AA3HD,kBA2HC"}