From 5a9950b4e17470f2c17d5cf3208f6b52926fc49a Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 20:57:56 +0100 Subject: [PATCH 01/14] update checklist node definition --- .../adapters/document_check/document_check.ts | 51 ++++-- .../__snapshots__/document_check.test.ts.snap | 58 ++++--- .../document_check/document_check.test.ts | 159 ++++++++++++++++-- .../adapters/document_check/document_check.ts | 76 ++++++++- .../@pufflig/ps-types/src/types/params.ts | 5 +- 5 files changed, 288 insertions(+), 61 deletions(-) diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts index 3a5ed39..8c02a1a 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts @@ -4,7 +4,7 @@ import { NodeConfig } from "@pufflig/ps-types"; export const documentCheckNodeType = "modifier/document_check" as const; export const documentCheck: NodeConfig = { - name: "Document Checklist", + name: "Checklist", description: "Run a checklist on a document.", tags: ["adapter", "document", "text"], status: "stable", @@ -23,9 +23,9 @@ export const documentCheck: NodeConfig = { }, outputs: [ { - id: "result", - name: "Result", - description: "A list, checklist or other information about the document", + id: "checklist", + name: "Checklist", + description: "A checklist of items to run on the document", type: "text", defaultValue: "", }, @@ -43,25 +43,44 @@ export const documentCheck: NodeConfig = { }, }, { - id: "prompt", - name: "Prompt", - description: "Prompt to check the document with", + id: "instructions", + name: "Instructions", + description: "Instructions for the AI", type: "text", - defaultValue: `Extract information in the document below and insert them in the csv table, don't overwrite existing values and keep things empty if you cannot find information in the document:\n\nTABLE EXAMPLE:\ncharacters, age\nmickey mouse, 10\ndonald duck, -\n\nTABLE:\n{{table}}\n\nDOCUMENT:\n{{document}}\n\nTABLE:\n`, - }, - { - id: "table", - name: "Table", - description: "The list, table or checklist to parse the document with.", - type: "text", - defaultValue: "", + defaultValue: `Run the checklist below on the document.`, }, { id: "document", name: "Document", - description: "Document to be processed", + description: "Document to be checked", type: "text", defaultValue: "", }, + { + id: "checklist", + name: "Checklist", + description: "The checklist to run on the document", + type: "object", + editableSchema: true, + defaultValue: [], + }, + { + id: "format", + name: "Format", + description: "The format in which to return the cheklist results", + type: "selection", + defaultValue: "markdown", + options: [ + { id: "csv", name: "CSV" }, + { id: "markdown", name: "Markdown" }, + ], + }, + { + id: "fields", + name: "Fields", + description: "Custom fields to include in the output for each checklist item", + type: "list", + defaultValue: ["ok"], + }, ], }; diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap b/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap index 29f261b..e9519f5 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap @@ -4,7 +4,7 @@ exports[`documentCheck should extract variables correctly 1`] = ` [ { "defaultValue": { - "modelId": "test_model", + "modelId": "gpt-3.5-turbo-instruct", "parameters": {}, }, "definition": { @@ -213,32 +213,52 @@ exports[`documentCheck should extract variables correctly 1`] = ` "type": "model", }, { - "defaultValue": "Hello, {{myVariable}}!", - "description": "Prompt to check the document with", - "id": "prompt", - "name": "Prompt", + "defaultValue": "Run the checklist below on the document.", + "description": "Instructions for the AI", + "id": "instructions", + "name": "Instructions", "type": "text", }, { - "defaultValue": "test_table", - "description": "The list, table or checklist to parse the document with.", - "id": "table", - "name": "Table", - "type": "text", - }, - { - "defaultValue": "This is a test document.", - "description": "Document to be processed", + "defaultValue": "", + "description": "Document to be checked", "id": "document", "name": "Document", "type": "text", }, { - "defaultValue": "myValue", - "description": "", - "id": "myVariable", - "name": "myVariable", - "type": "text", + "defaultValue": [], + "description": "The checklist to run on the document", + "editableSchema": true, + "id": "checklist", + "name": "Checklist", + "type": "object", + }, + { + "defaultValue": "markdown", + "description": "The format in which to return the cheklist results", + "id": "format", + "name": "Format", + "options": [ + { + "id": "csv", + "name": "CSV", + }, + { + "id": "markdown", + "name": "Markdown", + }, + ], + "type": "selection", + }, + { + "defaultValue": [ + "ok", + ], + "description": "Custom fields to include in the output for each checklist item", + "id": "fields", + "name": "Fields", + "type": "list", }, ] `; diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts index aeb34f2..8378d81 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts @@ -1,5 +1,5 @@ -import { execute, getInputDefinition, LLMCompletionInput } from "./document_check"; import axios from "axios"; +import { execute, getInputDefinition, LLMCompletionInput } from "./document_check"; jest.mock("axios"); @@ -8,15 +8,58 @@ describe("documentCheck", () => { jest.resetAllMocks(); }); - it("should return the completion string", async () => { + it("should return the resulting checklist", async () => { const input: LLMCompletionInput = { - prompt: "Hello, world!", + instructions: "Hello, world!", model: { modelId: "test_model", parameters: {}, }, document: "This is a test document.", - table: "test_table", + checklist: [ + { id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }, + ], + fields: ["ok"], + format: "csv", + }; + + const expectedOutput = { result: "mock checklist" }; + const mockedAxiosResponse = { data: expectedOutput }; + (axios.post as jest.MockedFunction).mockResolvedValueOnce(mockedAxiosResponse); + + const output = await execute(input); + + expect(output).toEqual({ checklist: expectedOutput.result }); + expect(axios.post).toHaveBeenCalledTimes(1); + }); + + it("should parse input variables", async () => { + const input: LLMCompletionInput = { + instructions: "Hello, {{world}}! Run a checklist on the following document: {{document}}", + model: { + modelId: "test_model", + parameters: {}, + }, + document: "This is a test document.", + checklist: [ + { + id: "is_greeting", + defaultValue: "is the text a greeting?", + type: "text", + name: "is_greeting", + description: "", + }, + { + id: "is_formal", + defaultValue: "is the greeting formal?", + type: "text", + name: "is_formal", + description: "", + }, + ], + fields: ["ok"], + format: "csv", + world: "test", }; const expectedOutput = { result: "This is a test completion." }; @@ -25,20 +68,70 @@ describe("documentCheck", () => { const output = await execute(input); - expect(output).toEqual(expectedOutput); + expect(output).toEqual({ checklist: expectedOutput.result }); expect(axios.post).toHaveBeenCalledTimes(1); + expect(axios.post).toHaveBeenCalledWith( + expect.any(String), + { + document: "This is a test document.", + format: `check,ok +is_greeting, +is_formal,`, + modelId: "test_model", + options: { + cache: true, + track: true, + }, + parameters: {}, + prompt: `Hello, test! Run a checklist on the following document: {{document}} + +CHECKLIST DESCRIPTION: +check,description +is_greeting, is the text a greeting? +is_formal, is the greeting formal? + +CHECKLIST FORMAT: +{{table}} + +CHECKLIST IN CSV FORMAT: +`, + }, + { + headers: { + Authorization: "Bearer undefined", + "Content-Type": "application/json", + }, + } + ); }); it("should parse input variables", async () => { const input: LLMCompletionInput = { - prompt: "Hello, {{myVariable}}!", + instructions: "Hello, {{world}}! Run a checklist on the following document: {{document}}", model: { modelId: "test_model", parameters: {}, }, document: "This is a test document.", - table: "test_table", - myVariable: "myValue", + checklist: [ + { + id: "is_greeting", + defaultValue: "is the text a greeting?", + type: "text", + name: "is_greeting", + description: "", + }, + { + id: "is_formal", + defaultValue: "is the greeting formal?", + type: "text", + name: "is_formal", + description: "", + }, + ], + fields: ["ok"], + format: "markdown", + world: "test", }; const expectedOutput = { result: "This is a test completion." }; @@ -47,20 +140,33 @@ describe("documentCheck", () => { const output = await execute(input); - expect(output).toEqual(expectedOutput); + expect(output).toEqual({ checklist: expectedOutput.result }); expect(axios.post).toHaveBeenCalledTimes(1); expect(axios.post).toHaveBeenCalledWith( expect.any(String), { document: "This is a test document.", - format: "test_table", + format: `|check|ok| +|is_greeting|| +|is_formal||`, modelId: "test_model", options: { cache: true, track: true, }, parameters: {}, - prompt: "Hello, myValue!", + prompt: `Hello, test! Run a checklist on the following document: {{document}} + +CHECKLIST DESCRIPTION: +|check|description| +|is_greeting|is the text a greeting?| +|is_formal|is the greeting formal?| + +CHECKLIST FORMAT: +{{table}} + +CHECKLIST IN MARKDOWN FORMAT: +`, }, { headers: { @@ -73,14 +179,31 @@ describe("documentCheck", () => { it("should extract variables correctly", async () => { const output = getInputDefinition({ - prompt: "Hello, {{myVariable}}!", + instructions: "Hello, {{world}}!", model: { modelId: "test_model", parameters: {}, }, document: "This is a test document.", - table: "test_table", - myVariable: "myValue", + checklist: [ + { + id: "is_greeting", + defaultValue: "is the text a greeting?", + type: "text", + name: "is_greeting", + description: "", + }, + { + id: "is_formal", + defaultValue: "is the greeting formal?", + type: "text", + name: "is_formal", + description: "", + }, + ], + fields: ["ok"], + format: "csv", + world: "test", }); expect(output).toMatchSnapshot(); @@ -88,13 +211,17 @@ describe("documentCheck", () => { it("should throw an error if the API call fails", async () => { const input: LLMCompletionInput = { - prompt: "Hello, world!", + instructions: "Hello, world!", model: { modelId: "test_model", parameters: {}, }, document: "This is a test document.", - table: "test_table", + checklist: [ + { id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }, + ], + fields: ["ok"], + format: "csv", }; const expectedError = new Error("API call failed."); diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts index 63b6c7e..8fc1041 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts @@ -1,36 +1,96 @@ import { nodeTypes, nodes } from "@pufflig/ps-nodes-config"; import { refineCompletion } from "@pufflig/ps-sdk"; -import { Execute, GetInputDefinition, ModelValue, Node, Param } from "@pufflig/ps-types"; +import { Execute, GetInputDefinition, ModelValue, Node, ObjectDefinition, Param } from "@pufflig/ps-types"; import { getPromptStudioKey } from "../../utils/getPromptStudioKey"; import { extractVariables } from "../../utils/extractVariables"; import Mustache from "mustache"; export interface LLMCompletionInput { - prompt: string; + instructions: string; model: ModelValue; document: string; - table: string; + checklist: ObjectDefinition; + format: string; + fields: string[]; [key: string]: any; } export interface LLMCompletionOutput { - result: string; + checklist: string; } +const makeCSVChecklist = (checklist: ObjectDefinition, fields: string[]) => { + const header = "check," + fields.join(","); + const rows = checklist.map((row) => { + return row.id + "," + fields.map(() => "").join(","); + }); + + return `${header}\n${rows.join("\n")}`; +}; + +const makeMarkdownChecklist = (checklist: ObjectDefinition, fields: string[]) => { + const header = "|check|" + fields.join("|") + "|"; + const rows = checklist.map((row) => { + return "|" + row.id + "|" + fields.map(() => "").join("|") + "|"; + }); + + return `${header}\n${rows.join("\n")}`; +}; + +const makeCSVDescription = (checklist: ObjectDefinition) => { + const header = "check,description"; + const rows = checklist.map((item) => { + return `${item.id}, ${(item.defaultValue as string).replace(/,/g, "")}`; + }); + return `${header}\n${rows.join("\n")}`; +}; + +const makeMarkdownDescription = (checklist: ObjectDefinition) => { + const header = "|check|description|"; + const rows = checklist.map((item) => { + return `|${item.id}|${(item.defaultValue as string).replace(/,/g, "")}|`; + }); + return `${header}\n${rows.join("\n")}`; +}; + export const execute: Execute = async (input, options = {}) => { - const { prompt, model, document, table, ...variables } = input; + const { instructions, model, document, checklist, fields, format, ...variables } = input; const { modelId, parameters } = model; const { globals } = options; + const isCSV = format === "csv"; + + // checklist format + const checkListFormat = isCSV ? makeCSVChecklist(checklist, fields) : makeMarkdownChecklist(checklist, fields); + + // checklist description + const description = isCSV ? makeCSVDescription(checklist) : makeMarkdownDescription(checklist); + + // TODO: move into the API + const instructionsWithChecklist = `${instructions} + +CHECKLIST DESCRIPTION: +${description} + +CHECKLIST FORMAT: +{{table}} + +CHECKLIST IN ${format.toUpperCase()} FORMAT: +`; + // render the prompt without overwriting the document and table variables - const renderedPrompt = Mustache.render(prompt, { ...variables, document: "{{document}}", table: "{{table}}" }); + const renderedPrompt = Mustache.render(instructionsWithChecklist, { + ...variables, + document: "{{document}}", + table: "{{table}}", + }); const { result } = await refineCompletion({ apiKey: getPromptStudioKey(globals || {}), modelId, prompt: renderedPrompt, document: document, - format: table, + format: checkListFormat, parameters, config: globals, options: { @@ -40,7 +100,7 @@ export const execute: Execute = async ( }); return { - result: result || "", + checklist: result || "", }; }; diff --git a/packages/@pufflig/ps-types/src/types/params.ts b/packages/@pufflig/ps-types/src/types/params.ts index ae5c845..d687a5d 100644 --- a/packages/@pufflig/ps-types/src/types/params.ts +++ b/packages/@pufflig/ps-types/src/types/params.ts @@ -86,7 +86,8 @@ export interface ObjectParam extends BaseParam { export interface ListParam extends BaseParam { type: "list"; - defaultValue: []; + files?: boolean; + defaultValue: string[]; } export interface VectorParam extends BaseParam { @@ -102,7 +103,7 @@ export type ParamValue = | Chat | ChatMessage | null - | (NumberParam | TextParam)[] + | ObjectDefinition | Array | Array; From c9b8655fdc6f794141a797ea4740b008e42079c6 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 20:58:33 +0100 Subject: [PATCH 02/14] v0.24.0 --- lerna.json | 2 +- package-lock.json | 30 +++++++++---------- packages/@pufflig/ps-chains/package.json | 4 +-- packages/@pufflig/ps-models/package.json | 4 +-- .../@pufflig/ps-nodes-config/package.json | 6 ++-- packages/@pufflig/ps-nodes/package.json | 10 +++---- packages/@pufflig/ps-sdk/package.json | 4 +-- packages/@pufflig/ps-types/package.json | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index dbaf780..7b7de75 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.23.2" + "version": "0.24.0" } diff --git a/package-lock.json b/package-lock.json index e1b9071..8069bc7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21240,14 +21240,14 @@ } }, "packages/@pufflig/ps-chains": { - "version": "0.23.1", + "version": "0.24.0", "license": "MIT", "dependencies": { "mustache": "^4.2.0", "pino": "^8.15.0" }, "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", @@ -21291,23 +21291,23 @@ } }, "packages/@pufflig/ps-models": { - "version": "0.23.2", + "version": "0.24.0", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" } }, "packages/@pufflig/ps-nodes": { - "version": "0.23.2", + "version": "0.24.0", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.23.2", - "@pufflig/ps-nodes-config": "^0.23.2", - "@pufflig/ps-sdk": "^0.23.2", + "@pufflig/ps-models": "^0.24.0", + "@pufflig/ps-nodes-config": "^0.24.0", + "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", @@ -21316,7 +21316,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -21329,13 +21329,13 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.23.2", + "version": "0.24.0", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.23.2" + "@pufflig/ps-models": "^0.24.0" }, "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", @@ -21866,10 +21866,10 @@ } }, "packages/@pufflig/ps-sdk": { - "version": "0.23.2", + "version": "0.24.0", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.23.2", + "@pufflig/ps-models": "^0.24.0", "axios": "^1.5.0" }, "devDependencies": { @@ -21904,7 +21904,7 @@ } }, "packages/@pufflig/ps-types": { - "version": "0.23.1", + "version": "0.24.0", "license": "MIT" }, "websites/blog": { diff --git a/packages/@pufflig/ps-chains/package.json b/packages/@pufflig/ps-chains/package.json index 08e21f2..89fe666 100644 --- a/packages/@pufflig/ps-chains/package.json +++ b/packages/@pufflig/ps-chains/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-chains", - "version": "0.23.1", + "version": "0.24.0", "license": "MIT", "main": "./dist/ps-chains.umd.js", "module": "./dist/ps-chains.es.js", @@ -16,7 +16,7 @@ "test": "jest" }, "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", diff --git a/packages/@pufflig/ps-models/package.json b/packages/@pufflig/ps-models/package.json index c5bf39c..e8a3dd4 100644 --- a/packages/@pufflig/ps-models/package.json +++ b/packages/@pufflig/ps-models/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-models", "private": false, - "version": "0.23.2", + "version": "0.24.0", "description": "Configuration of models used in Prompt Studio", "files": [ "dist" @@ -16,7 +16,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index 5199448..88f0d99 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.23.2", + "version": "0.24.0", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" @@ -16,10 +16,10 @@ "author": "Pufflig AB", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.23.2" + "@pufflig/ps-models": "^0.24.0" }, "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 69d863c..558d3d4 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.23.2", + "version": "0.24.0", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -17,7 +17,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.23.1", + "@pufflig/ps-types": "^0.24.0", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -33,9 +33,9 @@ }, "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.23.2", - "@pufflig/ps-nodes-config": "^0.23.2", - "@pufflig/ps-sdk": "^0.23.2", + "@pufflig/ps-models": "^0.24.0", + "@pufflig/ps-nodes-config": "^0.24.0", + "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", diff --git a/packages/@pufflig/ps-sdk/package.json b/packages/@pufflig/ps-sdk/package.json index 330fdb2..ae2735e 100644 --- a/packages/@pufflig/ps-sdk/package.json +++ b/packages/@pufflig/ps-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-sdk", - "version": "0.23.2", + "version": "0.24.0", "license": "MIT", "main": "./dist/ps-sdk.umd.js", "module": "./dist/ps-sdk.es.js", @@ -21,7 +21,7 @@ "vite-plugin-dts": "^3.5.3" }, "dependencies": { - "@pufflig/ps-models": "^0.23.2", + "@pufflig/ps-models": "^0.24.0", "axios": "^1.5.0" }, "gitHead": "534ff07d186327e38133c0c14a5badd04ced0a9c" diff --git a/packages/@pufflig/ps-types/package.json b/packages/@pufflig/ps-types/package.json index e470da6..113e614 100644 --- a/packages/@pufflig/ps-types/package.json +++ b/packages/@pufflig/ps-types/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-types", - "version": "0.23.1", + "version": "0.24.0", "description": "Typescript definitions for Prompt Studio", "main": "src/index.ts", "author": "Pufflig AB", From 2ae1ad590387a3da4247d538f88c9acd9aba3909 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:09:28 +0100 Subject: [PATCH 03/14] improvements to the checklist node --- .../src/adapters/document_check/document_check.ts | 14 +++++++------- .../src/adapters/document_check/document_check.ts | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts index 8c02a1a..b6cbf9c 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts @@ -64,6 +64,13 @@ export const documentCheck: NodeConfig = { editableSchema: true, defaultValue: [], }, + { + id: "fields", + name: "Fields", + description: "Custom fields to include in the output for each checklist item", + type: "list", + defaultValue: ["ok (yes/no)"], + }, { id: "format", name: "Format", @@ -75,12 +82,5 @@ export const documentCheck: NodeConfig = { { id: "markdown", name: "Markdown" }, ], }, - { - id: "fields", - name: "Fields", - description: "Custom fields to include in the output for each checklist item", - type: "list", - defaultValue: ["ok"], - }, ], }; diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts index 8fc1041..b3bba1e 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts @@ -68,6 +68,8 @@ export const execute: Execute = async ( // TODO: move into the API const instructionsWithChecklist = `${instructions} +DOCUMENT: +{{document}} CHECKLIST DESCRIPTION: ${description} @@ -75,8 +77,8 @@ ${description} CHECKLIST FORMAT: {{table}} -CHECKLIST IN ${format.toUpperCase()} FORMAT: -`; +Return only the CHECKLIST IN ${format.toUpperCase()} FORMAT: +${isCSV ? "check," : "|check|"}`; // render the prompt without overwriting the document and table variables const renderedPrompt = Mustache.render(instructionsWithChecklist, { From 6f0f8280af80735012f3ac81becb75162a4cfc11 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:10:24 +0100 Subject: [PATCH 04/14] v0.24.1 --- lerna.json | 2 +- package-lock.json | 6 +++--- packages/@pufflig/ps-nodes-config/package.json | 2 +- packages/@pufflig/ps-nodes/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 7b7de75..8cd9c01 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.0" + "version": "0.24.1" } diff --git a/package-lock.json b/package-lock.json index 8069bc7..6ce77e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21301,12 +21301,12 @@ } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.0", + "version": "0.24.1", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.0", + "@pufflig/ps-nodes-config": "^0.24.1", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", @@ -21329,7 +21329,7 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.24.0", + "version": "0.24.1", "license": "MIT", "dependencies": { "@pufflig/ps-models": "^0.24.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index 88f0d99..350e4c3 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.24.0", + "version": "0.24.1", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 558d3d4..97c29c2 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.0", + "version": "0.24.1", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -34,7 +34,7 @@ "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.0", + "@pufflig/ps-nodes-config": "^0.24.1", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", From 840cd5f99653af3f9575d983a312d8c662e145f3 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:11:44 +0100 Subject: [PATCH 05/14] rename checklist input --- .../src/adapters/document_check/document_check.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts index b6cbf9c..491fda0 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts @@ -57,8 +57,8 @@ export const documentCheck: NodeConfig = { defaultValue: "", }, { - id: "checklist", - name: "Checklist", + id: "checks", + name: "Checks", description: "The checklist to run on the document", type: "object", editableSchema: true, From 2af277489099ff72283858afd3024c33667eb165 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:12:56 +0100 Subject: [PATCH 06/14] v0.24.2 --- lerna.json | 2 +- package-lock.json | 6 +++--- packages/@pufflig/ps-nodes-config/package.json | 2 +- packages/@pufflig/ps-nodes/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 8cd9c01..81a662b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.1" + "version": "0.24.2" } diff --git a/package-lock.json b/package-lock.json index 6ce77e3..a5746e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21301,12 +21301,12 @@ } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.1", + "version": "0.24.2", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.1", + "@pufflig/ps-nodes-config": "^0.24.2", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", @@ -21329,7 +21329,7 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.24.1", + "version": "0.24.2", "license": "MIT", "dependencies": { "@pufflig/ps-models": "^0.24.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index 350e4c3..a840a15 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.24.1", + "version": "0.24.2", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 97c29c2..578efad 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.1", + "version": "0.24.2", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -34,7 +34,7 @@ "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.1", + "@pufflig/ps-nodes-config": "^0.24.2", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", From 431262ad7080aa105c203a7155e6c3be48896adb Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:40:02 +0100 Subject: [PATCH 07/14] fix param name --- .../src/adapters/document_check/document_check.ts | 2 +- .../src/adapters/document_check/document_check.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts index 491fda0..5efb98b 100644 --- a/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes-config/src/adapters/document_check/document_check.ts @@ -47,7 +47,7 @@ export const documentCheck: NodeConfig = { name: "Instructions", description: "Instructions for the AI", type: "text", - defaultValue: `Run the checklist below on the document.`, + defaultValue: ``, }, { id: "document", diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts index b3bba1e..fe56ef7 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts @@ -9,7 +9,7 @@ export interface LLMCompletionInput { instructions: string; model: ModelValue; document: string; - checklist: ObjectDefinition; + checks: ObjectDefinition; format: string; fields: string[]; [key: string]: any; @@ -47,24 +47,24 @@ const makeCSVDescription = (checklist: ObjectDefinition) => { const makeMarkdownDescription = (checklist: ObjectDefinition) => { const header = "|check|description|"; - const rows = checklist.map((item) => { + const rows = (checklist || []).map((item) => { return `|${item.id}|${(item.defaultValue as string).replace(/,/g, "")}|`; }); return `${header}\n${rows.join("\n")}`; }; export const execute: Execute = async (input, options = {}) => { - const { instructions, model, document, checklist, fields, format, ...variables } = input; + const { instructions, model, document, checks, fields, format, ...variables } = input; const { modelId, parameters } = model; const { globals } = options; const isCSV = format === "csv"; // checklist format - const checkListFormat = isCSV ? makeCSVChecklist(checklist, fields) : makeMarkdownChecklist(checklist, fields); + const checkListFormat = isCSV ? makeCSVChecklist(checks, fields) : makeMarkdownChecklist(checks, fields); // checklist description - const description = isCSV ? makeCSVDescription(checklist) : makeMarkdownDescription(checklist); + const description = isCSV ? makeCSVDescription(checks) : makeMarkdownDescription(checks); // TODO: move into the API const instructionsWithChecklist = `${instructions} From 04022c1129f51957834d62eec9b02b7e6ea8bbc7 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:40:24 +0100 Subject: [PATCH 08/14] v0.24.3 --- lerna.json | 2 +- package-lock.json | 6 +++--- packages/@pufflig/ps-nodes-config/package.json | 2 +- packages/@pufflig/ps-nodes/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lerna.json b/lerna.json index 81a662b..2768d82 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.2" + "version": "0.24.3" } diff --git a/package-lock.json b/package-lock.json index a5746e4..bad1ffb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21301,12 +21301,12 @@ } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.2", + "version": "0.24.3", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.2", + "@pufflig/ps-nodes-config": "^0.24.3", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", @@ -21329,7 +21329,7 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.24.2", + "version": "0.24.3", "license": "MIT", "dependencies": { "@pufflig/ps-models": "^0.24.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index a840a15..55e302a 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.24.2", + "version": "0.24.3", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 578efad..b659be8 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.2", + "version": "0.24.3", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -34,7 +34,7 @@ "dependencies": { "@dqbd/tiktoken": "^1.0.7", "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.2", + "@pufflig/ps-nodes-config": "^0.24.3", "@pufflig/ps-sdk": "^0.24.0", "axios": "^1.6.2", "langchain": "^0.0.193", From 59216403974a42494cc718a5e48974faf4b40f73 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:41:43 +0100 Subject: [PATCH 09/14] fix types --- .../adapters/document_check/document_check.test.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts index 8378d81..1fdce0a 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts @@ -16,9 +16,7 @@ describe("documentCheck", () => { parameters: {}, }, document: "This is a test document.", - checklist: [ - { id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }, - ], + checks: [{ id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }], fields: ["ok"], format: "csv", }; @@ -41,7 +39,7 @@ describe("documentCheck", () => { parameters: {}, }, document: "This is a test document.", - checklist: [ + checks: [ { id: "is_greeting", defaultValue: "is the text a greeting?", @@ -113,7 +111,7 @@ CHECKLIST IN CSV FORMAT: parameters: {}, }, document: "This is a test document.", - checklist: [ + checks: [ { id: "is_greeting", defaultValue: "is the text a greeting?", @@ -185,7 +183,7 @@ CHECKLIST IN MARKDOWN FORMAT: parameters: {}, }, document: "This is a test document.", - checklist: [ + checks: [ { id: "is_greeting", defaultValue: "is the text a greeting?", @@ -217,9 +215,7 @@ CHECKLIST IN MARKDOWN FORMAT: parameters: {}, }, document: "This is a test document.", - checklist: [ - { id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }, - ], + checks: [{ id: "is_greeting", defaultValue: "test_table", type: "text", name: "is_greeting", description: "" }], fields: ["ok"], format: "csv", }; From 53f54b6d4d0a0a8714ff9ddc18f522730cfaf61b Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:41:59 +0100 Subject: [PATCH 10/14] v0.24.4 --- lerna.json | 2 +- package-lock.json | 2 +- packages/@pufflig/ps-nodes/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lerna.json b/lerna.json index 2768d82..ed21905 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.3" + "version": "0.24.4" } diff --git a/package-lock.json b/package-lock.json index bad1ffb..49b9219 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21301,7 +21301,7 @@ } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.3", + "version": "0.24.4", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index b659be8..3bfab13 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.3", + "version": "0.24.4", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" From c51628c8393d855285f8f0b35afaf36bfd241e7b Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Thu, 23 Nov 2023 22:50:25 +0100 Subject: [PATCH 11/14] v0.24.5 --- lerna.json | 2 +- package-lock.json | 30 +++++++++---------- packages/@pufflig/ps-chains/package.json | 4 +-- packages/@pufflig/ps-models/package.json | 4 +-- .../@pufflig/ps-nodes-config/package.json | 6 ++-- packages/@pufflig/ps-nodes/package.json | 10 +++---- packages/@pufflig/ps-sdk/package.json | 4 +-- packages/@pufflig/ps-types/package.json | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index ed21905..27c7b31 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.4" + "version": "0.24.5" } diff --git a/package-lock.json b/package-lock.json index 49b9219..876c854 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21240,14 +21240,14 @@ } }, "packages/@pufflig/ps-chains": { - "version": "0.24.0", + "version": "0.24.5", "license": "MIT", "dependencies": { "mustache": "^4.2.0", "pino": "^8.15.0" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", @@ -21291,23 +21291,23 @@ } }, "packages/@pufflig/ps-models": { - "version": "0.24.0", + "version": "0.24.5", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.4", + "version": "0.24.5", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.3", - "@pufflig/ps-sdk": "^0.24.0", + "@pufflig/ps-models": "^0.24.5", + "@pufflig/ps-nodes-config": "^0.24.5", + "@pufflig/ps-sdk": "^0.24.5", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", @@ -21316,7 +21316,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -21329,13 +21329,13 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.24.3", + "version": "0.24.5", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.0" + "@pufflig/ps-models": "^0.24.5" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", @@ -21866,10 +21866,10 @@ } }, "packages/@pufflig/ps-sdk": { - "version": "0.24.0", + "version": "0.24.5", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.0", + "@pufflig/ps-models": "^0.24.5", "axios": "^1.5.0" }, "devDependencies": { @@ -21904,7 +21904,7 @@ } }, "packages/@pufflig/ps-types": { - "version": "0.24.0", + "version": "0.24.5", "license": "MIT" }, "websites/blog": { diff --git a/packages/@pufflig/ps-chains/package.json b/packages/@pufflig/ps-chains/package.json index 89fe666..f8431c7 100644 --- a/packages/@pufflig/ps-chains/package.json +++ b/packages/@pufflig/ps-chains/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-chains", - "version": "0.24.0", + "version": "0.24.5", "license": "MIT", "main": "./dist/ps-chains.umd.js", "module": "./dist/ps-chains.es.js", @@ -16,7 +16,7 @@ "test": "jest" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", diff --git a/packages/@pufflig/ps-models/package.json b/packages/@pufflig/ps-models/package.json index e8a3dd4..34ba190 100644 --- a/packages/@pufflig/ps-models/package.json +++ b/packages/@pufflig/ps-models/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-models", "private": false, - "version": "0.24.0", + "version": "0.24.5", "description": "Configuration of models used in Prompt Studio", "files": [ "dist" @@ -16,7 +16,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index 55e302a..f0c1070 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.24.3", + "version": "0.24.5", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" @@ -16,10 +16,10 @@ "author": "Pufflig AB", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.0" + "@pufflig/ps-models": "^0.24.5" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 3bfab13..67e3cdf 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.4", + "version": "0.24.5", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -17,7 +17,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.0", + "@pufflig/ps-types": "^0.24.5", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -33,9 +33,9 @@ }, "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.24.0", - "@pufflig/ps-nodes-config": "^0.24.3", - "@pufflig/ps-sdk": "^0.24.0", + "@pufflig/ps-models": "^0.24.5", + "@pufflig/ps-nodes-config": "^0.24.5", + "@pufflig/ps-sdk": "^0.24.5", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", diff --git a/packages/@pufflig/ps-sdk/package.json b/packages/@pufflig/ps-sdk/package.json index ae2735e..de2e6bd 100644 --- a/packages/@pufflig/ps-sdk/package.json +++ b/packages/@pufflig/ps-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-sdk", - "version": "0.24.0", + "version": "0.24.5", "license": "MIT", "main": "./dist/ps-sdk.umd.js", "module": "./dist/ps-sdk.es.js", @@ -21,7 +21,7 @@ "vite-plugin-dts": "^3.5.3" }, "dependencies": { - "@pufflig/ps-models": "^0.24.0", + "@pufflig/ps-models": "^0.24.5", "axios": "^1.5.0" }, "gitHead": "534ff07d186327e38133c0c14a5badd04ced0a9c" diff --git a/packages/@pufflig/ps-types/package.json b/packages/@pufflig/ps-types/package.json index 113e614..5d3f236 100644 --- a/packages/@pufflig/ps-types/package.json +++ b/packages/@pufflig/ps-types/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-types", - "version": "0.24.0", + "version": "0.24.5", "description": "Typescript definitions for Prompt Studio", "main": "src/index.ts", "author": "Pufflig AB", From b7aab914654cfbc48b4e2d5a94021973065d7fba Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Fri, 24 Nov 2023 00:21:45 +0100 Subject: [PATCH 12/14] fix prompt --- .../ps-nodes/src/adapters/document_check/document_check.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts index fe56ef7..5fa01bc 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts @@ -74,11 +74,10 @@ DOCUMENT: CHECKLIST DESCRIPTION: ${description} -CHECKLIST FORMAT: +TABLE FORMAT: {{table}} -Return only the CHECKLIST IN ${format.toUpperCase()} FORMAT: -${isCSV ? "check," : "|check|"}`; +Return only the TABLE IN ${format.toUpperCase()} FORMAT`; // render the prompt without overwriting the document and table variables const renderedPrompt = Mustache.render(instructionsWithChecklist, { From 6875935400f378b343b809813cfc1913c89357d8 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Fri, 24 Nov 2023 00:22:07 +0100 Subject: [PATCH 13/14] v0.24.6 --- lerna.json | 2 +- package-lock.json | 30 +++++++++---------- packages/@pufflig/ps-chains/package.json | 4 +-- packages/@pufflig/ps-models/package.json | 4 +-- .../@pufflig/ps-nodes-config/package.json | 6 ++-- packages/@pufflig/ps-nodes/package.json | 10 +++---- packages/@pufflig/ps-sdk/package.json | 4 +-- packages/@pufflig/ps-types/package.json | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index 27c7b31..2947a5b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.24.5" + "version": "0.24.6" } diff --git a/package-lock.json b/package-lock.json index 876c854..baef853 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21240,14 +21240,14 @@ } }, "packages/@pufflig/ps-chains": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "dependencies": { "mustache": "^4.2.0", "pino": "^8.15.0" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", @@ -21291,23 +21291,23 @@ } }, "packages/@pufflig/ps-models": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" } }, "packages/@pufflig/ps-nodes": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.24.5", - "@pufflig/ps-nodes-config": "^0.24.5", - "@pufflig/ps-sdk": "^0.24.5", + "@pufflig/ps-models": "^0.24.6", + "@pufflig/ps-nodes-config": "^0.24.6", + "@pufflig/ps-sdk": "^0.24.6", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", @@ -21316,7 +21316,7 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -21329,13 +21329,13 @@ } }, "packages/@pufflig/ps-nodes-config": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.5" + "@pufflig/ps-models": "^0.24.6" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", @@ -21866,10 +21866,10 @@ } }, "packages/@pufflig/ps-sdk": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.5", + "@pufflig/ps-models": "^0.24.6", "axios": "^1.5.0" }, "devDependencies": { @@ -21904,7 +21904,7 @@ } }, "packages/@pufflig/ps-types": { - "version": "0.24.5", + "version": "0.24.6", "license": "MIT" }, "websites/blog": { diff --git a/packages/@pufflig/ps-chains/package.json b/packages/@pufflig/ps-chains/package.json index f8431c7..1db4597 100644 --- a/packages/@pufflig/ps-chains/package.json +++ b/packages/@pufflig/ps-chains/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-chains", - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "main": "./dist/ps-chains.umd.js", "module": "./dist/ps-chains.es.js", @@ -16,7 +16,7 @@ "test": "jest" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/react-dom": "^18.2.7", "immer": "^10.0.2", "prop-types": "^15.8.1", diff --git a/packages/@pufflig/ps-models/package.json b/packages/@pufflig/ps-models/package.json index 34ba190..daf8ac6 100644 --- a/packages/@pufflig/ps-models/package.json +++ b/packages/@pufflig/ps-models/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-models", "private": false, - "version": "0.24.5", + "version": "0.24.6", "description": "Configuration of models used in Prompt Studio", "files": [ "dist" @@ -16,7 +16,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "typescript": "^5.2.2", "vite": "^4.3.9", "vite-plugin-dts": "^2.3.0" diff --git a/packages/@pufflig/ps-nodes-config/package.json b/packages/@pufflig/ps-nodes-config/package.json index f0c1070..17f4627 100644 --- a/packages/@pufflig/ps-nodes-config/package.json +++ b/packages/@pufflig/ps-nodes-config/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes-config", "private": false, - "version": "0.24.5", + "version": "0.24.6", "description": "Configuration files for nodes used in prompt studio.", "files": [ "dist" @@ -16,10 +16,10 @@ "author": "Pufflig AB", "license": "MIT", "dependencies": { - "@pufflig/ps-models": "^0.24.5" + "@pufflig/ps-models": "^0.24.6" }, "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/jest": "^29.5.8", "jest": "^29.7.0", "ts-jest": "^29.1.0", diff --git a/packages/@pufflig/ps-nodes/package.json b/packages/@pufflig/ps-nodes/package.json index 67e3cdf..ae5b759 100644 --- a/packages/@pufflig/ps-nodes/package.json +++ b/packages/@pufflig/ps-nodes/package.json @@ -1,7 +1,7 @@ { "name": "@pufflig/ps-nodes", "private": false, - "version": "0.24.5", + "version": "0.24.6", "description": "Collection of nodes used in Prompt Studio", "files": [ "dist" @@ -17,7 +17,7 @@ "author": "Pufflig AB", "license": "MIT", "devDependencies": { - "@pufflig/ps-types": "^0.24.5", + "@pufflig/ps-types": "^0.24.6", "@types/jest": "^29.5.8", "@types/lodash": "^4.14.196", "@types/mustache": "^4.2.2", @@ -33,9 +33,9 @@ }, "dependencies": { "@dqbd/tiktoken": "^1.0.7", - "@pufflig/ps-models": "^0.24.5", - "@pufflig/ps-nodes-config": "^0.24.5", - "@pufflig/ps-sdk": "^0.24.5", + "@pufflig/ps-models": "^0.24.6", + "@pufflig/ps-nodes-config": "^0.24.6", + "@pufflig/ps-sdk": "^0.24.6", "axios": "^1.6.2", "langchain": "^0.0.193", "lodash": "^4.17.21", diff --git a/packages/@pufflig/ps-sdk/package.json b/packages/@pufflig/ps-sdk/package.json index de2e6bd..27c9140 100644 --- a/packages/@pufflig/ps-sdk/package.json +++ b/packages/@pufflig/ps-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-sdk", - "version": "0.24.5", + "version": "0.24.6", "license": "MIT", "main": "./dist/ps-sdk.umd.js", "module": "./dist/ps-sdk.es.js", @@ -21,7 +21,7 @@ "vite-plugin-dts": "^3.5.3" }, "dependencies": { - "@pufflig/ps-models": "^0.24.5", + "@pufflig/ps-models": "^0.24.6", "axios": "^1.5.0" }, "gitHead": "534ff07d186327e38133c0c14a5badd04ced0a9c" diff --git a/packages/@pufflig/ps-types/package.json b/packages/@pufflig/ps-types/package.json index 5d3f236..6c4e341 100644 --- a/packages/@pufflig/ps-types/package.json +++ b/packages/@pufflig/ps-types/package.json @@ -1,6 +1,6 @@ { "name": "@pufflig/ps-types", - "version": "0.24.5", + "version": "0.24.6", "description": "Typescript definitions for Prompt Studio", "main": "src/index.ts", "author": "Pufflig AB", From 0d2071a528e95d26ef40f601a1d4fb1cd6d355f7 Mon Sep 17 00:00:00 2001 From: Aurelien Franky Date: Fri, 24 Nov 2023 00:48:57 +0100 Subject: [PATCH 14/14] fix tests --- .../__snapshots__/document_check.test.ts.snap | 24 +++++++++---------- .../document_check/document_check.test.ts | 22 +++++++++-------- .../adapters/document_check/document_check.ts | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap b/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap index e9519f5..47f4995 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/__snapshots__/document_check.test.ts.snap @@ -213,7 +213,7 @@ exports[`documentCheck should extract variables correctly 1`] = ` "type": "model", }, { - "defaultValue": "Run the checklist below on the document.", + "defaultValue": "", "description": "Instructions for the AI", "id": "instructions", "name": "Instructions", @@ -230,10 +230,19 @@ exports[`documentCheck should extract variables correctly 1`] = ` "defaultValue": [], "description": "The checklist to run on the document", "editableSchema": true, - "id": "checklist", - "name": "Checklist", + "id": "checks", + "name": "Checks", "type": "object", }, + { + "defaultValue": [ + "ok (yes/no)", + ], + "description": "Custom fields to include in the output for each checklist item", + "id": "fields", + "name": "Fields", + "type": "list", + }, { "defaultValue": "markdown", "description": "The format in which to return the cheklist results", @@ -251,14 +260,5 @@ exports[`documentCheck should extract variables correctly 1`] = ` ], "type": "selection", }, - { - "defaultValue": [ - "ok", - ], - "description": "Custom fields to include in the output for each checklist item", - "id": "fields", - "name": "Fields", - "type": "list", - }, ] `; diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts index 1fdce0a..f22fecc 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.test.ts @@ -33,7 +33,7 @@ describe("documentCheck", () => { it("should parse input variables", async () => { const input: LLMCompletionInput = { - instructions: "Hello, {{world}}! Run a checklist on the following document: {{document}}", + instructions: "Hello, {{world}}! Run a checklist on the following document:", model: { modelId: "test_model", parameters: {}, @@ -81,18 +81,19 @@ is_formal,`, track: true, }, parameters: {}, - prompt: `Hello, test! Run a checklist on the following document: {{document}} + prompt: `Hello, test! Run a checklist on the following document: +DOCUMENT: +{{document}} CHECKLIST DESCRIPTION: check,description is_greeting, is the text a greeting? is_formal, is the greeting formal? -CHECKLIST FORMAT: +TABLE FORMAT: {{table}} -CHECKLIST IN CSV FORMAT: -`, +Return only the TABLE IN CSV FORMAT:`, }, { headers: { @@ -105,7 +106,7 @@ CHECKLIST IN CSV FORMAT: it("should parse input variables", async () => { const input: LLMCompletionInput = { - instructions: "Hello, {{world}}! Run a checklist on the following document: {{document}}", + instructions: "Hello, {{world}}! Run a checklist on the following document:", model: { modelId: "test_model", parameters: {}, @@ -153,18 +154,19 @@ CHECKLIST IN CSV FORMAT: track: true, }, parameters: {}, - prompt: `Hello, test! Run a checklist on the following document: {{document}} + prompt: `Hello, test! Run a checklist on the following document: +DOCUMENT: +{{document}} CHECKLIST DESCRIPTION: |check|description| |is_greeting|is the text a greeting?| |is_formal|is the greeting formal?| -CHECKLIST FORMAT: +TABLE FORMAT: {{table}} -CHECKLIST IN MARKDOWN FORMAT: -`, +Return only the TABLE IN MARKDOWN FORMAT:`, }, { headers: { diff --git a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts index 5fa01bc..3dc9128 100644 --- a/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts +++ b/packages/@pufflig/ps-nodes/src/adapters/document_check/document_check.ts @@ -77,7 +77,7 @@ ${description} TABLE FORMAT: {{table}} -Return only the TABLE IN ${format.toUpperCase()} FORMAT`; +Return only the TABLE IN ${format.toUpperCase()} FORMAT:`; // render the prompt without overwriting the document and table variables const renderedPrompt = Mustache.render(instructionsWithChecklist, {