{"_id":"@ag076810/prompt","name":"@ag076810/prompt","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.4":{"name":"@ag076810/prompt","version":"0.0.4","description":"A prompt management library for OpenAI gpt-3.5-turbo and gpt-4","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ag076810/prompt.js.git"},"keywords":["ai","gpt-3.5","gpt-4","prompt","management"],"author":{"name":"The Maximalist"},"license":"MIT","bugs":{"url":"https://github.com/themaximal1st/prompt.js/issues"},"homepage":"https://github.com/themaximal1st/prompt.js","dependencies":{"debug":"^4.3.4","ejs":"^3.1.9","toml":"^3.0.0"},"gitHead":"5d8cb76792b8c20fc7436e6b73d20d1893254026","_id":"@ag076810/prompt@0.0.4","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-zP2AyIo25+f/MAHptvxEeNg5R3MBfpGFu3pdsPCwEI8mdywhu1aZDzIDIMEOtvDTwl+1UWpJ3l0rxwjJDXDmBA==","shasum":"05e1489e5585872859cd698b0cb5ba5029909a0a","tarball":"https://registry.npmjs.org/@ag076810/prompt/-/prompt-0.0.4.tgz","fileCount":7,"unpackedSize":5581,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBKvUhOk7bVVbrXEaXgiIABSr29YL9LuheKW5jMnbhwgAiBPFWWh+PlXAyqNgGmQXtOu3hYkNlBxOeZUA1+IFbbcDQ=="}]},"_npmUser":{"name":"ag076810","email":"ag0768101@gmail.com"},"directories":{},"maintainers":[{"name":"ag076810","email":"ag0768101@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/prompt_0.0.4_1691402033183_0.3706328588933958"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-07T09:53:53.122Z","0.0.4":"2023-08-07T09:53:53.347Z","modified":"2023-08-07T09:53:53.503Z"},"maintainers":[{"name":"ag076810","email":"ag0768101@gmail.com"}],"description":"A prompt management library for OpenAI gpt-3.5-turbo and gpt-4","homepage":"https://github.com/themaximal1st/prompt.js","keywords":["ai","gpt-3.5","gpt-4","prompt","management"],"repository":{"type":"git","url":"git+https://github.com/ag076810/prompt.js.git"},"author":{"name":"The Maximalist"},"bugs":{"url":"https://github.com/themaximal1st/prompt.js/issues"},"license":"MIT","readme":"# prompt.js\n\nA simple and flexible node.js prompt loader for OpenAI applications that supports both plain text and TOML formats.\n\n\n\n## Features\n\n-   Load prompts from `.txt` and `.toml` files\n-   Support for EJS templating for dynamic content\n-   Easy configuration of prompt directory\n\n\n\n## Installation\n\n```bash\nnpm install --save @themaximalist/prompt.js\n```\n\n\n\n## Usage\n\n```javascript\nconst prompt = require(\"@themaximalist/prompt.js\");\n\n// Configure prompt directory (optional)\nprompt.configure({\n    promptDir: join(__dirname, \"path/to/prompts\"),\n});\n\n// Load a plain text prompt\n// > cat example1.txt\n// Hello <%= name %>\nconst response = prompt.load(\"example1\", { name: \"The Maximalist\" });\nconsole.log(response); // Hello The Maximalist\n\n// Load a TOML prompt\n// > cat example2.toml\n// <% for (const chat of chats) { %>\n// [[messages]]\n// role = \"<%= chat.role %>\"\n// content = \"\"\"\n// <%- chat.content %>\n// \"\"\"\n// <% } %>\nconst messages = prompt.load(\"example2\", {\n    chats: [\n        { role: \"user\", content: \"Hello, I am a user\" },\n        { role: \"assistant\", content: \"Hi, how can I help you?\" },\n    ]\n});\nconsole.log(messages); // [{...}, {...}]\n```\n\n\n\n## API\n\n### configure(options)\n\nConfigure the prompt loader with custom options.\n\n- `promptDir`: A string representing the path to the directory containing the prompt files.\n\n\n\n### load(promptName, variables)\n\nLoad a prompt from a file and return the parsed content.\n\n- `promptName`: A string representing the name of the prompt file (without the file extension).\n- `variables`: An object containing variables to be used when parsing the prompt with EJS.\n\n\n\n## Error Handling\n\n`PromptError` is an error class specific to this package, used when a prompt file cannot be found.\n\n```javascript\ntry {\n    const message = prompt.load(\"nonexistent_prompt\");\n} catch (error) {\n    if (error instanceof prompt.PromptError) {\n        console.error(\"Prompt not found:\", error.message);\n    } else {\n        throw error;\n    }\n}\n```\n\n\n\n## Author\n\nhttps://themaximalist.com\n\nhttps://twitter.com/themaximal1st\n\n\n\n## License\n\nThis project is released under the [MIT License](https://chat.openai.com/LICENSE).\n","readmeFilename":"README.md"}