{"id":13592721,"url":"https://github.com/rafalzawadzki/spellbook-forge","last_synced_at":"2025-04-10T18:20:36.160Z","repository":{"id":152739546,"uuid":"626927292","full_name":"rafalzawadzki/spellbook-forge","owner":"rafalzawadzki","description":"✨ Make your LLM prompts executable and version controlled. ✨","archived":false,"fork":false,"pushed_at":"2023-04-14T10:59:20.000Z","size":95,"stargazers_count":75,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T22:43:06.356Z","etag":null,"topics":["ai","chatgpt","chatgpt-api","chatgpt-app","chatgpt3","express","express-middleware","expressjs","gpt","gpt-2","gpt-3","gpt-4","gpt4","gpt4-api","langchain","langchain-typescript","openai","openai-api","vcs"],"latest_commit_sha":null,"homepage":"https://book.spell.so","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafalzawadzki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-12T12:45:04.000Z","updated_at":"2025-01-20T12:02:34.000Z","dependencies_parsed_at":"2024-01-06T20:54:54.027Z","dependency_job_id":null,"html_url":"https://github.com/rafalzawadzki/spellbook-forge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafalzawadzki%2Fspellbook-forge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafalzawadzki%2Fspellbook-forge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafalzawadzki%2Fspellbook-forge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafalzawadzki%2Fspellbook-forge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafalzawadzki","download_url":"https://codeload.github.com/rafalzawadzki/spellbook-forge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248270465,"owners_count":21075794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatgpt","chatgpt-api","chatgpt-app","chatgpt3","express","express-middleware","expressjs","gpt","gpt-2","gpt-3","gpt-4","gpt4","gpt4-api","langchain","langchain-typescript","openai","openai-api","vcs"],"created_at":"2024-08-01T16:01:12.443Z","updated_at":"2025-04-10T18:20:36.143Z","avatar_url":"https://github.com/rafalzawadzki.png","language":"TypeScript","funding_links":[],"categories":["Tools","TypeScript","工具"],"sub_categories":["Services","服务"],"readme":"# 🪄📙🔨 Spellbook Forge\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social\u0026label=Follow%20%40SpellHQ)](https://twitter.com/spellhq) [![](https://dcbadge.vercel.app/api/server/R2nTZPGf?compact=true\u0026style=flat)](https://discord.gg/R2nTZPGf)\n\n✨ Make your LLM prompts executable and version controlled. ✨\n\n## Quick Start\n\nIn your Express server:\n\n`yarn add spellbook-forge`\n\n```typescript\nimport { spellbookForge } from \"spellbook-forge\";\n\nconst app = express()\n  .use(spellbookForge({\n    gitHost: 'https://github.com'\n  }))\n```\n\nand then:\n\n```\nGET http://localhost:3000/your/repository/prompt?execute\n\n\u003c-- HTTP 200\n{\n  \"prompt-content\": \"Complete this phrase in coders’ language: Hello …\",\n  \"model\": \"gpt3.5\",\n  \"result\": \"Hello, World!\"\n}\n```\nSee [live examples](#-try-it) to try it out!\n\n## 🤔 What is this?\n\nThis is an [ExpressJS](https://expressjs.com) middleware that allows you to create an API interface for your LLM prompts. \nIt will automatically generate a server for your prompts stored in a git repository. Using Spellbook, you can:\n- Store \u0026 manage LLM prompts in a familiar tool: a git repository\n- Execute prompts with chosen model and get results using a simple API\n- Plug into LangChain templating system\n- Perform basic CRUD operations on prompts\n\n\u003e 💡 **Note:** It's an early version. Expect bugs, breaking changes and poor performance.\n\n## 🚀 Try it\n\n\u003e This prompt repository: https://github.com/rafalzawadzki/spellbook-prompts/hello-world\n\u003e \n\u003e Can be executed like this: https://book.spell.so/rafalzawadzki/spellbook-prompts/hello-world?execute\n\n\n➡️ Spellbook server: https://book.spell.so \n\nThe server uses `spellbook-forge` and is currently hooked up to Github as a git host. You can use any public repository with prompts in it (as long as they adhere to [the accepted format](#-documentation)).\n\nFor example, using a repository [rafalzawadzki/spellbook-prompts](https://github.com/rafalzawadzki/spellbook-prompts), you can form an endpoint ([and many more](#api)):\n\nhttps://book.spell.so/rafalzawadzki/spellbook-prompts/hello-world\n\n## 📖 Documentation\n\n\u003e 💡 Full documentation coming soon!\n\n### OpenAI key\nIf you want to use the `execute` query on your own spellbook-forge instance, you need to provide an OpenAI API key in .env file or env variables:\n```md\nOPENAI_API_KEY=your-key\n```\n\n### Main dependencies\n   1. [🦜🔗 LangChain.js](https://js.langchain.com)\n   2. [simple-git](https://github.com/steveukx/git-js)\n\n### Prompt format\nPrompt files must adhere to a specific format (JSON/YAML). See examples here [here](https://github.com/rafalzawadzki/spellbook-prompts).\n\n#### Example\n\n```jsx\n├── prompt1\n│   ├── prompt.json\n│   └── readme.md\n└── collection\n    └── prompt2\n        ├── prompt.yaml\n        └── readme.md\n```\n\nThe above file structure will result in the following API endpoints being generated:\n\n`{host}/prompt1`\n\n`{host}/collection/prompt2`\n\n#### Files\n1. `prompt.json` the main file with the prompt content and configuration.\n2. `readme.md` additional information about prompt usage, examples etc.\n\n### API\n\n#### CRUD\n\n- `GET` `{host}/path/to/prompt` - get prompt content\n\n- `POST` `{host}/path/to/prompt` - upsert prompt content\n\n- `DELETE` `{host}/path/to/prompt` - delete prompt (along with readme and metadata!)\n\n#### Execution\n\n- `GET` `{host}/path/to/prompt?execute` - for simple prompts without templating\n\n- `POST` `{host}/path/to/prompt?execute` - for prompts with templating (recommended)\n\n```\n// request body\n{\n  \"variables\": [\n    \"name\": \"World\"\n  ]\n}\n```\n\n- `GET` `{host}/path/to/prompt?execute=gpt4` - with different model (not implemented yet)\n\n### Using with LangChain\n\nYou can fetch the prompt content and execute it using LangChain:\n\n```js\nimport { PromptTemplate } from \"langchain/prompts\";\n\nexport const run = async () =\u003e {\n  const template = await fetch(\n          \"https://book.spell.so/rafalzawadzki/spellbook-prompts/hello-world\"\n  ).then((res) =\u003e res.text());\n  const prompt = new PromptTemplate({template, inputVariables: [\"product\"]})\n  // do something with the prompt ...\n}\n```\n\nThe presented solution ofc makes sense mostly in chaining, for simple prompts it's best to just use Spellbook directly!\n\nIn the future I may contribute to extend the [LangChain `prompt/load`](https://js.langchain.com/docs/api/modules/prompts_load) function to support loading prompts from Spellbook, eg:\n\n```js\nimport { loadPrompt } from \"langchain/prompts/load\";\nconst prompt = await loadPrompt(\"{spellbook-host}/hello-world/prompt\");\n```\n\n\n## ☑️ Todo\n- [ ] Documentation\n  - [ ] OpenAI API key\n  - [x] Generated API\n  - [ ] Templating\n  - [x] Using with LangChain\n  - [ ] Prompt format\n  - [ ] Available models\n- [ ] Add missing functionality\n  - [ ] `POST /prompt?execute` with body\n  - [ ] Support for different models, eg. `execute=gpt4`\n  - [ ] Graceful error handling\n  - [ ] Response formatting\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafalzawadzki%2Fspellbook-forge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafalzawadzki%2Fspellbook-forge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafalzawadzki%2Fspellbook-forge/lists"}