diff --git a/.github/workflows/canary.yaml b/.github/workflows/canary.yaml index 0b74431f..59242098 100644 --- a/.github/workflows/canary.yaml +++ b/.github/workflows/canary.yaml @@ -130,6 +130,27 @@ jobs: - name: Test run: wing test working-directory: ngrok + canary-openai: + name: Test openai + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + sparse-checkout: openai + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org + - name: Install winglang + run: npm i -g winglang + - name: Install dependencies + run: npm install --include=dev + working-directory: openai + - name: Test + run: wing test + working-directory: openai canary-postgres: name: Test postgres runs-on: ubuntu-latest diff --git a/.github/workflows/openai-pull.yaml b/.github/workflows/openai-pull.yaml new file mode 100644 index 00000000..ddadbd14 --- /dev/null +++ b/.github/workflows/openai-pull.yaml @@ -0,0 +1,29 @@ +name: openai-pull +on: + pull_request: + paths: + - openai/** +jobs: + build-openai: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + sparse-checkout: openai + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org + - name: Install winglang + run: npm i -g winglang + - name: Install dependencies + run: npm install --include=dev + working-directory: openai + - name: Test + run: wing test + working-directory: openai + - name: Pack + run: wing pack + working-directory: openai diff --git a/.github/workflows/openai-release.yaml b/.github/workflows/openai-release.yaml new file mode 100644 index 00000000..3f61b2fe --- /dev/null +++ b/.github/workflows/openai-release.yaml @@ -0,0 +1,54 @@ +name: openai-release +on: + push: + branches: + - main + paths: + - openai/** + - "!openai/package-lock.json" +jobs: + build-openai: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + sparse-checkout: openai + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org + - name: Install winglang + run: npm i -g winglang + - name: Install dependencies + run: npm install --include=dev + working-directory: openai + - name: Test + run: wing test + working-directory: openai + - name: Pack + run: wing pack + working-directory: openai + - name: Get package version + run: echo WINGLIB_VERSION=$(node -p "require('./package.json').version") >> + "$GITHUB_ENV" + working-directory: openai + - name: Publish + run: npm publish --access=public --registry https://registry.npmjs.org --tag + latest *.tgz + working-directory: openai + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Tag commit + uses: tvdias/github-tagger@v0.0.1 + with: + repo-token: ${{ secrets.PROJEN_GITHUB_TOKEN }} + tag: openai-v${{ env.WINGLIB_VERSION }} + - name: GitHub release + uses: softprops/action-gh-release@v1 + with: + name: openai v${{ env.WINGLIB_VERSION }} + tag_name: openai-v${{ env.WINGLIB_VERSION }} + files: "*.tgz" + token: ${{ secrets.PROJEN_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 783e1112..6a5f24e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/node_modules/** target/ **/.env +.history/ diff --git a/.mergify.yml b/.mergify.yml index 883ffa44..b10827f4 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -53,6 +53,9 @@ pull_request_rules: - -check-failure=build-ngrok - -check-pending=build-ngrok - -check-stale=build-ngrok + - -check-failure=build-openai + - -check-pending=build-openai + - -check-stale=build-openai - -check-failure=build-postgres - -check-pending=build-postgres - -check-stale=build-postgres @@ -104,6 +107,9 @@ pull_request_rules: - -check-failure=build-ngrok - -check-pending=build-ngrok - -check-stale=build-ngrok + - -check-failure=build-openai + - -check-pending=build-openai + - -check-stale=build-openai - -check-failure=build-postgres - -check-pending=build-postgres - -check-stale=build-postgres diff --git a/README.md b/README.md index c2d0bf00..34721530 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ Clone this repository: git clone git@github.com:winglang/winglibs ``` +Change to the `winglibs` directory: + +```sh +cd winglibs +``` + Use the fabulous `mklib.sh` script to scaffold your library: ```sh @@ -74,6 +80,9 @@ bring my-awesome-lib ## Writing Wing Libraries See [docs](https://www.winglang.io/docs/libraries#creating-a-wing-library). + +Please note that it refers to writing libraries that are not published here, so it includes instructions for things that you get here automatically when using the `mklib.sh` script to scaffold your library. + ## License This repository is licensed under the [MIT License](./LICENSE), unless otherwise specified in a diff --git a/openai/.gitignore b/openai/.gitignore new file mode 100644 index 00000000..cd2c33bc --- /dev/null +++ b/openai/.gitignore @@ -0,0 +1,3 @@ +target/ +node_modules/ +.history/ diff --git a/openai/LICENSE b/openai/LICENSE new file mode 100644 index 00000000..a875f479 --- /dev/null +++ b/openai/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Wing + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/openai/README.md b/openai/README.md new file mode 100644 index 00000000..36bdc3d7 --- /dev/null +++ b/openai/README.md @@ -0,0 +1,45 @@ +# openai + +## Prerequisites + +* [winglang](https://winglang.io). + +## Installation + +`sh +npm i @winglibs/openai +` + +## Example + +`js +bring openai; + +let openAIService = new openai.OpenAI("your-api-key"); + +new cloud.Function(inflight () => { + let joke = openAIService.createCompletion("tell me a short joke"); + log(joke); +}); +` + +## Usage +The `openai.OpenAI` resource provides the following inflight methods: + +* `createCompletion` - Gets an answer to a prompt. + +The preflight constructor requires an api key in the form of either a secret or a string. + +## Roadmap + +* [x] Support the rest of the openai API +* [ ] Add more examples +* [ ] Add more tests + +## Maintainers + +* [Shai Ber](https://github.com/shaiber) + +## License + +Licensed under the [MIT License](/LICENSE). diff --git a/openai/api.w b/openai/api.w new file mode 100644 index 00000000..8a61690e --- /dev/null +++ b/openai/api.w @@ -0,0 +1,9 @@ +pub struct CompletionParams { + model: str; + max_tokens: num; +} + +// TODO: need to recreate the openai interface with higher fidelity +pub interface IOpenAI extends std.IResource { + inflight createCompletion(prompt: str, params: CompletionParams?): str; +} diff --git a/openai/openai.js b/openai/openai.js new file mode 100644 index 00000000..25eda35d --- /dev/null +++ b/openai/openai.js @@ -0,0 +1,42 @@ +const openai = require('openai'); + +exports.createNewInflightClient = (apiKey, org) => { + const config = { + apiKey: apiKey + }; + + if (org) { + config.organization = org; + } + + let client = new openai.OpenAI(config); + + // TODO: this is a hack for now, we should model the openai api in the api.w file with more fidelity + // and then we can just return the client itself, like we do in redis + return { + createCompletion: async (prompt, params = { model: "gpt-3.5-turbo", max_tokens: 2048 }) => { + if (!prompt) { + throw new Error("Prompt is required"); + }; + + if (typeof prompt !== "string") { + throw new Error("Prompt must be a string"); + } + + if (!params.model) { + params.model = "gpt-3.5-turbo"; + }; + + if (!params.max_tokens) { + params.max_tokens = 2048; + } + + params.messages = [{role: 'user', content: prompt}]; + + const response = await client.chat.completions.create(params); + + return response.choices[0]?.message?.content; + } + }; +}; + diff --git a/openai/openai.test.w b/openai/openai.test.w new file mode 100644 index 00000000..bbf2628c --- /dev/null +++ b/openai/openai.test.w @@ -0,0 +1,21 @@ +bring expect; +bring "./openai.w" as openai; + +let client = new openai.OpenAI(); + +// This test currently doesn't pass because of issue https://github.com/winglang/wing/issues/5948 +// test "cant create client without key" { +// let var errorMessage = ""; +// try { +// let answer = client.createCompletion("tell me a short joke"); +// } catch e { +// errorMessage = e; +// } +// expect.equal(errorMessage, "OpenAI API key is required"); +// } + +// This test currently cannot pass because we can't pass credentials to it in the test runner +// test "basic completion" { +// let answer = client.createCompletion("tell me a short joke"); +// expect.notNil(answer); +// } diff --git a/openai/openai.w b/openai/openai.w new file mode 100644 index 00000000..58433b17 --- /dev/null +++ b/openai/openai.w @@ -0,0 +1,45 @@ +bring util; +bring "./api.w" as api; +bring "./utils.w" as utils; +bring cloud; + +pub class OpenAI impl api.IOpenAI { + apiKey: cloud.Secret?; + org: cloud.Secret?; + keyOverride: str?; + orgOverride: str?; + + inflight openai: api.IOpenAI; + + new (apiKey: str?, org: str?, apiKeySecret: cloud.Secret?, orgSecret: cloud.Secret?) { + this.apiKey = apiKeySecret; + this.org = orgSecret; + this.keyOverride = apiKey; + this.orgOverride = org; + } + + inflight new() { + // I wanted to write this thing like this: + // let apiKey: str? = this.keyOverride ?? this.apiKey?.value(); + // I was even willing to settle for this: + // let apiKey: str? = this.keyOverride ?? this.apiKey?.value(); + // But neither of those work. So I'm doing this instead after opening issue https://github.com/winglang/wing/issues/5944: + let var apiKey = this.keyOverride; + if (apiKey == nil){ + apiKey = this.apiKey?.value(); + } + if (apiKey == nil || apiKey == ""){ + throw "OpenAI API key is required"; + } + let var org: str? = this.orgOverride; + if (org == nil){ + org = this.org?.value(); + } + + this.openai = utils.createNewInflightClient(apiKey!, org); + } + + pub inflight createCompletion(prompt: str, params: api.CompletionParams?): str { + return this.openai.createCompletion(prompt, params); + } +} diff --git a/openai/package-lock.json b/openai/package-lock.json new file mode 100644 index 00000000..0a52ec44 --- /dev/null +++ b/openai/package-lock.json @@ -0,0 +1,290 @@ +{ + "name": "@winglibs/openai", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@winglibs/openai", + "version": "0.0.1", + "license": "MIT", + "dependencies": { + "openai": "^4.28.4" + } + }, + "node_modules/@types/node": { + "version": "18.19.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.24.tgz", + "integrity": "sha512-eghAz3gnbQbvnHqB+mgB2ZR3aH6RhdEmHGS48BnV75KceQPHqabkxKI0BbUSsqhqy2Ddhc2xD/VAR9ySZd57Lw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "engines": { + "node": "*" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "engines": { + "node": "*" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/digest-fetch": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", + "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==", + "dependencies": { + "base-64": "^0.1.0", + "md5": "^2.3.0" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/formdata-node/node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "engines": { + "node": ">= 14" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/openai": { + "version": "4.28.4", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.28.4.tgz", + "integrity": "sha512-RNIwx4MT/F0zyizGcwS+bXKLzJ8QE9IOyigDG/ttnwB220d58bYjYFp0qjvGwEFBO6+pvFVIDABZPGDl46RFsg==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + }, + "bin": { + "openai": "bin/cli" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/openai/package.json b/openai/package.json new file mode 100644 index 00000000..1b4621ad --- /dev/null +++ b/openai/package.json @@ -0,0 +1,17 @@ +{ + "name": "@winglibs/openai", + "version": "0.0.1", + "repository": { + "type": "git", + "url": "https://github.com/winglang/winglibs.git", + "directory": "openai" + }, + "author": { + "email": "shaib@wing.cloud", + "name": "Shai Ber" + }, + "license": "MIT", + "dependencies": { + "openai": "^4.28.4" + } +} diff --git a/openai/utils.w b/openai/utils.w new file mode 100644 index 00000000..1f080534 --- /dev/null +++ b/openai/utils.w @@ -0,0 +1,5 @@ +bring "./api.w" as api; + +pub class Util { + extern "./openai.js" pub static inflight createNewInflightClient(apiKey: str, org: str?): api.IOpenAI; +} \ No newline at end of file