├── .nvmrc ├── .npmrc ├── examples ├── .eslintignore ├── priompt │ ├── ArvidStory │ │ └── example01.yaml │ ├── examplePrompt │ │ └── example01.yaml │ ├── SimplePrompt │ │ └── example01.yaml │ ├── functionCallingPrompt │ │ └── example01.yaml │ └── SimpleFunction │ │ └── example01.yaml ├── .gitignore ├── .eslintrc.json ├── .env.example ├── vitest.config.ts ├── tsconfig.json ├── README.md ├── package.json └── src │ ├── priompt-preview-handlers.ts │ ├── prompt.tsx │ ├── function-calling-prompt.tsx │ └── index.ts ├── priompt-preview ├── src │ ├── load_remote.ts │ ├── vite-env.d.ts │ ├── index.css │ ├── lib │ │ └── utils.ts │ ├── main.tsx │ ├── components │ │ └── ui │ │ │ ├── textarea.tsx │ │ │ ├── button.tsx │ │ │ ├── dialog.tsx │ │ │ └── command.tsx │ └── openai.ts ├── README.md ├── vite.config.d.ts ├── postcss.config.js ├── tsconfig.node.json ├── vite.config.ts ├── vite.config.js ├── .gitignore ├── components.json ├── index.html ├── .eslintrc.cjs ├── tsconfig.json ├── tailwind.config.js ├── scripts │ └── serve.cjs └── package.json ├── priompt ├── .gitignore ├── .eslintignore ├── README.md ├── .eslintrc.json ├── vitest.config.ts ├── src │ ├── index.ts │ ├── outputCatcher.ai.impl.ts │ ├── outputCatcher.ai.ts │ ├── tokenizer.ts │ ├── components.tsx │ ├── base.test.tsx │ ├── openai.ts │ ├── types.d.ts │ ├── components.test.tsx │ ├── outputCatcher.ai.test.ts │ └── preview.ts ├── tsconfig.json └── package.json ├── tiktoken-node ├── build.rs ├── npm │ ├── darwin-x64 │ │ ├── README.md │ │ └── package.json │ ├── darwin-arm64 │ │ ├── README.md │ │ └── package.json │ ├── linux-x64-gnu │ │ ├── README.md │ │ └── package.json │ ├── win32-x64-msvc │ │ ├── README.md │ │ └── package.json │ ├── linux-arm64-gnu │ │ ├── README.md │ │ └── package.json │ └── win32-arm64-msvc │ │ ├── README.md │ │ └── package.json ├── .npmignore ├── README.md ├── Cargo.toml ├── package.json ├── index.d.ts ├── .gitignore ├── index.js └── src │ └── lib.rs ├── rustfmt.toml ├── .gitignore ├── init.sh ├── .vscode └── settings.json ├── LICENSE ├── publish.sh ├── .eslintrc.base.json ├── pull-from-open-source.sh ├── push-to-open-source.sh ├── .github └── workflows │ └── publish.yml └── README.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 20.6.1 -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | publish-branch=publish -------------------------------------------------------------------------------- /examples/.eslintignore: -------------------------------------------------------------------------------- 1 | vitest.config.ts -------------------------------------------------------------------------------- /priompt-preview/src/load_remote.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /priompt/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules -------------------------------------------------------------------------------- /examples/priompt/ArvidStory/example01.yaml: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /priompt/.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | esbuild.ts 3 | vitest.config.ts -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .env 4 | priompt/*/dumps/**/* -------------------------------------------------------------------------------- /priompt-preview/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /priompt/README.md: -------------------------------------------------------------------------------- 1 | Run `pnpm build` or `pnpm build-watch` to build the library. 2 | -------------------------------------------------------------------------------- /priompt-preview/README.md: -------------------------------------------------------------------------------- 1 | Run `pnpm build` or `pnpm build-watch` to build the library. 2 | -------------------------------------------------------------------------------- /priompt-preview/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /tiktoken-node/build.rs: -------------------------------------------------------------------------------- 1 | extern crate napi_build; 2 | 3 | fn main() { 4 | napi_build::setup(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/priompt/examplePrompt/example01.yaml: -------------------------------------------------------------------------------- 1 | message: what is the advantage of rust over c 2 | name: arvid 3 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | use_small_heuristics = "Max" 2 | newline_style = "Unix" 3 | edition = "2021" 4 | tab_spaces = 2 5 | -------------------------------------------------------------------------------- /priompt-preview/vite.config.d.ts: -------------------------------------------------------------------------------- 1 | declare const _default: import("vite").UserConfig; 2 | export default _default; 3 | -------------------------------------------------------------------------------- /examples/priompt/SimplePrompt/example01.yaml: -------------------------------------------------------------------------------- 1 | text: Cursor är den bästa plattformen för att skriva kod. 2 | language: swahili 3 | -------------------------------------------------------------------------------- /priompt-preview/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /examples/priompt/functionCallingPrompt/example01.yaml: -------------------------------------------------------------------------------- 1 | message: bad the prompt buton not work 2 | includeFunctions: 3 | - insert_sql_row 4 | -------------------------------------------------------------------------------- /examples/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../.eslintrc.base"], 3 | "rules": { 4 | // additional rules specific to this config 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /priompt/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../.eslintrc.base"], 3 | "rules": { 4 | // additional rules specific to this config 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tiktoken-node/npm/darwin-x64/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-darwin-x64` 2 | 3 | This is the **x86_64-apple-darwin** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /tiktoken-node/npm/darwin-arm64/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-darwin-arm64` 2 | 3 | This is the **aarch64-apple-darwin** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /tiktoken-node/npm/linux-x64-gnu/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-linux-x64-gnu` 2 | 3 | This is the **x86_64-unknown-linux-gnu** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /tiktoken-node/npm/win32-x64-msvc/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-win32-x64-msvc` 2 | 3 | This is the **x86_64-pc-windows-msvc** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /tiktoken-node/npm/linux-arm64-gnu/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-linux-arm64-gnu` 2 | 3 | This is the **aarch64-unknown-linux-gnu** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /tiktoken-node/npm/win32-arm64-msvc/README.md: -------------------------------------------------------------------------------- 1 | # `@anysphere/tiktoken-node-win32-arm64-msvc` 2 | 3 | This is the **aarch64-pc-windows-msvc** binary for `@anysphere/tiktoken-node` 4 | -------------------------------------------------------------------------------- /examples/priompt/SimpleFunction/example01.yaml: -------------------------------------------------------------------------------- 1 | code: |- 2 | function x() { 3 | return z.object({ 4 | a: z.string(), 5 | b: z.number(), 6 | }); 7 | } 8 | error: '''z'' is not defined' 9 | -------------------------------------------------------------------------------- /tiktoken-node/.npmignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | .cargo 4 | .github 5 | npm 6 | .eslintrc 7 | .prettierignore 8 | rustfmt.toml 9 | yarn.lock 10 | *.node 11 | .yarn 12 | __test__ 13 | renovate.json 14 | -------------------------------------------------------------------------------- /priompt-preview/src/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from "clsx" 2 | import { twMerge } from "tailwind-merge" 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /examples/.env.example: -------------------------------------------------------------------------------- 1 | SERVER_PORT=8008 2 | NODE_ENV=development 3 | OPENAI_API_KEY=sk-your-openai-secret-key 4 | 5 | PRIOMPT_PREVIEW_PORT=6284 6 | PRIOMPT_PREVIEW_SERVER_PORT=$SERVER_PORT 7 | PRIOMPT_PREVIEW_OPENAI_KEY=$OPENAI_API_KEY -------------------------------------------------------------------------------- /examples/vitest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | test: { 3 | include: [ 4 | 'src/**/*.{test,spec}.{js,ts,jsx,tsx}', 5 | // Also include top level files 6 | 'src/*.{test,spec}.{js,ts,jsx,tsx}' 7 | ], 8 | exclude: ['build/**/*'], 9 | }, 10 | }; -------------------------------------------------------------------------------- /priompt-preview/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "node", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /priompt/vitest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | test: { 3 | include: [ 4 | 'src/**/*.{test,spec}.{js,ts,jsx,tsx}', 5 | // Also include top level files 6 | 'src/*.{test,spec}.{js,ts,jsx,tsx}' 7 | ], 8 | exclude: ['build/**/*'], 9 | // setupFiles: ['dotenv/config'] 10 | }, 11 | }; -------------------------------------------------------------------------------- /tiktoken-node/README.md: -------------------------------------------------------------------------------- 1 | # @anysphere/tiktoken-node 2 | 3 | We use our own fork for now because we are making changes that may not be useful to everyone. For example, we add support for special tokens, and we also add support for running tokenization asynchronously with the computation happening on a different thread. 4 | -------------------------------------------------------------------------------- /priompt-preview/src/main.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as ReactDOM from "react-dom/client"; 3 | import './index.css'; 4 | import App from "./App"; 5 | 6 | ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( 7 | 8 | 9 | 10 | ); 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | priompt-opensource 4 | commit.patch 5 | commit.template 6 | .wireit 7 | target/ 8 | *.tsbuildinfo 9 | 10 | # todo: we should figure out a good way to sync these with the internal repo instead of having to generate them with the init script 11 | Cargo.lock 12 | Cargo.toml 13 | pnpm-workspace.yaml 14 | pnpm-lock.yaml -------------------------------------------------------------------------------- /priompt-preview/vite.config.ts: -------------------------------------------------------------------------------- 1 | import path from "path" 2 | import react from "@vitejs/plugin-react" 3 | import { defineConfig } from "vite" 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [react()], 8 | resolve: { 9 | alias: { 10 | "@": path.resolve(__dirname, "./src"), 11 | }, 12 | }, 13 | }) 14 | -------------------------------------------------------------------------------- /priompt-preview/vite.config.js: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import react from "@vitejs/plugin-react"; 3 | import { defineConfig } from "vite"; 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | resolve: { 8 | alias: { 9 | "@": path.resolve(__dirname, "./src"), 10 | }, 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /priompt-preview/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /tiktoken-node/npm/darwin-x64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-darwin-x64", 3 | "version": "0.1.27", 4 | "os": [ 5 | "darwin" 6 | ], 7 | "cpu": [ 8 | "x64" 9 | ], 10 | "main": "tiktoken-node.darwin-x64.node", 11 | "files": [ 12 | "tiktoken-node.darwin-x64.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | } 18 | } -------------------------------------------------------------------------------- /tiktoken-node/npm/darwin-arm64/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-darwin-arm64", 3 | "version": "0.1.27", 4 | "os": [ 5 | "darwin" 6 | ], 7 | "cpu": [ 8 | "arm64" 9 | ], 10 | "main": "tiktoken-node.darwin-arm64.node", 11 | "files": [ 12 | "tiktoken-node.darwin-arm64.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | } 18 | } -------------------------------------------------------------------------------- /tiktoken-node/npm/win32-x64-msvc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-win32-x64-msvc", 3 | "version": "0.1.27", 4 | "os": [ 5 | "win32" 6 | ], 7 | "cpu": [ 8 | "x64" 9 | ], 10 | "main": "tiktoken-node.win32-x64-msvc.node", 11 | "files": [ 12 | "tiktoken-node.win32-x64-msvc.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | } 18 | } -------------------------------------------------------------------------------- /priompt-preview/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": false, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "src/index.css", 9 | "baseColor": "stone", 10 | "cssVariables": false 11 | }, 12 | "aliases": { 13 | "components": "@/components", 14 | "utils": "@/lib/utils" 15 | } 16 | } -------------------------------------------------------------------------------- /tiktoken-node/npm/win32-arm64-msvc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-win32-arm64-msvc", 3 | "version": "0.1.27", 4 | "os": [ 5 | "win32" 6 | ], 7 | "cpu": [ 8 | "arm64" 9 | ], 10 | "main": "tiktoken-node.win32-arm64-msvc.node", 11 | "files": [ 12 | "tiktoken-node.win32-arm64-msvc.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | } 18 | } -------------------------------------------------------------------------------- /priompt-preview/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Priompt Preview 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tiktoken-node/npm/linux-x64-gnu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-linux-x64-gnu", 3 | "version": "0.1.27", 4 | "os": [ 5 | "linux" 6 | ], 7 | "cpu": [ 8 | "x64" 9 | ], 10 | "main": "tiktoken-node.linux-x64-gnu.node", 11 | "files": [ 12 | "tiktoken-node.linux-x64-gnu.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | }, 18 | "libc": [ 19 | "glibc" 20 | ] 21 | } -------------------------------------------------------------------------------- /tiktoken-node/npm/linux-arm64-gnu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@anysphere/tiktoken-node-linux-arm64-gnu", 3 | "version": "0.1.27", 4 | "os": [ 5 | "linux" 6 | ], 7 | "cpu": [ 8 | "arm64" 9 | ], 10 | "main": "tiktoken-node.linux-arm64-gnu.node", 11 | "files": [ 12 | "tiktoken-node.linux-arm64-gnu.node" 13 | ], 14 | "license": "MIT", 15 | "engines": { 16 | "node": ">= 10" 17 | }, 18 | "libc": [ 19 | "glibc" 20 | ] 21 | } -------------------------------------------------------------------------------- /examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "outDir": "./dist", 5 | "strictNullChecks": true, 6 | "noImplicitAny": true, 7 | "declaration": true, 8 | "isolatedModules": true, 9 | "target": "es2022", 10 | "moduleResolution": "node", 11 | "jsx": "react", 12 | "jsxFactory": "Priompt.createElement", 13 | "jsxFragmentFactory": "Priompt.Fragment", 14 | "strictPropertyInitialization": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /priompt/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib'; 2 | 3 | export * from './components'; 4 | 5 | export { PreviewManager, dumpProps, register } from './preview'; 6 | export type { PreviewManagerGetPromptQuery, PreviewManagerLiveModeQuery, PreviewManagerLiveModeResultQuery, PreviewConfig, SynchronousPreviewConfig } from './preview'; 7 | 8 | export type { RenderOptions, RenderOutput, JSX, RenderedPrompt, Prompt, PromptElement, BaseProps, PromptProps, ChatAndFunctionPromptFunction, ChatPrompt } from './types'; 9 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 4 | 5 | echo '{ 6 | "packages": ["priompt", "priompt-preview", "examples", "tiktoken-node"] 7 | }' > "$SCRIPT_DIR"/pnpm-workspace.yaml 8 | 9 | echo '[workspace] 10 | members = ["tiktoken-node"] 11 | ' > "$SCRIPT_DIR"/Cargo.toml 12 | 13 | # copy over the examples/.env.example to examples/.env 14 | cp -f "$SCRIPT_DIR"/examples/.env.example "$SCRIPT_DIR"/examples/.env 15 | 16 | pnpm i -r 17 | -------------------------------------------------------------------------------- /priompt-preview/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { browser: true, es2020: true, node: true }, 3 | extends: [ 4 | 'eslint:recommended', 5 | 'plugin:@typescript-eslint/recommended', 6 | 'plugin:react-hooks/recommended', 7 | ], 8 | parser: '@typescript-eslint/parser', 9 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 10 | plugins: ['react-refresh'], 11 | rules: { 12 | 'react-refresh/only-export-components': 'warn', 13 | // disable unused vars check 14 | '@typescript-eslint/no-unused-vars': 'off', 15 | '@typescript-eslint/no-empty-interface': 'off', 16 | '@typescript-eslint/no-inferrable-types': 'off', 17 | }, 18 | } 19 | -------------------------------------------------------------------------------- /priompt-preview/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "lib": ["DOM", "DOM.Iterable", "ESNext"], 5 | "module": "ESNext", 6 | "skipLibCheck": true, 7 | 8 | /* Bundler mode */ 9 | "moduleResolution": "node", 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "noEmit": true, 13 | "jsx": "react-jsx", 14 | "incremental": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true, 21 | "baseUrl": ".", 22 | "paths": { 23 | "@/*": ["./src/*"] 24 | } 25 | }, 26 | "include": ["src"], 27 | "references": [{ "path": "./tsconfig.node.json" }] 28 | } 29 | -------------------------------------------------------------------------------- /tiktoken-node/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2021" 3 | name = "anysphere_tiktoken-node" 4 | version = "0.0.1" 5 | 6 | [lib] 7 | crate-type = ["cdylib"] 8 | 9 | [dependencies] 10 | # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix 11 | napi = { version = "2.12.2", default-features = false, features = [ 12 | "napi4", 13 | "async", 14 | ] } 15 | napi-derive = "2.12.2" 16 | tiktoken = { git = "https://github.com/anysphere/tiktoken-rs", rev = "6b66cac8738428a4c695d7479d881aaddaf926dd" } 17 | rayon = "1.7.0" 18 | anyhow = "1.0.69" 19 | tokio = { version = "1.13.0", features = [ 20 | "rt-multi-thread", 21 | "sync", 22 | "rt", 23 | "macros", 24 | ] } 25 | 26 | [build-dependencies] 27 | napi-build = "2.0.1" 28 | 29 | [profile.release] 30 | lto = true 31 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Priompt examples 2 | 3 | An example showing how to use `priompt` and `priompt-preview`; somewhat useful for testing random prompts. 4 | 5 | This example uses `fastify` for the server, but any server library or framework should work 6 | 7 | ## Running 8 | 9 | First run: 10 | 11 | ```bash 12 | cd .. && ./init.sh 13 | ``` 14 | 15 | Then configure your OpenAI key in `.env`. 16 | 17 | In one terminal: 18 | 19 | ```bash 20 | pnpm priompt 21 | ``` 22 | 23 | In another: 24 | 25 | ```bash 26 | pnpm watch 27 | ``` 28 | 29 | In a third: 30 | 31 | ```bash 32 | curl 'localhost:8008/message?message=what%20is%20the%20advantage%20of%20rust%20over%20c&name=a%20curious%20explorer' 33 | ``` 34 | 35 | You should get a response within a few seconds. 36 | 37 | Go to [localhost:6284](http://localhost:6284) to see the prompt in the priompt preview. 38 | -------------------------------------------------------------------------------- /priompt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "outDir": "./dist", 5 | "strictNullChecks": true, 6 | "noImplicitAny": true, 7 | "declaration": true, 8 | "target": "ES2019", 9 | "module": "NodeNext", 10 | // we need this because vitest 1 requires nodenext, and vitest 0.33 and vitest 1 cannot coexist 11 | "moduleResolution": "nodenext", 12 | "jsx": "react", 13 | "jsxFactory": "Priompt.createElement", 14 | "jsxFragmentFactory": "Priompt.Fragment", 15 | "sourceMap": true, 16 | "inlineSources": true, 17 | // we need this to fix this weird vitest problem: https://github.com/vitejs/vite/issues/11552 18 | "skipLibCheck": true, 19 | "strictPropertyInitialization": true, 20 | "declarationMap": true 21 | }, 22 | "include": ["./src/**/*.ts", "./src/**/*.tsx"] 23 | } 24 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.workingDirectories": [ 3 | { 4 | "directory": "examples", 5 | "changeProcessCWD": true 6 | }, 7 | { 8 | "directory": "priompt", 9 | "changeProcessCWD": true 10 | }, 11 | { 12 | "directory": "priompt-preview", 13 | "changeProcessCWD": true 14 | } 15 | ], 16 | "[javascript]": { 17 | "editor.defaultFormatter": "vscode.typescript-language-features", 18 | "editor.insertSpaces": false, 19 | "editor.formatOnSave": true 20 | }, 21 | "[typescript]": { 22 | "editor.defaultFormatter": "vscode.typescript-language-features", 23 | "editor.insertSpaces": false, 24 | "editor.formatOnSave": true 25 | }, 26 | "[jsonc]": { 27 | "editor.defaultFormatter": "esbenp.prettier-vscode", 28 | "editor.formatOnSave": true 29 | }, 30 | "files.associations": { 31 | "*.env*": "properties" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /priompt-preview/src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import { cn } from "@/lib/utils"; 4 | 5 | export interface TextareaProps 6 | extends React.TextareaHTMLAttributes {} 7 | 8 | const Textarea = React.forwardRef( 9 | ({ className, ...props }, ref) => { 10 | return ( 11 |