1.1.4 • Published 12 days ago

@workflowai/workflowai v1.1.4

Weekly downloads
-
License
-
Repository
-
Last release
12 days ago

workflowAI client

Install workflowAI

npm install --save @workflowai/workflowai

Initialize client

import { WorkflowAI } from '@workflowai/workflowai'

const workflowAI = new WorkflowAI({
  apiKey: '...', // optional, defaults to process.env.WORKFLOWAI_API_KEY
})

Compile your task

import { z } from '@workflowai/workflowai'

const checkTextFollowInstructions = await workflowAI.compileTask(
  {
    taskId: 'CheckTextFollowInstructions',
    schema: {
      id: 5,
      input: z.object({
        text: z
          .string()
          .describe(
            'The text to check if it follows the instructions in "instructions"',
          ),
        instructions: z
          .string()
          .describe('The instructions to check if the text follows'),
      }),
      output: z.object({
        isFollowingInstructions: z
          .bool()
          .describe('Whether the "text" follows all the instructions or not'),
        reason: z
          .string()
          .describe('The reason why the text follows or not the instructions'),
      }),
    },
  },
  {
    // Default run configuration is optional if passed when runs are created
    group: {
      id: '...', // Find group IDs in the playground
    },
  },
)

Prepare your task input

Use the TaskInput TypeScript helper to infer the type of a task input. Another helper, TaskOutput, can infer the type of what you can expect as result of a task run.

import { TaskInput } from '@workflowai/workflowai'

const input: TaskInput<typeof checkTextFollowInstructions> = {
  text: 'The capital of France is Barcelona',
  instructions: 'The text must be written in English',
}

Run your task

const output = await checkTextFollowInstructions(input, {
  // Run configuration is optional if defaults were given at task compilation
  group: {
    id: '2',
  },
})

// `output` is of type `TaskOutput<typeof checkTextFollowInstructions>`

console.log(output.isFollowingInstructions) // Boolean, true
console.log(output.reason) // String, "The text is written in English"
1.1.4

12 days ago

1.1.3

17 days ago

1.1.2

19 days ago

1.1.1

30 days ago

1.1.0

1 month ago

1.0.5

1 month ago

1.0.4

1 month ago

1.0.3

1 month ago

1.0.2

1 month ago

1.0.1

1 month ago

1.0.0

1 month ago

0.1.0

1 month ago