From d9a858545b9e156cfc6cb0dab74bb21bf9960301 Mon Sep 17 00:00:00 2001 From: Jessica Temporal Date: Fri, 17 Jan 2025 15:55:10 -0500 Subject: [PATCH] Removes openai-fga example The sample has been moved to https://github.com/oktadev/auth0-ai-samples --- examples/openai-fga/LICENSE | 176 ----- examples/openai-fga/README.md | 76 -- examples/openai-fga/package-lock.json | 736 ------------------ examples/openai-fga/package.json | 21 - examples/openai-fga/scripts/fga-init.ts | 34 - .../openai-fga/src/assets/docs/private-doc.md | 36 - .../openai-fga/src/assets/docs/public-doc.md | 127 --- examples/openai-fga/src/fga-retriever.ts | 101 --- examples/openai-fga/src/helpers.ts | 114 --- examples/openai-fga/src/index.ts | 40 - 10 files changed, 1461 deletions(-) delete mode 100644 examples/openai-fga/LICENSE delete mode 100644 examples/openai-fga/README.md delete mode 100644 examples/openai-fga/package-lock.json delete mode 100644 examples/openai-fga/package.json delete mode 100644 examples/openai-fga/scripts/fga-init.ts delete mode 100644 examples/openai-fga/src/assets/docs/private-doc.md delete mode 100644 examples/openai-fga/src/assets/docs/public-doc.md delete mode 100644 examples/openai-fga/src/fga-retriever.ts delete mode 100644 examples/openai-fga/src/helpers.ts delete mode 100644 examples/openai-fga/src/index.ts diff --git a/examples/openai-fga/LICENSE b/examples/openai-fga/LICENSE deleted file mode 100644 index e6815d1..0000000 --- a/examples/openai-fga/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/examples/openai-fga/README.md b/examples/openai-fga/README.md deleted file mode 100644 index dd8906b..0000000 --- a/examples/openai-fga/README.md +++ /dev/null @@ -1,76 +0,0 @@ -## OpenAI + RAG + Okta FGA - -## Getting Started - -### Prerequisites - -- An Okta FGA account, you can create one [here](https://dashboard.fga.dev). -- An OpenAI account and API key create one [here](https://platform.openai.com). - -### Setup - -1. Create a `.env` file using the format below: - - ```sh - # OpenAI - OPENAI_API_KEY= - - # Okta FGA - FGA_STORE_ID= - FGA_CLIENT_ID= - FGA_CLIENT_SECRET= - # Optional - FGA_API_URL=https://api.xxx.fga.dev - FGA_API_TOKEN_ISSUER=auth.fga.dev - FGA_API_AUDIENCE=https://api.xxx.fga.dev/ - ``` - -#### Obtain OpenAI API Key - -[Use this page for instructions on how to find your OpenAI API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key). Once you have your key, update the `.env` file accordingly. - -#### Configure Okta FGA - -1. Add the model: Under Model Explorer update the model to contain the model below: - - ``` - model - schema 1.1 - - type user - - type doc - relations - define owner: [user] - define viewer: [user, user:*] - define can_view: viewer or owner - define can_edit: owner - - ``` - -2. Create a client: Navigate to _Settings_ and in the _Authorized Clients_ section click **+ Create Client** button. On the new page give your client a name and mark all three client permissions then click **Create**. - -3. Copy the information on the modal and update your `.env` file with the values you now have for `FGA_STORE_ID`, `FGA_CLIENT_ID`, and `FGA_CLIENT_SECRET`. - -### How to run it - -1. Install dependencies. If you want to run with local dependencies follow root instructions. - - ```sh - npm install - ``` - -2. Initialize Okta FGA with the necessary model and tuples. - - ```sh - npm run fga:init - ``` - -3. Running the example - ```sh - npm run dev - ``` - -## License - -Apache-2.0 diff --git a/examples/openai-fga/package-lock.json b/examples/openai-fga/package-lock.json deleted file mode 100644 index 92589c7..0000000 --- a/examples/openai-fga/package-lock.json +++ /dev/null @@ -1,736 +0,0 @@ -{ - "name": "openai-rag-fga", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "openai-rag-fga", - "version": "1.0.0", - "license": "Apache-2.0", - "dependencies": { - "@openfga/sdk": "^0.7.0", - "dotenv": "^16.4.7", - "faiss-node": "^0.5.1", - "openai": "^4.75.0" - } - }, - "node_modules/@openfga/sdk": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@openfga/sdk/-/sdk-0.7.0.tgz", - "integrity": "sha512-sPsRk3SIrSuKscAccadu7BasQvCLQjNR2FW4QlgnDypoGPMWcviuHGf2SfnB34En0lM4ObiEymypkt4z/OxMkA==", - "dependencies": { - "@opentelemetry/api": "^1.9.0", - "axios": "^1.7.5", - "tiny-async-pool": "^2.1.0" - }, - "engines": { - "node": ">=14.17.0" - } - }, - "node_modules/@opentelemetry/api": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", - "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@types/node": { - "version": "18.19.67", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.67.tgz", - "integrity": "sha512-wI8uHusga+0ZugNp0Ol/3BqQfEcCCNfojtO6Oou9iVNGPTL6QNSdnUdqq85fRgIorLhLMuPIKpsN98QE9Nh+KQ==", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/@types/node-fetch": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", - "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", - "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/axios": { - "version": "1.7.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.8.tgz", - "integrity": "sha512-Uu0wb7KNqK2t5K+YQyVCLM76prD5sRFjKHbJYCP1J7JFGEQ6nN7HWn9+04LAeiJ3ji54lgS/gZCH1oxyrf1SPw==", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" - }, - "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/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "engines": { - "node": ">=4.0.0" - } - }, - "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/detect-libc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", - "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/dotenv": { - "version": "16.4.7", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", - "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dependencies": { - "once": "^1.4.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/expand-template": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", - "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/faiss-node": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/faiss-node/-/faiss-node-0.5.1.tgz", - "integrity": "sha512-zD8wobJn8C6OLWo68Unho+Ih8l6nSRB2w3Amj01a+xc4bsEvd2mBDLklAn7VocA9XO3WDvQL/bLpi5flkCn/XQ==", - "hasInstallScript": true, - "dependencies": { - "bindings": "^1.5.0", - "node-addon-api": "^6.0.0", - "prebuild-install": "^7.1.1" - }, - "engines": { - "node": ">= 14.0.0" - } - }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, - "node_modules/follow-redirects": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", - "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", - "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/fs-constants": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" - }, - "node_modules/github-from-package": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" - }, - "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/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" - }, - "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/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" - }, - "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/napi-build-utils": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" - }, - "node_modules/node-abi": { - "version": "3.71.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz", - "integrity": "sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==", - "dependencies": { - "semver": "^7.3.5" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-addon-api": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", - "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" - }, - "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/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/openai": { - "version": "4.75.0", - "resolved": "https://registry.npmjs.org/openai/-/openai-4.75.0.tgz", - "integrity": "sha512-8cWaK3td0qLspaflKWD6AvpQnl0gynWFbHg7sMAgiu//F20I4GJlCCpllDrECO6WFSuY8HXJj8gji3urw2BGGg==", - "dependencies": { - "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.4", - "abort-controller": "^3.0.0", - "agentkeepalive": "^4.2.1", - "form-data-encoder": "1.7.2", - "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7" - }, - "bin": { - "openai": "bin/cli" - }, - "peerDependencies": { - "zod": "^3.23.8" - }, - "peerDependenciesMeta": { - "zod": { - "optional": true - } - } - }, - "node_modules/prebuild-install": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", - "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", - "dependencies": { - "detect-libc": "^2.0.0", - "expand-template": "^2.0.3", - "github-from-package": "0.0.0", - "minimist": "^1.2.3", - "mkdirp-classic": "^0.5.3", - "napi-build-utils": "^1.0.1", - "node-abi": "^3.3.0", - "pump": "^3.0.0", - "rc": "^1.2.7", - "simple-get": "^4.0.0", - "tar-fs": "^2.0.0", - "tunnel-agent": "^0.6.0" - }, - "bin": { - "prebuild-install": "bin.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/pump": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", - "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/simple-concat": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", - "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/simple-get": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", - "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "decompress-response": "^6.0.0", - "once": "^1.3.1", - "simple-concat": "^1.0.0" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/tar-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", - "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dependencies": { - "bl": "^4.0.3", - "end-of-stream": "^1.4.1", - "fs-constants": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tiny-async-pool": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-2.1.0.tgz", - "integrity": "sha512-ltAHPh/9k0STRQqaoUX52NH4ZQYAJz24ZAEwf1Zm+HYg3l9OXTWeqWKyYsHu40wF/F0rxd2N2bk5sLvX2qlSvg==" - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, - "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/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" - }, - "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/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" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - } - } -} diff --git a/examples/openai-fga/package.json b/examples/openai-fga/package.json deleted file mode 100644 index 6b76b61..0000000 --- a/examples/openai-fga/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "openai-rag-fga", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "dev": "npx tsx src/index.ts", - "fga:init": "npx tsx ./scripts/fga-init.ts" - }, - "author": { - "name": "Auth0 Inc.", - "url": "https://auth0.com" - }, - "license": "Apache-2.0", - "dependencies": { - "@openfga/sdk": "^0.7.0", - "dotenv": "^16.4.7", - "faiss-node": "^0.5.1", - "openai": "^4.75.0" - } -} diff --git a/examples/openai-fga/scripts/fga-init.ts b/examples/openai-fga/scripts/fga-init.ts deleted file mode 100644 index fa720b1..0000000 --- a/examples/openai-fga/scripts/fga-init.ts +++ /dev/null @@ -1,34 +0,0 @@ -import "dotenv/config"; - -import { CredentialsMethod, OpenFgaClient } from "@openfga/sdk"; - -/** - * Initializes the OpenFgaClient, writes an authorization model, and configures pre-defined tuples. - * - * This function performs the following steps: - * 1. Creates an instance of OpenFgaClient with the necessary configuration. - * 2. Writes an authorization model with specified schema version and type definitions. - * 3. Configures pre-defined tuples using the newly created authorization model. - */ -async function main() { - const fgaClient = new OpenFgaClient({ - apiUrl: process.env.FGA_API_URL || "https://api.us1.fga.dev", - storeId: process.env.FGA_STORE_ID!, - credentials: { - method: CredentialsMethod.ClientCredentials, - config: { - apiTokenIssuer: process.env.FGA_API_TOKEN_ISSUER || "auth.fga.dev", - apiAudience: process.env.FGA_API_AUDIENCE || "https://api.us1.fga.dev/", - clientId: process.env.FGA_CLIENT_ID!, - clientSecret: process.env.FGA_CLIENT_SECRET!, - }, - }, - }); - - // 01. CONFIGURE PRE-DEFINED TUPLES - await fgaClient.write({ - writes: [{ user: "user:*", relation: "viewer", object: "doc:public-doc" }], - }); -} - -main().catch(console.error); diff --git a/examples/openai-fga/src/assets/docs/private-doc.md b/examples/openai-fga/src/assets/docs/private-doc.md deleted file mode 100644 index 2ed6baa..0000000 --- a/examples/openai-fga/src/assets/docs/private-doc.md +++ /dev/null @@ -1,36 +0,0 @@ -**Zeko Advanced Systems Inc. (Ticker: ZEKO)** -**Forecast for Fiscal Year 2025** - -**Executive Summary:** - -As we look ahead to fiscal year 2025, we maintain a bearish outlook on Zeko Advanced Systems Inc. (ZEKO). Despite the company's stable performance in recent quarters, several factors suggest that ZEKO may underperform the broader market in the coming year. Our analysis considers the company's financial performance, market dynamics, and strategic positioning, which collectively indicate potential headwinds that could hinder growth and profitability. - -**Revenue Growth Challenges:** - -While Zeko reported a modest 2.3% increase in revenue for Q3 2024, this growth rate lags behind industry peers and suggests potential challenges in sustaining momentum. The company's reliance on digital health solutions and AI-driven patient monitoring devices, while innovative, may face increased competition from both established players and new entrants. Additionally, economic uncertainties and geopolitical tensions could dampen demand in key emerging markets, particularly in Asia and the Middle East, where Zeko is focusing its expansion efforts. - -**Margin Pressures:** - -Zeko's gross margin declined slightly to 55% in Q3 2024, primarily due to rising raw material costs and ongoing supply chain disruptions. These pressures are expected to persist into 2025, further compressing margins and impacting profitability. Additionally, the company's significant investment in research and development, while necessary for innovation, may not yield immediate returns, thereby straining operating margins. - -**Operational and Strategic Concerns:** - -Despite Zeko's commitment to innovation and strategic partnerships, the pace of product development and market adoption may not be sufficient to drive significant revenue growth. The introduction of new AI-driven platforms and minimally invasive surgical technologies, while promising, may face regulatory hurdles and require extensive validation before achieving widespread adoption. Furthermore, the company's expansion into emerging markets presents inherent risks, including currency fluctuations and regulatory challenges. - -**Financial Outlook:** - -- **Revenue:** We project Zeko's revenue growth to remain subdued, with an estimated increase of 2-3% for fiscal year 2025. This projection reflects the anticipated competitive pressures and macroeconomic uncertainties that could limit market expansion. - -- **Net Income:** Net income growth is expected to be modest, with potential headwinds from increased operational costs and margin pressures. We forecast a net income increase of 1-2% year-over-year. - -- **Earnings Per Share (EPS):** Given the expected challenges in revenue and net income growth, we anticipate EPS to grow at a similar rate of 1-2%, potentially reaching $1.64 to $1.65 for fiscal year 2025. - -- **Gross Margin:** Gross margin is likely to remain under pressure, potentially declining further to 54-55% as cost challenges persist. - -**Conclusion:** - -In conclusion, while Zeko Advanced Systems Inc. continues to demonstrate resilience and a commitment to innovation, the company faces significant challenges that may impede its ability to outperform the market in fiscal year 2025. Investors should remain cautious and consider these potential headwinds when evaluating ZEKO as an investment opportunity. The company's strategic focus on emerging markets and new product development, while commendable, may not deliver the desired financial performance in the near term. As such, we maintain a bearish outlook on Zeko's prospects for the upcoming fiscal year. - ---- - -**Note:** This document is purely fictional and is generated for the purpose of a mock or example use case. All names, technologies, and concepts mentioned are invented. diff --git a/examples/openai-fga/src/assets/docs/public-doc.md b/examples/openai-fga/src/assets/docs/public-doc.md deleted file mode 100644 index bbc44cb..0000000 --- a/examples/openai-fga/src/assets/docs/public-doc.md +++ /dev/null @@ -1,127 +0,0 @@ -# Zeko Advanced Systems Inc. Documentation - -## Table of Contents - -1. **Introduction** -2. **Company Overview** -3. **Core Technologies** -4. **Products & Services** -5. **Research & Development** -6. **Corporate Governance** - ---- - -## 1. **Introduction** - -Welcome to the official documentation for **Zeko Advanced Systems Inc.**. This document provides an overview of our company, the technologies we develop, the products we offer, and our corporate structure. Zeko Advanced Systems Inc. is a pioneering organization at the cutting edge of technological innovation, specializing in high-performance computing, artificial intelligence, and advanced robotics. - ---- - -## 2. **Company Overview** - -**Zeko Advanced Systems Inc.** (ZAS) was founded in 2011 by a group of visionary engineers and entrepreneurs dedicated to creating the next generation of intelligent systems. Based in Silicon Valley, California, Zeko has grown into a leading force in the tech industry, delivering groundbreaking solutions in multiple sectors including aerospace, defense, healthcare, and consumer technology. - -### Mission Statement - -Our mission is to revolutionize industries by delivering advanced systems that combine artificial intelligence, machine learning, and quantum computing. We aim to enhance human capability and improve the quality of life for people around the world. - -### Vision - -We envision a future where intelligent systems drive progress in every field, from autonomous vehicles to personalized healthcare, making the impossible possible. - ---- - -## 3. **Core Technologies** - -At Zeko Advanced Systems Inc., we specialize in developing a suite of cutting-edge technologies that push the boundaries of what is possible. - -### **Quantum Computing** - -Our quantum computing division is at the forefront of developing scalable, fault-tolerant quantum processors. Zeko's proprietary QuantumFusion™ technology promises to revolutionize industries by enabling unprecedented computational power for complex simulations, cryptography, and data analysis. - -### **Artificial Intelligence** - -Our AI platforms leverage deep learning, neural networks, and natural language processing to deliver innovative solutions for automation, predictive analytics, and intelligent decision-making. Zeko’s AI systems are deployed in sectors such as financial services, manufacturing, and autonomous driving. - -### **Autonomous Robotics** - -Zeko’s robotics division specializes in creating highly intelligent, autonomous robots capable of performing complex tasks in dynamic environments. Our robots are utilized in various fields, including logistics, healthcare, and hazardous material handling. - -### **Cybersecurity Solutions** - -Zeko Advanced Systems Inc. offers a comprehensive range of cybersecurity products designed to protect enterprises against emerging threats. Our ZeroTrust™ security architecture provides multi-layered protection across cloud infrastructure, endpoints, and internal networks. - ---- - -## 4. **Products & Services** - -Zeko Advanced Systems Inc. provides a diverse array of products and services tailored to meet the specific needs of different industries. - -### **Zeko Axiom™ (Quantum Processor)** - -The Zeko Axiom™ is a state-of-the-art quantum processor designed for high-performance computing tasks, capable of solving complex problems that would take traditional supercomputers millennia to process. - -### **Zeko NeuralNet™ (AI Platform)** - -Our Zeko NeuralNet™ platform is an all-in-one artificial intelligence suite that helps businesses streamline operations, optimize decision-making, and build smarter systems. It includes machine learning models, pre-trained algorithms, and customizable templates for deployment. - -### **Zeko RoboFleet™ (Autonomous Vehicles)** - -The Zeko RoboFleet™ is a fleet of autonomous, electric vehicles designed for commercial applications, including logistics, delivery, and public transportation. Equipped with cutting-edge sensors and AI, RoboFleet™ operates safely in urban environments. - -### **Zeko SecureShield™ (Cybersecurity Suite)** - -Zeko SecureShield™ is an enterprise-grade cybersecurity solution that integrates artificial intelligence with advanced encryption technologies to safeguard your data against the latest threats. With real-time threat detection and response, it provides a 360-degree defense perimeter for your organization. - -### **Zeko CloudX™ (Cloud Computing Services)** - -Zeko CloudX™ is our scalable cloud infrastructure platform that powers businesses with reliable storage, processing power, and seamless data management. Optimized for AI workloads and quantum computing, CloudX™ offers a flexible environment for developing and deploying next-gen applications. - ---- - -## 5. **Research & Development** - -Zeko Advanced Systems Inc. is committed to continuous innovation. Our R&D department plays a pivotal role in ensuring that our technologies remain on the cutting edge. We invest over 30% of our annual revenue into R&D to explore new solutions, improve existing products, and identify future industry needs. - -### Key R&D Focus Areas: - -- **Quantum Machine Learning:** We are developing quantum-enhanced machine learning models that can outperform classical systems in data analysis and pattern recognition. -- **AI-Driven Robotics:** Our team is working on next-gen autonomous robots that can adapt in real-time to changing environments and learn from experience. -- **Advanced Materials for Quantum Hardware:** Our materials science team is exploring novel compounds for the development of more stable, energy-efficient quantum processors. - ---- - -## 6. **Corporate Governance** - -Zeko Advanced Systems Inc. is governed by a team of seasoned executives and industry experts. Our leadership is dedicated to ensuring the long-term growth of the company, while maintaining high standards of ethics and responsibility. - -### **Board of Directors:** - -- **Elliott Zeko** - CEO & Founder -- **Dr. Helena Wong** - Chief Technology Officer (CTO) -- **Sarah Perez** - Chief Financial Officer (CFO) -- **Dr. Alan Tan** - Chief Operating Officer (COO) -- **Rebecca Knight** - Chief Marketing Officer (CMO) - -### **Executive Leadership Team:** - -- **John Carver** - Senior Vice President of Research & Development -- **Samantha Lee** - Vice President of AI & Robotics -- **Marcus Holt** - Vice President of Cloud & Cybersecurity Solutions -- **Emily Jordan** - Vice President of Strategic Partnerships - ---- - -## 7. **Partnerships & Collaborations** - -Zeko Advanced Systems Inc. is proud to collaborate with a variety of industry leaders, research institutions, and government agencies. Our strategic partnerships allow us to leverage combined expertise and drive forward-thinking solutions. - -### Notable Partnerships: - -- **NASA**: Joint development of autonomous systems for space exploration missions. -- **MIT AI Lab**: Collaborative research into artificial general intelligence (AGI) and machine learning. -- **Tesla**: Integration of Zeko’s AI platform into Tesla's autonomous driving systems. - ---- - -**Note:** This document is purely fictional and is generated for the purpose of a mock or example use case. All names, technologies, and concepts mentioned are invented. diff --git a/examples/openai-fga/src/fga-retriever.ts b/examples/openai-fga/src/fga-retriever.ts deleted file mode 100644 index 6b67761..0000000 --- a/examples/openai-fga/src/fga-retriever.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { - ClientCheckRequest, - ConsistencyPreference, - CredentialsMethod, - OpenFgaClient, -} from "@openfga/sdk"; - -import { Document, DocumentWithScore } from "./helpers"; - -export type FGARetrieverCheckerFn = (document: Document) => { - user: string; - object: string; - relation: string; -}; - -export interface FGARetrieverProps { - buildQuery: FGARetrieverCheckerFn; - documents: DocumentWithScore[]; -} - -export class FGARetriever { - private buildQuery: FGARetrieverCheckerFn; - private fgaClient: OpenFgaClient; - private documents: DocumentWithScore[]; - - private constructor( - { buildQuery, documents }: FGARetrieverProps, - fgaClient?: OpenFgaClient - ) { - this.documents = documents; - this.buildQuery = buildQuery; - this.fgaClient = - fgaClient || - new OpenFgaClient({ - apiUrl: process.env.FGA_API_URL || "https://api.us1.fga.dev", - storeId: process.env.FGA_STORE_ID!, - credentials: { - method: CredentialsMethod.ClientCredentials, - config: { - apiTokenIssuer: process.env.FGA_API_TOKEN_ISSUER || "auth.fga.dev", - apiAudience: - process.env.FGA_API_AUDIENCE || "https://api.us1.fga.dev/", - clientId: process.env.FGA_CLIENT_ID!, - clientSecret: process.env.FGA_CLIENT_SECRET!, - }, - }, - }); - } - - static create( - { buildQuery, documents }: FGARetrieverProps, - fgaClient?: OpenFgaClient - ) { - return new FGARetriever({ buildQuery, documents }, fgaClient); - } - - private async checkPermissions( - requests: ClientCheckRequest[] - ): Promise> { - const batchCheckResponse = await this.fgaClient.batchCheck(requests, { - consistency: ConsistencyPreference.HigherConsistency, - }); - - return batchCheckResponse.responses.reduce( - (permissionMap: Map, response) => { - permissionMap.set(response._request.object, response.allowed || false); - return permissionMap; - }, - new Map() - ); - } - - async retrieve(): Promise { - const retrievedNodes = this.documents; - - const { checks, documentToObjectMap } = retrievedNodes.reduce( - (accumulator, documentWithScore: DocumentWithScore) => { - const permissionCheck = this.buildQuery(documentWithScore.document); - accumulator.checks.push(permissionCheck); - accumulator.documentToObjectMap.set( - documentWithScore.document, - permissionCheck.object - ); - return accumulator; - }, - { - checks: [] as ClientCheckRequest[], - documentToObjectMap: new Map(), - } - ); - - const permissionsMap = await this.checkPermissions(checks); - - return retrievedNodes.filter( - (documentWithScore) => - permissionsMap.get( - documentToObjectMap.get(documentWithScore.document) || "" - ) === true - ); - } -} diff --git a/examples/openai-fga/src/helpers.ts b/examples/openai-fga/src/helpers.ts deleted file mode 100644 index cdba575..0000000 --- a/examples/openai-fga/src/helpers.ts +++ /dev/null @@ -1,114 +0,0 @@ -import * as faiss from "faiss-node"; -import fs from "fs"; -import OpenAI from "openai"; - -const EMBEDDING_MODEL = "text-embedding-3-large"; -const MODEL = "gpt-4o-mini"; - -export type Document = { - id: string; - text: string; -}; - -export type DocumentWithScore = { - document: Document; - score: number; -}; - -export function readDocuments() { - function readDoc(path: string) { - return fs.readFileSync(path, "utf-8"); - } - - const document1 = { - id: "public-doc", - text: readDoc("./src/assets/docs/public-doc.md"), - }; - const document2 = { - id: "private-doc", - text: readDoc("./src/assets/docs/private-doc.md"), - }; - - return [document1, document2]; -} - -export const LocalVectorStore = { - fromDocuments: async (documents: Document[]) => { - const openai = new OpenAI(); - const indexFilename = "faiss_index.index"; - let index: faiss.IndexFlatIP; - - if (fs.existsSync(indexFilename)) { - index = faiss.IndexFlatIP.read(indexFilename); - } else { - const documentEmbeddings = await Promise.all( - documents.map(async (document) => { - const embeddingResponse = await openai.embeddings.create({ - model: EMBEDDING_MODEL, - input: document.text, - encoding_format: "float", - }); - - return embeddingResponse.data[0].embedding; - }) - ); - - const dimension = documentEmbeddings[0].length; - index = new faiss.IndexFlatIP(dimension); - - documentEmbeddings.forEach((embedding) => { - index.add(embedding); - }); - - index.write(indexFilename); - } - - return { - search: async (query: string, k: number = 2) => { - const queryEmbeddingResponse = await openai.embeddings.create({ - model: EMBEDDING_MODEL, - input: query, - encoding_format: "float", - }); - const { labels, distances } = index.search( - queryEmbeddingResponse.data[0].embedding, - k - ); - - const threshold = 0.2; - const retrievedDocuments = labels - .map((label: number, index: number) => ({ - label, - distance: distances[index], - })) - .filter(({ distance }) => distance >= threshold) - .map(({ label, distance }) => ({ - document: documents[label], - score: distance, - })); - - return retrievedDocuments; - }, - }; - }, -}; - -export async function generate(query: string, context: DocumentWithScore[]) { - const openai = new OpenAI(); - const response = await openai.chat.completions.create({ - model: MODEL, - messages: [ - { - role: "system", - content: ` - Context: ${context.map((d) => d.document.text).join("\n\n")}. - Use only the context provided to answer the question. - If you don't know, do not make up an answer. - `, - }, - { role: "user", content: query }, - ], - }); - - return response.choices[0].message.content; -} diff --git a/examples/openai-fga/src/index.ts b/examples/openai-fga/src/index.ts deleted file mode 100644 index db9de17..0000000 --- a/examples/openai-fga/src/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import "dotenv/config"; - -import { FGARetriever } from "./fga-retriever"; -import { generate, LocalVectorStore, readDocuments } from "./helpers"; - -async function main() { - // User ID - const user = "user1"; - // User query - const query = "Show me forecast for ZEKO?"; - - // 1. RAG pipeline - const documents = readDocuments(); - // `LocalVectorStore` is a helper function that creates a Faiss index - // and uses OpenAI embeddings API to encode the documents. - const vectorStore = await LocalVectorStore.fromDocuments(documents); - - // 2. Create an instance of the FGARetriever - const retriever = FGARetriever.create({ - documents: await vectorStore.search(query), - buildQuery: (doc) => ({ - user: `user:${user}`, - object: `doc:${doc.id}`, - relation: "can_view", - }), - }); - - // 3. Filter documents based on user permissions - const context = await retriever.retrieve(); - - // 4. Generate a response based on the context - // `generate` is a helper function that takes a query and a context and returns - // a response using OpenAI chat completion API. - const answer = await generate(query, context); - - // 5. Print the answer - console.log(answer); -} - -main().catch(console.error);