codemie-sdk 0.1.80 → 0.1.82
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/README.md +78 -2
- package/dist/index.cjs +77 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +77 -57
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -230,8 +230,84 @@ const params: AssistantChatParams = {
|
|
|
230
230
|
};
|
|
231
231
|
const response = await client.assistants.chat("assistant-id", params);
|
|
232
232
|
```
|
|
233
|
+
7. **Utilize structured outputs with Assistant
|
|
234
|
+
Uzing zod objects
|
|
235
|
+
```typescript
|
|
236
|
+
|
|
237
|
+
const ResponseFormat = z.object({
|
|
238
|
+
answer: z.string().describe("The answer to the user's question"),
|
|
239
|
+
followup_question: z
|
|
240
|
+
.string()
|
|
241
|
+
.describe("A followup question the user could ask"),
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const params: AssistantChatParams = {
|
|
245
|
+
text: "Your message here",
|
|
246
|
+
history: [], // Previous conversation messages as ChatMessage[] or string
|
|
247
|
+
// Optional parameters
|
|
248
|
+
stream: false, // Set to true for streaming response
|
|
249
|
+
conversation_id: "optional-conversation-id",
|
|
250
|
+
llm_model: "gpt-4o",
|
|
251
|
+
system_prompt: "Override default system prompt",
|
|
252
|
+
background_task: false,
|
|
253
|
+
content_raw: "", // Raw content if needed
|
|
254
|
+
file_name: "", // For file processing
|
|
255
|
+
top_k: 1,
|
|
256
|
+
metadata: {}, // Additional metadata
|
|
257
|
+
output_schema: ResponseFormat
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const response = await client.assistants.chat(
|
|
261
|
+
"b797be81-5ddb-4649-a445-96bbdde14809",
|
|
262
|
+
params
|
|
263
|
+
);
|
|
264
|
+
// response.generated is object
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
Using JSON Schema in object format
|
|
268
|
+
```typescript
|
|
269
|
+
const schema = {
|
|
270
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
271
|
+
"$id": "https://example.com/product.schema.json",
|
|
272
|
+
"title": "ResponseFormatter",
|
|
273
|
+
"type": "object",
|
|
274
|
+
"properties": {
|
|
275
|
+
"answer": {
|
|
276
|
+
"description": "The answer to the user's question",
|
|
277
|
+
"type": "string"
|
|
278
|
+
},
|
|
279
|
+
"followup_question": {
|
|
280
|
+
"description": "A followup question the user could ask",
|
|
281
|
+
"type": "string"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
"required": ["answer", "followup_question"]
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const params: AssistantChatParams = {
|
|
288
|
+
text: "Your message here",
|
|
289
|
+
history: [], // Previous conversation messages as ChatMessage[] or string
|
|
290
|
+
// Optional parameters
|
|
291
|
+
stream: false, // Set to true for streaming response
|
|
292
|
+
conversation_id: "optional-conversation-id",
|
|
293
|
+
llm_model: "gpt-4o",
|
|
294
|
+
system_prompt: "Override default system prompt",
|
|
295
|
+
background_task: false,
|
|
296
|
+
content_raw: "", // Raw content if needed
|
|
297
|
+
file_name: "", // For file processing
|
|
298
|
+
top_k: 1,
|
|
299
|
+
metadata: {}, // Additional metadata
|
|
300
|
+
output_schema: schema
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const response = await client.assistants.chat(
|
|
304
|
+
"b797be81-5ddb-4649-a445-96bbdde14809",
|
|
305
|
+
params
|
|
306
|
+
);
|
|
307
|
+
// response.generated is object
|
|
308
|
+
```
|
|
233
309
|
|
|
234
|
-
|
|
310
|
+
8. **Work with Prebuilt Assistants**
|
|
235
311
|
```typescript
|
|
236
312
|
// List prebuilt assistants
|
|
237
313
|
const prebuilt = await client.assistants.getPrebuilt();
|
|
@@ -240,7 +316,7 @@ const prebuilt = await client.assistants.getPrebuilt();
|
|
|
240
316
|
const prebuiltAssistant = await client.assistants.getPrebuiltBySlug("assistant-slug");
|
|
241
317
|
```
|
|
242
318
|
|
|
243
|
-
|
|
319
|
+
9. **Get Available Tools**
|
|
244
320
|
```typescript
|
|
245
321
|
const tools = await client.assistants.getTools();
|
|
246
322
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -134,6 +134,10 @@ var AssistantMapper = class {
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
+
// src/services/assistant.ts
|
|
138
|
+
var import_zod2 = require("zod");
|
|
139
|
+
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
140
|
+
|
|
137
141
|
// src/schemas/assistant.ts
|
|
138
142
|
var import_zod = require("zod");
|
|
139
143
|
var AssistantListParamsSchema = import_zod.z.object({
|
|
@@ -223,7 +227,11 @@ var AssistantChatParamsSchema = import_zod.z.object({
|
|
|
223
227
|
top_k: import_zod.z.number().optional(),
|
|
224
228
|
system_prompt: import_zod.z.string().optional(),
|
|
225
229
|
background_task: import_zod.z.boolean().optional(),
|
|
226
|
-
metadata: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
230
|
+
metadata: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
231
|
+
output_schema: import_zod.z.union([
|
|
232
|
+
import_zod.z.custom((val) => val instanceof import_zod.z.ZodType),
|
|
233
|
+
import_zod.z.record(import_zod.z.unknown())
|
|
234
|
+
]).optional()
|
|
227
235
|
}).readonly();
|
|
228
236
|
|
|
229
237
|
// src/utils/http.ts
|
|
@@ -400,7 +408,15 @@ var AssistantService = class {
|
|
|
400
408
|
* Send a chat request to an assistant.
|
|
401
409
|
*/
|
|
402
410
|
async chat(assistantId, _params) {
|
|
403
|
-
|
|
411
|
+
let zodSchema = void 0;
|
|
412
|
+
let params = { ..._params };
|
|
413
|
+
if (params.output_schema && params.output_schema instanceof import_zod2.z.ZodType) {
|
|
414
|
+
zodSchema = params.output_schema;
|
|
415
|
+
params.output_schema = (0, import_zod_to_json_schema.zodToJsonSchema)(zodSchema, {
|
|
416
|
+
definitions: {}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
params = AssistantChatParamsSchema.parse(params);
|
|
404
420
|
const response = await this.api.post(
|
|
405
421
|
`/v1/assistants/${assistantId}/model`,
|
|
406
422
|
params,
|
|
@@ -408,7 +424,11 @@ var AssistantService = class {
|
|
|
408
424
|
responseType: params.stream ? "stream" : void 0
|
|
409
425
|
}
|
|
410
426
|
);
|
|
411
|
-
|
|
427
|
+
const mapped = AssistantMapper.mapBaseModelApiResponse(response);
|
|
428
|
+
if (!params.stream && zodSchema && mapped.generated) {
|
|
429
|
+
mapped.generated = zodSchema.parse(mapped.generated);
|
|
430
|
+
}
|
|
431
|
+
return mapped;
|
|
412
432
|
}
|
|
413
433
|
};
|
|
414
434
|
|
|
@@ -733,35 +753,35 @@ var IntegrationType = {
|
|
|
733
753
|
};
|
|
734
754
|
|
|
735
755
|
// src/schemas/integration.ts
|
|
736
|
-
var
|
|
737
|
-
var IntegrationListParamsSchema =
|
|
738
|
-
setting_type:
|
|
739
|
-
page:
|
|
740
|
-
per_page:
|
|
741
|
-
filters:
|
|
756
|
+
var import_zod3 = require("zod");
|
|
757
|
+
var IntegrationListParamsSchema = import_zod3.z.object({
|
|
758
|
+
setting_type: import_zod3.z.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER),
|
|
759
|
+
page: import_zod3.z.number().default(0),
|
|
760
|
+
per_page: import_zod3.z.number().default(10),
|
|
761
|
+
filters: import_zod3.z.record(import_zod3.z.unknown()).optional()
|
|
742
762
|
}).readonly();
|
|
743
|
-
var IntegrationGetParamsSchema =
|
|
744
|
-
integration_id:
|
|
745
|
-
setting_type:
|
|
763
|
+
var IntegrationGetParamsSchema = import_zod3.z.object({
|
|
764
|
+
integration_id: import_zod3.z.string(),
|
|
765
|
+
setting_type: import_zod3.z.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER)
|
|
746
766
|
}).readonly();
|
|
747
|
-
var IntegrationGetByAliasParamsSchema =
|
|
748
|
-
alias:
|
|
749
|
-
setting_type:
|
|
767
|
+
var IntegrationGetByAliasParamsSchema = import_zod3.z.object({
|
|
768
|
+
alias: import_zod3.z.string(),
|
|
769
|
+
setting_type: import_zod3.z.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER)
|
|
750
770
|
}).readonly();
|
|
751
|
-
var CredentialValueSchema =
|
|
752
|
-
key:
|
|
753
|
-
value:
|
|
771
|
+
var CredentialValueSchema = import_zod3.z.object({
|
|
772
|
+
key: import_zod3.z.string(),
|
|
773
|
+
value: import_zod3.z.unknown()
|
|
754
774
|
});
|
|
755
|
-
var IntegrationCreateParamsSchema =
|
|
756
|
-
credential_type:
|
|
757
|
-
credential_values:
|
|
758
|
-
project_name:
|
|
759
|
-
setting_type:
|
|
760
|
-
alias:
|
|
761
|
-
default:
|
|
762
|
-
project:
|
|
763
|
-
enabled:
|
|
764
|
-
external_id:
|
|
775
|
+
var IntegrationCreateParamsSchema = import_zod3.z.object({
|
|
776
|
+
credential_type: import_zod3.z.enum(Object.values(CredentialTypes)),
|
|
777
|
+
credential_values: import_zod3.z.array(CredentialValueSchema),
|
|
778
|
+
project_name: import_zod3.z.string(),
|
|
779
|
+
setting_type: import_zod3.z.enum([IntegrationType.USER, IntegrationType.PROJECT]).default(IntegrationType.USER),
|
|
780
|
+
alias: import_zod3.z.string().optional(),
|
|
781
|
+
default: import_zod3.z.boolean().optional().default(false),
|
|
782
|
+
project: import_zod3.z.string().optional(),
|
|
783
|
+
enabled: import_zod3.z.boolean().optional().default(true),
|
|
784
|
+
external_id: import_zod3.z.string().optional()
|
|
765
785
|
}).readonly();
|
|
766
786
|
var IntegrationUpdateParamsSchema = IntegrationCreateParamsSchema;
|
|
767
787
|
|
|
@@ -960,7 +980,7 @@ var WorkflowMapper = class {
|
|
|
960
980
|
};
|
|
961
981
|
|
|
962
982
|
// src/schemas/workflow.ts
|
|
963
|
-
var
|
|
983
|
+
var import_zod4 = require("zod");
|
|
964
984
|
|
|
965
985
|
// src/models/workflow.ts
|
|
966
986
|
var WorkflowMode = {
|
|
@@ -977,39 +997,39 @@ var ExecutionStatus = {
|
|
|
977
997
|
};
|
|
978
998
|
|
|
979
999
|
// src/schemas/workflow.ts
|
|
980
|
-
var WorkflowListParamsSchema =
|
|
981
|
-
page:
|
|
982
|
-
per_page:
|
|
983
|
-
projects:
|
|
1000
|
+
var WorkflowListParamsSchema = import_zod4.z.object({
|
|
1001
|
+
page: import_zod4.z.number().default(0),
|
|
1002
|
+
per_page: import_zod4.z.number().default(10),
|
|
1003
|
+
projects: import_zod4.z.array(import_zod4.z.string()).optional()
|
|
984
1004
|
}).readonly();
|
|
985
|
-
var WorkflowCreateParamsSchema =
|
|
986
|
-
project:
|
|
987
|
-
name:
|
|
988
|
-
description:
|
|
989
|
-
yaml_config:
|
|
990
|
-
mode:
|
|
991
|
-
shared:
|
|
992
|
-
icon_url:
|
|
1005
|
+
var WorkflowCreateParamsSchema = import_zod4.z.object({
|
|
1006
|
+
project: import_zod4.z.string(),
|
|
1007
|
+
name: import_zod4.z.string(),
|
|
1008
|
+
description: import_zod4.z.string().optional(),
|
|
1009
|
+
yaml_config: import_zod4.z.string(),
|
|
1010
|
+
mode: import_zod4.z.enum([WorkflowMode.SEQUENTIAL, WorkflowMode.AUTONOMOUS]),
|
|
1011
|
+
shared: import_zod4.z.boolean(),
|
|
1012
|
+
icon_url: import_zod4.z.string().optional()
|
|
993
1013
|
}).readonly();
|
|
994
|
-
var WorkflowUpdateParamsSchema =
|
|
995
|
-
project:
|
|
996
|
-
name:
|
|
997
|
-
description:
|
|
998
|
-
yaml_config:
|
|
999
|
-
mode:
|
|
1000
|
-
shared:
|
|
1001
|
-
icon_url:
|
|
1014
|
+
var WorkflowUpdateParamsSchema = import_zod4.z.object({
|
|
1015
|
+
project: import_zod4.z.string(),
|
|
1016
|
+
name: import_zod4.z.string(),
|
|
1017
|
+
description: import_zod4.z.string().optional(),
|
|
1018
|
+
yaml_config: import_zod4.z.string(),
|
|
1019
|
+
mode: import_zod4.z.enum([WorkflowMode.SEQUENTIAL, WorkflowMode.AUTONOMOUS]).optional(),
|
|
1020
|
+
shared: import_zod4.z.boolean().optional(),
|
|
1021
|
+
icon_url: import_zod4.z.string().optional()
|
|
1002
1022
|
}).readonly();
|
|
1003
|
-
var WorkflowExecutionListParamsSchema =
|
|
1004
|
-
page:
|
|
1005
|
-
per_page:
|
|
1023
|
+
var WorkflowExecutionListParamsSchema = import_zod4.z.object({
|
|
1024
|
+
page: import_zod4.z.number().default(0),
|
|
1025
|
+
per_page: import_zod4.z.number().default(10)
|
|
1006
1026
|
}).readonly();
|
|
1007
|
-
var WorkflowExecutionCreateParamsSchema =
|
|
1008
|
-
user_input:
|
|
1027
|
+
var WorkflowExecutionCreateParamsSchema = import_zod4.z.object({
|
|
1028
|
+
user_input: import_zod4.z.string().default("")
|
|
1009
1029
|
}).readonly();
|
|
1010
|
-
var WorkflowExecutionStateListParamsSchema =
|
|
1011
|
-
page:
|
|
1012
|
-
per_page:
|
|
1030
|
+
var WorkflowExecutionStateListParamsSchema = import_zod4.z.object({
|
|
1031
|
+
page: import_zod4.z.number().default(0),
|
|
1032
|
+
per_page: import_zod4.z.number().default(10)
|
|
1013
1033
|
}).readonly();
|
|
1014
1034
|
|
|
1015
1035
|
// src/services/workflow_execution_state.ts
|