@workflowai/code-generator
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -38,4 +38,5 @@ import { JsonSchemaObject } from '@workflowai/schema'; | ||
streamRunTask: GeneratedCode; | ||
importTaskRun: GeneratedCode; | ||
}; | ||
export declare const getPlaygroundSnippets: (config: GetPlaygroundSnippetsConfig) => Promise<GetPlaygroundSnippetsResult>; | ||
export {}; |
@@ -55,5 +55,9 @@ "use strict"; | ||
const taskFunctionName = validVarName(taskName || taskId); | ||
const importRunFunctionName = validVarName(`import ${taskFunctionName} run`); | ||
const _stringifiedInput = JSON.stringify(example.input, null, 2); | ||
const _stringifiedOutput = JSON.stringify(example.output, null, 2); | ||
const beautifiedInput = base64DataToFileDataProvider(_stringifiedInput, fileDataProvider); | ||
const isUsingFileDataProvider = beautifiedInput !== _stringifiedInput; | ||
const beautifiedOutput = base64DataToFileDataProvider(_stringifiedOutput, fileDataProvider); | ||
const isUsingFileDataProvider = beautifiedInput !== _stringifiedInput || | ||
beautifiedOutput !== _stringifiedOutput; | ||
const fileProviderImport = { | ||
@@ -94,3 +98,3 @@ 'fs-promise': 'import { readFile } from "fs/promises"', | ||
${cleanZodDescribe((0, beautify_1.beautifyTypescript)(`const { run: ${taskFunctionName} } = await workflowAI.useTask({ | ||
${cleanZodDescribe((0, beautify_1.beautifyTypescript)(`const { run: ${taskFunctionName}, importRun: ${importRunFunctionName} } = await workflowAI.useTask({ | ||
taskId: "${taskId}", | ||
@@ -146,4 +150,28 @@ schema: { | ||
}, | ||
importTaskRun: { | ||
language: 'typescript', | ||
code: ` | ||
${[ | ||
'import { TaskInput, TaskOutput } from "@workflowai/workflowai"', | ||
isUsingFileDataProvider && fileProviderImport, | ||
] | ||
.filter(Boolean) | ||
.join('\n')} | ||
const input: TaskInput<typeof ${importRunFunctionName}> = ${beautifiedInput} | ||
const output: TaskOutput<typeof ${importRunFunctionName}> = ${beautifiedOutput} | ||
await ${importRunFunctionName}(input, output, { | ||
group: { | ||
properties: { | ||
provider: "openai", | ||
model: "gpt-4o-2024-05-13", | ||
temperature: 0, | ||
} | ||
} | ||
}) | ||
`.trim(), | ||
}, | ||
}; | ||
}; | ||
exports.getPlaygroundSnippets = getPlaygroundSnippets; |
@@ -52,5 +52,9 @@ import { inputSchemaToZod, outputSchemaToZod, } from '@workflowai/schema'; | ||
const taskFunctionName = validVarName(taskName || taskId); | ||
const importRunFunctionName = validVarName(`import ${taskFunctionName} run`); | ||
const _stringifiedInput = JSON.stringify(example.input, null, 2); | ||
const _stringifiedOutput = JSON.stringify(example.output, null, 2); | ||
const beautifiedInput = base64DataToFileDataProvider(_stringifiedInput, fileDataProvider); | ||
const isUsingFileDataProvider = beautifiedInput !== _stringifiedInput; | ||
const beautifiedOutput = base64DataToFileDataProvider(_stringifiedOutput, fileDataProvider); | ||
const isUsingFileDataProvider = beautifiedInput !== _stringifiedInput || | ||
beautifiedOutput !== _stringifiedOutput; | ||
const fileProviderImport = { | ||
@@ -91,3 +95,3 @@ 'fs-promise': 'import { readFile } from "fs/promises"', | ||
${cleanZodDescribe(beautifyTypescript(`const { run: ${taskFunctionName} } = await workflowAI.useTask({ | ||
${cleanZodDescribe(beautifyTypescript(`const { run: ${taskFunctionName}, importRun: ${importRunFunctionName} } = await workflowAI.useTask({ | ||
taskId: "${taskId}", | ||
@@ -143,3 +147,27 @@ schema: { | ||
}, | ||
importTaskRun: { | ||
language: 'typescript', | ||
code: ` | ||
${[ | ||
'import { TaskInput, TaskOutput } from "@workflowai/workflowai"', | ||
isUsingFileDataProvider && fileProviderImport, | ||
] | ||
.filter(Boolean) | ||
.join('\n')} | ||
const input: TaskInput<typeof ${importRunFunctionName}> = ${beautifiedInput} | ||
const output: TaskOutput<typeof ${importRunFunctionName}> = ${beautifiedOutput} | ||
await ${importRunFunctionName}(input, output, { | ||
group: { | ||
properties: { | ||
provider: "openai", | ||
model: "gpt-4o-2024-05-13", | ||
temperature: 0, | ||
} | ||
} | ||
}) | ||
`.trim(), | ||
}, | ||
}; | ||
}; |
@@ -38,2 +38,3 @@ import { JsonSchemaObject } from '@workflowai/schema'; | ||
streamRunTask: GeneratedCode; | ||
importTaskRun: GeneratedCode; | ||
}; | ||
@@ -40,0 +41,0 @@ export declare const getPlaygroundSnippets: (config: GetPlaygroundSnippetsConfig) => Promise<GetPlaygroundSnippetsResult>; |
{ | ||
"name": "@workflowai/code-generator", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "workflowAI code-generator", | ||
@@ -5,0 +5,0 @@ "author": "workflowAI", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
20214
457
0