@dandori/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.25 • Public • Published

dandori/core

This repository is responsible for generating the task dependency from texts by using AI.

Installation

npm install @dandori/core
yarn add @dandori/core
pnpm add @dandori/core

Usage

import generateDandoriTasks from '@dandori/core';

const source = `
Today's My Tasks
* Send Email to John
* Send Email to Mary
* Report to Boss after sending emails
`;

const tasks = await generateDandoriTasks(source);

Requirements

  • @dandori/core depends on OpenAI API. You need to set OPENAI_API_KEY environment variable.
  • @dandori/core supports to load .env file. Please create .env file and set OPENAI_API_KEY environment variable.

API

generateDandoriTasks

 async function generateDandoriTasks(
  source: string,
  options?: GenerateDandoriTasksOptions,
): Promise<DandoriTask[]> {}

generateDandoriTasks generates the tasks from text with the dependencies by using Open AI GPT.

Parameters

source

The source text to generate the tasks like belows.

const source = `
Today's My Tasks
* Send Email to John
* Send Email to Mary
* Report to Boss after sending emails
`;
options
type GenerateDandoriTasksOptions = {
  chatGPTModel?: ChatGPTFunctionCallModel;
  envFilePath?: string;
  optionalTaskProps?: OptionalTaskPropsOption;
};
  • chatGPTModel

default is gpt-3.5-turbo-0613

The model of OpenAI GPT to generate the tasks which supports function calling.

You can choose gpt-3.5-turbo-0613 or gpt-4-0613 .

  • envFilePath

default is .env

The path of .env file to load environment variables.

  • optionalTaskProps

default is []

The optional task properties to add to the generated tasks.

You can add the optional task properties like belows.

const optionalTaskProps = ["description", "deadline", "assignee", "status"];
// or
// const optionalTaskProps = ["all"];

const tasks = await generateDandoriTasks(source, {
  optionalTaskProps,
});

If you want to know more details, please see Return Value.

Return Value

type DandoriTask = {
  id: string;
  name: string;
  description?: string;
  deadline?: string;
  assignee?: {
    id: string;
    name: string;
  };
  status?: DandoriTaskStatus;
  fromTaskIdList: string[];
}[];

NOTE

You must use optionalTaskProps parameter like description to add the optional task properties to the generated tasks.

  • id

The id of the task. The id is generated automatically.

  • name

The name of the task. The name is generated by AI.

  • description

The description of the task. The description is generated by AI.

  • deadline

The deadline of the task. The deadline is generated by AI.

  • assignee

The assignee of the task. The assignee is generated by AI.

assignee.id is generated automatically.

  • status

The status of the task. The status is todo , doing or done.

  • fromTaskIdList

The list of the task ids which are dependencies of the task.

Please see the example belows.

import generateDandoriTasks from '@dandori/core';

const source = `
Today's My Tasks
* Send Email to John
* Report to Boss after sending emails
`;

const tasks = await generateDandoriTasks(source);
console.log(tasks)

// [
//   {
//     "id": "1",
//     "name": "Send Email to John",
//     "fromTaskIdList": [] 
//   },
//   {
//     "id": "2",
//     "name": "Report to Boss after sending emails",
//     "fromTaskIdList": [
//       "1"
//     ]
//   }
// ]

Q&A

How to get OpenAI API Key?

Please visit https://platform.openai.com/api-keys and sign up.

Readme

Keywords

none

Package Sidebar

Install

npm i @dandori/core

Weekly Downloads

2

Version

0.0.25

License

MIT

Unpacked Size

17.6 kB

Total Files

7

Last publish

Collaborators

  • hiroki0525