🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@workflowai/workflowai

Package Overview
Dependencies
Maintainers
0
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workflowai/workflowai

workflowAI client

1.1.8-alpha.0
npm
Version published
Weekly downloads
460
-17.12%
Maintainers
0
Weekly downloads
 
Created
Source

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"

Keywords

workflowai

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts