# CodexJs-AI

<p align="center">Quickly call OpenAI to generate code.</p>

<div align="center">

[![npm version](https://img.shields.io/npm/v/codexjs-ai.svg?style=flat-square)](https://www.npmjs.org/package/codexjs-ai)
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=codexjs-ai&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=codexjs-ai)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/codexjs-ai?style=flat-square)](https://bundlephobia.com/package/codexjs-ai@latest)
[![npm downloads](https://img.shields.io/npm/dm/codexjs-ai.svg?style=flat-square)](https://npm-stat.com/charts.html?package=codexjs-ai)

</div>

## Project Description

OpenAI has created a JavaScript code generation library that makes it easier to use OpenAI's generated code and provides a foundation for higher-level software.

## Browser Support

![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
--- | --- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |

## Platform

UMD | CJS | ESM | Typescript |
--- | --- | --- | --- |
Support ✔ | Support ✔ | Support ✔ | Support ✔ |



## Installing

### Package manager
Using npm:

```bash
npm install codexjs-ai
```


You can also use the default export, since the named export is just a re-export from the codexjs-ai factory:

```js
import codexjs from 'codexjs-ai';

codexjs.get('实现一个数组去重函数，es6版本', (data) => {
    console.log(data)
}, () => {
    console.log('Information transmission complete.')
}, err => {
    console.log('error：', err)
})
```

If you use require for importing, only default export is available:

```js
const codexjs = require('codexjs-ai');

codexjs.get('实现一个数组去重函数，es6版本', (data) => {
    console.log(data)
}, () => {
    console.log('Information transmission complete.')
}, err => {
    console.log('error：', err)
})
```

For cases where something went wrong when trying to import a module into a custom or legacy environment, you can try importing the module package directly:

```js
const codexjs = require('codexjs-ai/dist/codexjs.cjs'); // browser commonJS bundle
```

> For more information, please see the examples in the /demo files. I have prepared demonstration files in both cjs and umd formats.

### CDN

Using jsDelivr CDN (ES5 UMD browser module):

```html
<script src="https://cdn.jsdelivr.net/npm/codexjs-ai@0.0.3/dist/codexjs.umd.js"></script>
```

Using unpkg CDN:

```html
<script src="https://unpkg.com/codexjs-ai@0.0.3/dist/codexjs.umd.js"></script>
```

## 🚧 Tip

This project is still in an unstable phase. If you encounter any issues, please feel free to open an issue on GitHub. We welcome your feedback and suggestions.


## License

[MIT](LICENSE)
