{"id":16923892,"url":"https://github.com/robatwilliams/openai-excel-functions","last_synced_at":"2025-03-22T11:31:02.009Z","repository":{"id":212318187,"uuid":"731197847","full_name":"robatwilliams/openai-excel-functions","owner":"robatwilliams","description":"Create OpenAI chat completions from Excel formulas","archived":false,"fork":false,"pushed_at":"2024-01-22T16:39:06.000Z","size":265,"stargazers_count":39,"open_issues_count":7,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-18T10:51:32.710Z","etag":null,"topics":["excel-addin","excel-functions","genai","generative-ai","openai","openai-api","prompt-decompoosition","prompt-engineering"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robatwilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-13T14:55:36.000Z","updated_at":"2025-03-18T08:46:50.000Z","dependencies_parsed_at":"2023-12-21T13:54:13.775Z","dependency_job_id":"825c3edf-15ac-40a9-8979-69752190204c","html_url":"https://github.com/robatwilliams/openai-excel-functions","commit_stats":null,"previous_names":["robatwilliams/openai-excel-formulas","robatwilliams/openai-excel-functions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robatwilliams%2Fopenai-excel-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robatwilliams%2Fopenai-excel-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robatwilliams%2Fopenai-excel-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robatwilliams%2Fopenai-excel-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robatwilliams","download_url":"https://codeload.github.com/robatwilliams/openai-excel-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244951231,"owners_count":20537342,"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":["excel-addin","excel-functions","genai","generative-ai","openai","openai-api","prompt-decompoosition","prompt-engineering"],"created_at":"2024-10-13T20:01:02.143Z","updated_at":"2025-03-22T11:31:01.418Z","avatar_url":"https://github.com/robatwilliams.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAI API Functions for Excel\n\n\u003e Create OpenAI chat completions from Excel formulas\n\nDeveloper oriented Excel add-in that provides `=OAI.CHAT_COMPLETE()` to call the completions API, and helpers. Use the power of spreadsheets for prompt engineering, prompt decomposition, prototyping systems, and more.\n\n## Why this add-in\n\n- Free - use your own API key\n- Confidential - calls go directly to OpenAI's API\n- Comprehensive - supports all models and parameters\n- Observable - view and use all API request and response data\n- Open source\n\nBuilt with generative AI developers in mind - other products are available which may be more suitable for using generative AI in general spreadsheets. As a rule, we don't include convenience functions for tasks that can be reasonably accomplished using built-in Excel functions.\n\n## Blog\n\nRead our post [Prompt engineering with spreadsheets](https://blog.scottlogic.com/2024/01/10/prompt-engineering-with-spreadsheets.html) on the Scott Logic blog, where you'll also find much more about [artificial intelligence](https://blog.scottlogic.com/category/ai.html) and all things software.\n\n## Installation\n\nThe add-in is installed via a \"sideloading\" process, in which you load the manifest file into Excel, which then loads the add-in code directly from GitHub. It's not published to the Office Store.\n\nFirst, download the [`manifest.xml`](./manifest.xml) file. You won't need to modify this or download anything else - disregard any such instructions in the following linked instructions.\n\nFollow the [sideloading instructions for your platform](https://learn.microsoft.com/en-us/office/dev/add-ins/testing/test-debug-office-add-ins#sideload-an-office-add-in-for-testing):\n\n- On web, use the \"manually sideload\" technique.\n- On Windows, use the \"configure trust manually\" option at the relevant step.\n\nType `=OAI.` in the formula bar or a cell, and you should see the new functions.\n\n\u003cdetails\u003e\n\u003csummary\u003eUninstallation\u003c/summary\u003e\n\nOn web, clear your browser's cookies for its domain.\n\nFor other platforms, [clear the Office cache](https://learn.microsoft.com/en-us/office/dev/add-ins/testing/clear-cache).\n\n\u003c/details\u003e\n\n## Usage\n\n`OAI.CHAT_COMPLETE()` calls the API to create completions. It is typical to setup a sheet containing parameters for the model call. The first column is used as parameter keys and the second as values. The API_KEY parameter is required and its value should be sourced from the OpenAI console.\n\n`OAI.COST()` calculates the billing cost(s) of completion cell(s). Wrap it with `SUM()` to calculate a total.\n\nSee the [function metadata](https://github.com/robatwilliams/openai-excel-functions/blob/main/src/functions/functions.json) for full documentation of functions and parameters. Excel's presentation of custom function documentation varies in completeness by platform, but is best in the _Insert Function_ dialog and/or the desktop platform.\n\n\u003c!-- prettier-ignore --\u003e\n\u003e [!CAUTION]\n\u003e We advise caution to avoid unintentionally incurring excessive costs when working with many completion cells or expensive completions. Changes to dependency cells can cause mass recalculation, and certain actions in Excel can trigger full recalculation. You may wish to switch the calculation mode in Excel from automatic to manual. A maximum of 10 API requests are made in parallel - to cancel waiting or pending requests, undo your change or delete the formula.\n\n## Using completion results\n\nCompletions populate the cell with a custom data type which includes the complete API request and response. Its text value is the content of the first completion choice.\n\nTo obtain the text value for use in formulas, use the `VALUETOTEXT()` function. To obtain other request/response data, use dot notation to the property path (e.g. `A123.response.model`).\n\nTo view the completion data, open the entity card. The `lines` property provides a line-by-line view of the completion content.\n\nTo extract a final answer that follows a chain of thought, you could use a formula such as:\n\n```\n=TEXTAFTER(VALUETOTEXT(A123), \"\u003c!-- END CoT --\u003e\" \u0026 CHAR(10))\n```\n\n## Add-in development\n\n\u003cdetails\u003e\n\u003csummary\u003eInstructions for getting started with development work\u003c/summary\u003e\n\n### Prerequisites\n\nIf you're on Windows, configure NPM to use a sh-compatible shell, e.g:\n\n```bash\nnpm config set script-shell \"C:\\\\Program Files\\\\git\\\\bin\\\\bash.exe\"\n```\n\nConfigure your IDE to adhere to the project code formatting. For VSCode, these will be loaded from the workspace settings in `.vscode/`; for other editors/IDEs you'll need to configure equivalently. You may need to unset/disable any personal settings or extensions that interfere.\n\n### Install and run\n\n1. Install the npm dependencies (`npm i`)\n1. Generate and install certificates (`npm run install-certs`)\n1. Run the local server (`npm start`).\n\nAdditionally you may need to navigate to the [root](https://localhost:3000/) in your browser and temporarily trust the newly created cert-key pair.\n\n### Open in Excel web\n\n1. Open a spreadsheet in Excel on the web and append the following query string parameters\n\n```\nwdaddindevserverport=3000\u0026wdaddinmanifestfile=manifest-localhost.xml\u0026wdaddinmanifestguid=00aeeb98-f4d9-4db0-a1e6-cdc652c08e34\n```\n\n2. If you are prompted to enable Excel developer mode, do so.\n\nYou should now be able to use the functions as normal. When you make a change, you'll need to reload the browser window.\n\n### Open in Excel desktop\n\n```bash\nnpm run sideload:desktop\n```\n\n### Key files\n\n| Path | Description |\n| --- | --- |\n| src/functions/functions.json | The metadata which details each function and references its implementation. |\n| src/functions/functions.mjs | The JavaScript functions which implement the functions. |\n| shared.html | Root page loaded in the background during add-in startup. |\n| manifest-local.xml | A version of manifest.xml which references https://localhost:3000/ for add-in development use. |\n| manifest.xml | Configures where the add-in should be loaded from and what features it will make use of. |\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobatwilliams%2Fopenai-excel-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobatwilliams%2Fopenai-excel-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobatwilliams%2Fopenai-excel-functions/lists"}