diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..d7784252 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,22 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/package.json b/package.json index 49bb134e..63500287 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,15 @@ { - "name": "instructor", + "name": "instructor-js", "version": "0.0.1", "description": "structured outputs for llms", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, + "publishConfig": { + "access": "public" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "prepublish": "tsc", @@ -26,7 +32,7 @@ }, "homepage": "https://github.com/jxnl/instructor-js#readme", "dependencies": { - "openai": "^4.24.1", + "openai": "^4.24.1", "zod": "^3.22.4", "zod-to-json-schema": "^3.22.3" }, diff --git a/src/patch.ts b/src/patch.ts index 7d88abef..6144a4ed 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -181,6 +181,7 @@ export const patch = ({ ); delete args[0].response_model; delete args[0].max_retries; + while (retries < max_retries) { try { response = (await target.apply( diff --git a/tsconfig.json b/tsconfig.json index 1a311b8d..7ac961f2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,5 +11,5 @@ "declaration": true }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "exclude": ["examples", "node_modules", "dist"] } \ No newline at end of file