Skip to content

Commit

Permalink
TODOs + README + Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hejny committed May 3, 2024
1 parent ccc77ce commit b6756d8
Show file tree
Hide file tree
Showing 34 changed files with 169 additions and 111 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Multiple factories for `PromptbookLibrary`, Custom errors, enhance templating
More options to create `PromptbookLibrary`

- Utility `createPromptbookLibraryFromDirectory`
- Utility `createPromptbookLibraryFromList`
- Utility `createPromptbookLibraryFromUrl`
- Add `extractBlock` to build-in functions
- Remove problematic usage of `chalk` and use `colors` instead
- Export `replaceParameters` from `@promptbook/utils`
Expand Down Expand Up @@ -262,6 +262,8 @@ Better script execution

### 0..0 _(2024-0-)_

<!--[🍓]-->

More options to create `PromptbookLibrary`

### 0..0 _(2024-0-)_
Expand All @@ -270,7 +272,9 @@ Intagration with Langtail

### 0..0 _(2024-0-)_

- TODO: !!! Add splitInto functions to `@promptbook/utils` besides all the `count` functions
<!--[🍓]-->

- TODO: Add splitInto functions to `@promptbook/utils` besides all the `count` functions

- Add `countCharacters` -> `splitIntoCharacters`
- Add `countLines` -> `splitIntoLines`
Expand All @@ -284,6 +288,8 @@ Intagration with Langtail

More expect variations

<!--[🍓]-->

- Add command `EXPECT "..."` <-[🥤]
- Add command `EXPECT /.../i` <-[🥤]
- Add command `EXPECT "...{foo}..."` <-[🥤]
Expand All @@ -294,3 +300,7 @@ More expect variations

- When postprocessing fails, retry in same way as failed expectations
- When making next attempt for `PROMPT DIALOG`, preserve the previous user input <-[🌹]

## 1.0.0 Release

Across the repository there are marked [🍓] places that are required to be done before `1.0.0` release
34 changes: 17 additions & 17 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# 🎯 TODOs

- [ ][🧙‍♂️] Make Wizzard
- [x] Make from this folder a separate repository + npm package
- [x] Add tests
- [ ] Annotate all entities
- [ ][🍓][🧙‍♂️] Make Wizzard OR remove it
- [x] Annotate all entities
- [ ] Make internal string aliases
- [ ] Make branded types instead of pure `string` aliases
- [ ] Remove all `any`
Expand All @@ -13,24 +11,26 @@
- [ ][🧠] Wording: "param" vs "parameter" vs "variable" vs "argument"
- [ ] All entities must have public / private / protected modifiers
- [ ] Everything not needed should be private or not exported
- [ ] Refactor circular dependencies
- [ ] Importing subtemplates
- [ ] Use `spaceTrim` more effectively
- [ ] [🤹‍♂️] Allow chats to be continued with previous message
- [x] Refactor circular dependencies
- [ ][🍓] Importing subtemplates
- [x] Use `spaceTrim` more effectively
- [ ][🍓][🤹‍♂️] Allow chats to be continued with previous message
- [ ][🍓] Allow to set top_t and other model params
- [ ][🍓] Allow to shortvut set top_t and other model params by `MODEL CREATIVITY 50%`
- [ ] [🧠][🤹‍♂️] How to mark continued chat in .ptbk.md format?
- [ ] Use newest version of socket.io for remote server
- [ ] [🧠] Allow to use and define [function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
- [ ][🍓][🧠] Allow to use and define [function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
- [x] Register .ptbk file extension
- [ ] Fix error `content.js:73 Uncaught (in promise) TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))`
- [x] Fix error `content.js:73 Uncaught (in promise) TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))`
- [ ] Aborting execution, maybe use native AbortController
- [ ] Change `import {...} from '...';` to `import type {...} from '...';` when importing only types
- [x] Change `import {...} from '...';` to `import type {...} from '...';` when importing only types
- [x] Wrap OpenAI billing errors:
- [ ] Integrate word stemmer https://github.com/maxpatiiuk/porter-stemming/blob/main/src/index.ts
- [ ] Integrate faker to generate simple mocked data
- [ ] Put postprocessing + expectations into mermaid graphs
- [ ] mermaid graphs as exported CLI util
- [ ] Preprocessing
- [ ] System to bundle up Preprocessing + Postprocessing + Expectations
- [ ][🍓] Show postprocessing + expectations into mermaid graphs
- [x] mermaid graphs as exported CLI util
- [ ][🍓][🧠] Preprocessing DO or remove
- [ ][🍓] System to bundle up Preprocessing + Postprocessing + Expectations - like `USE ceaserCipher`
- [ ] Integrate ceaser-cipher to auto preprocess some and postprocess templates
- [ ] Scenario: Expect all information (for example in incomming email), when not then return = kinda reverse joker
- [ ] Make VSCode extension for validation/syntax highlite (and for other editors)
- [ ][🍓][🧠] Scenario: Expect all information (for example in incomming email), when not then return = kinda reverse joker
- [ ] Make VSCode extension for validation/syntax highlite (and for other editors)
2 changes: 1 addition & 1 deletion samples/templates/00-simple.ptbk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Show how to use a simple prompt with no parameters.

- PROMPTBOOK VERSION 1.0.0
- MODEL VARIANT Chat
- MODEL NAME `gpt-3.5-turbo`
- MODEL NAME `gpt-3.5-turbo` <!-- <- TODO: [♐] Pick just the best model of required variant-->
- OUTPUT PARAMETER `{greeting}`

<!--Graph-->
Expand Down
2 changes: 1 addition & 1 deletion samples/templates/02-ptbkurl.ptbk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Show how to use a simple prompt with no parameters.
- PROMPTBOOK URL https://promptbook.example.com/samples/simple.ptbk.md@v1
- PROMPTBOOK VERSION 1.0.0
- MODEL VARIANT Chat
- MODEL NAME `gpt-3.5-turbo`
- MODEL NAME `gpt-3.5-turbo` <!-- <- TODO: [♐] Pick just the best model of required variant-->
- OUTPUT PARAMETER `{greeting}`

<!--Graph-->
Expand Down
2 changes: 1 addition & 1 deletion samples/templates/05-comment.ptbk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Show how to use a simple prompt with no parameters and comments that should be i
- PROMPTBOOK URL https://promptbook.example.com/samples/comment.ptbk.md@v1
- PROMPTBOOK VERSION 1.0.0
- MODEL VARIANT Chat
- MODEL NAME `gpt-3.5-turbo`
- MODEL NAME `gpt-3.5-turbo` <!-- <- TODO: [♐] Pick just the best model of required variant-->
- OUTPUT PARAMETER `{greeting}`

<!--Graph-->
Expand Down
2 changes: 1 addition & 1 deletion samples/templates/10-single.ptbk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Show how to use a simple prompt with one parameter.
- PROMPTBOOK URL https://promptbook.example.com/samples/single.ptbk.md@v1
- PROMPTBOOK VERSION 1.0.0
- MODEL VARIANT Chat
- MODEL NAME `gpt-3.5-turbo`
- MODEL NAME `gpt-3.5-turbo` <!-- <- TODO: [♐] Pick just the best model of required variant-->
- INPUT  PARAMETER `{word}` Any single word
- OUTPUT PARAMETER `{wordSynonym}`

Expand Down
2 changes: 1 addition & 1 deletion samples/templates/20-two.ptbk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Show how to use two consecutive prompts with one parameter each.
- PROMPTBOOK URL https://promptbook.example.com/samples/two.ptbk.md@v1
- PROMPTBOOK VERSION 1.0.0
- MODEL VARIANT Chat
- MODEL NAME `gpt-3.5-turbo`
- MODEL NAME `gpt-3.5-turbo` <!-- <- TODO: [♐] Pick just the best model of required variant-->
- INPUT  PARAMETER `{word}` Any single word
- OUTPUT PARAMETER `{sentenceWithTwoSynonyms}`

Expand Down
2 changes: 1 addition & 1 deletion samples/usage/logging/logging.ts.todo
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function main() {
}

/**
* TODO: [🈴][⚾️] !!! Identify PROMPTBOOKs by URL
* TODO: [🈴][⚾️] !!! Identify PROMPTBOOKs by URL in this sample
* TODO: [⚾️] No need to set this script or userInterface in tools
* TODO: [⚾️] Use PromptbookLibrary.fromDirectory (directory vs folder)
* TODO: [⚾️] Also sample with Wizzard
Expand Down
2 changes: 1 addition & 1 deletion samples/usage/remote/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>esting remote server of PromptBook</h1>
<pre id="output"><pre>

<script type="module">
// TODO: [🤣] !!! Auto update version
// TODO: [🍓][🤣] !!! Auto update version
import { RemoteLlmExecutionTools } from 'https://cdn.jsdelivr.net/npm/@promptbook/[email protected]/+esm';
import { JavascriptEvalExecutionTools } from 'https://cdn.jsdelivr.net/npm/@promptbook/[email protected]/+esm';
import { SimplePromptbookLibrary } from 'https://cdn.jsdelivr.net/npm/@promptbook/[email protected]/+esm';
Expand Down
3 changes: 2 additions & 1 deletion samples/usage/remote/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function main() {
createLlmExecutionTools(clientId) {
console.log('clientId', clientId);
return new OpenAiExecutionTools({
// TODO: [♐] Pick just the best model of required variant
isVerbose: true,
openAiApiKey: process.env.OPENAI_API_KEY!,
user: clientId,
Expand All @@ -40,7 +41,7 @@ async function main() {
}

/**
* TODO: [🈴] !!! Identify PROMPTBOOKs by URL
* TODO: [🈴] !!! Identify PROMPTBOOKs by URL in this sample
* TODO: There should be no need to set this script or userInterface in tools
* TODO: Implement and use here PromptbookLibrary.fromDirectory (directory vs folder)
* TODO: [🧙‍♂️] Make sample with Wizzard
Expand Down
5 changes: 3 additions & 2 deletions samples/usage/simple-script/simple-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ async function main() {
const promptbookUrl = 'https://promptbook.example.com/samples/language-capabilities.ptbk.md@v1';

const library = createPromptbookLibraryFromSources(
// TODO: !!! Use createPromptbookLibraryFromDirectory
// TODO:[🍓] !!! Use createPromptbookLibraryFromDirectory
await readFile(`./samples/templates/50-advanced.ptbk.md`, 'utf-8'),
);

const promptbook = library.getPromptbookByUrl((await library.listPromptbooks())[0]);

const tools = {
llm: new OpenAiExecutionTools({
// TODO: [♐] Pick just the best model of required variant
isVerbose: true,
openAiApiKey: process.env.OPENAI_API_KEY,
}),
Expand Down Expand Up @@ -66,7 +67,7 @@ async function main() {
}

/**
* TODO: [🈴] !!! Identify PROMPTBOOKs by URL
* TODO: [🈴] !!! Identify PROMPTBOOKs by URL in this sample
* TODO: There should be no need to set this script or userInterface in tools
* TODO: Implement and use here PromptbookLibrary.fromDirectory (directory vs folder)
* TODO: Make sample with Wizzard
Expand Down
2 changes: 1 addition & 1 deletion samples/usagex/TODO.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TODO: !!! Probbably remove usagex - just want usage
TODO: [🍓] !!! Probbably remove usagex - just want usage
TODO: This is only for debugging NPM always install latest prerelease version
4 changes: 2 additions & 2 deletions src/_packages/core.index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export { ExecutionTypes, PROMPTBOOK_VERSION };

// @promptbook/library
export {
// TODO: !!!createPromptbookLibraryFromDirectory,
// TODO: !!! createPromptbookLibraryFromList,
// TODO: !!! [🍓] createPromptbookLibraryFromDirectory,
// TODO: !!! [🍓] createPromptbookLibraryFromUrl,
createPromptbookLibraryFromPromise,
createPromptbookLibraryFromSources,
createPromptbookSublibrary,
Expand Down
4 changes: 2 additions & 2 deletions src/_packages/langtail.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Use [Langtail](https://langtail.com/) to **ship AI apps with fewer surprises**.

This package is wrapper of [Langtail's OpenAI proxy](https://langtail.com/docs/proxy/openai) to make it easier to use inside the Promptbooks.

<!--!!! Example -->
<!--!!! Link Simillar wrappers -->
<!-- [🍓]!!! Example -->
<!-- [🍓] !!! Link Simillar wrappers -->
2 changes: 1 addition & 1 deletion src/_packages/openai.readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Wrapper around [OpenAI's SDK](https://www.npmjs.com/package/openai) to make it easier to use inside Promptbooks.

<!--!!! Link Simillar wrappers -->
<!-- TODO: [🍓] !!! Link Simillar wrappers -->
2 changes: 1 addition & 1 deletion src/_packages/remote-client.readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- TODO: !!! Sample of use + interlink server and client -->
<!-- TODO: [🍓] !!! Sample of use + interlink server and client -->
2 changes: 1 addition & 1 deletion src/_packages/remote-server.readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- TODO: !!! Sample of use + interlink server and client -->
<!-- TODO: [🍓] !!! Sample of use + interlink server and client -->
2 changes: 1 addition & 1 deletion src/conversion/prettify/prettifyPromptbookStringCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PROMPTBOOK_VERSION } from '../../version';
import { prettifyPromptbookString } from './prettifyPromptbookString';

/**
* !!! Initialize
* Runs CLI script for prettifying promptbooks
*/
export async function prettifyPromptbookStringCli(): Promise<void> {
if (!isRunningInNode()) {
Expand Down
4 changes: 2 additions & 2 deletions src/execution/ExecutionTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ExecutionTools = {
* Note: You can pass multiple ScriptExecutionTools, they will be tried one by one until one of them supports the script
* If none of them supports the script, an error is thrown
*/
script: Array<ScriptExecutionTools>;
script: Array<ScriptExecutionTools>; // <- TODO: [🧠] Maybe not Array but Arrayable

/**
* Tools for interacting with the user
Expand All @@ -28,5 +28,5 @@ export type ExecutionTools = {
};

/**
* TODO: !!!! Allow more
* TODO: [🍓] !!!! Allow to have more LlmExecutionTools
*/
1 change: 1 addition & 0 deletions src/execution/LlmExecutionTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type LlmExecutionTools = {
};

/**
* TODO: [🍓][♐] Allow to list compatible models with each variant
* TODO: [🏳] gptChat -> chat, gptComplete -> complete, translate
* TODO: [🧠] Should or should not there be a word "GPT" in both gptComplete and gptChat
*/
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
export class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {}

/**
* TODO: !!! Make lib which exports this
* TODO: [🍓][♐] Allow to list the aviable prompts in Langtail
*/
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class OpenAiExecutionTools implements LlmExecutionTools {
}

/**
* TODO: [🍓][♐] Allow to list compatible models with each variant
* TODO: Maybe Create some common util for gptChat and gptComplete
* TODO: Maybe make custom OpenaiError
*/
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PromptbookExecutionError } from '../../../../errors/PromptbookExecution
import type { PromptResult } from '../../../PromptResult';

/**
* !!!
* Computes the usage of the OpenAI API based on the response from OpenAI
*
* @throws {PromptbookExecutionError} If the usage is not defined in the response from OpenAI
*/
Expand Down Expand Up @@ -59,3 +59,7 @@ export function computeOpenaiUsage(
outputTokens,
};
}

/**
* TODO: [🍓] Make better
*/
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ export class RemoteLlmExecutionTools implements LlmExecutionTools {
}

/**
* TODO: [🍓][♐] Allow to list compatible models with each variant
* TODO: [🤹‍♂️] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
*/
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class JavascriptEvalExecutionTools implements ScriptExecutionTools {
normalizeTo_PascalCase,
parseKeywords,
normalizeTo_SCREAMING_CASE,
extractBlock, // <- !!!! Remove balast in all other functions, use this one as example
extractBlock, // <- [🍓] !!!! Remove balast in all other functions, use this one as example
};
const buildinFunctionsStatement = Object.keys(buildinFunctions)
.map(
Expand Down
5 changes: 3 additions & 2 deletions src/library/SimplePromptbookLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { PromptbookLibrary } from './PromptbookLibrary';
export class SimplePromptbookLibrary implements PromptbookLibrary {
private library: Map<string_promptbook_url, PromptbookJson>;

/**!!!
/**
* Constructs a promptbook library from promptbooks
*
* @param promptbooks !!!
*
Expand Down Expand Up @@ -83,7 +84,7 @@ export class SimplePromptbookLibrary implements PromptbookLibrary {
* Checks whether given prompt was defined in any promptbook in the library
*/
public isResponsibleForPrompt(prompt: Prompt): boolean {
// TODO: !!! DO not hardcode this, really validate whether the prompt is in the library
// TODO: [🍓] !!! DO not hardcode this, really validate whether the prompt is in the library
prompt;
return true;
}
Expand Down
22 changes: 21 additions & 1 deletion src/library/constructors/createPromptbookLibraryFromDirectory.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import { isRunningInNode } from '../../utils/isRunningInWhatever';
import { PromptbookLibrary } from '../PromptbookLibrary';

/**
* Constructs Promptbook from given directory
*
* Note: Works only in Node.js environment because it reads the file system
* Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
* SO during the construction syntax and logic sources IS NOT validated
*
* @returns PromptbookLibrary
*/
export function createPromptbookLibraryFromDirectory(): PromptbookLibrary {
if (!isRunningInNode()) {
throw new Error(
'Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.',
);
}

throw new Error('Not implemented yet');

// TODO: !! Load dynamically DO NOT use createPromptbookLibraryFromPromise

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return null as any;
}

/***
* TODO: !!! Annotate all + all to README and samples
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
*/
10 changes: 0 additions & 10 deletions src/library/constructors/createPromptbookLibraryFromList.ts

This file was deleted.

Loading

0 comments on commit b6756d8

Please sign in to comment.