ts\nimport { GpTs } from 'gpts-wrapper';\nconst brain = new GpTs(OPENAI_APIKEY); // dont publish your api key!\n\nconst thoughts = brain.completion({\n\tengineId: 'ada',\n\tprompt: 'whats for lunch?',\n});\n\nconsole.log(thoughts.choices[0].text); // "maybe a banana?"\n
\n\nalso see demo/index.ts (need to insert your api key to run)\n\n---\n\n## install\n\n### npm\n\nnpm i gpts-wrapper
\n\n### github\n\npackage.json
\n\njson\n\t"dependencies": {\n\t\t"gpts-wrapper": "UXTQ/gpts-wrapper",\n\t\t...\n\t},\n
\n\n---\n\n## features\n\n- engines\n - list ✅\n - retreive ✅\n- completions\n - create ✅\n - stream engineId
-> model
so if you specify both in the options
argument, options.model
takes precedence\n\n### client-side use\n\n- this library works client + server side using axios for http requests\n- DO NOT share your api key in public client-side frontend code\n- one way to hide your openai api key for client-side use is by hosting an api wrapper endpoint that enforces your own authentication, then updating the origin this library looks to use like the below.\n\napi wrapper example:\n\nts\nimport { GpTs } from 'gpts-wrapper';\n/*\n gives your api wrapper authorization like this:\n headers: {\n 'Authorization': 'Bearer ASuperSecretPassword'\n }\n\n the constructor takes 2 arguments\n 1. the authorization bearer value\n 2. the api origin\n*/\nconst brain = new GpTs('ASuperSecretPassword', 'https://company.api-wrappers.io/gpt3');\n
\n\n---\n\n## TODO\n\n- support completion streaming SSE (https://beta.openai.com/docs/api-reference/completions/create-via-get)\n- support fine-tuning management (https://beta.openai.com/docs/guides/fine-tuning/preparing-your-dataset)