This project has been template and mvc structure for crud operations.
https://replit.com/@dhavalsoni9989/openaitrainmodel?v=1
- Run
npm i
to install the project dependencies
If you would still prefer to do the installation manually, follow these steps:
Clone the repo:
git clone --depth 1 https://github.com/dhavalsoni9989/openai_train_model.git
cd openai_train_model
npx rimraf ./.git
Install the dependencies:
npm install
Set the environment variables:
cp .env.example .env
# open .env and modify the environment variables (if needed)
Running locally:
# Start Project
npm start
Linting:
# run ESLint
npm lint
# fix ESLint errors
npm lint:fix
# run prettier
npm prettier
# fix prettier errors
npm prettier:fix
The environment variables can be found and modified in the .env
file. They come with these default values:
# Port number
PORT=3000
# OpenAI API key
OPENAI_API_KEY=sk-XXXXX
List of available routes:
Auth routes:
GET /list-files
- List Uploaded Files
GET /list-fine-tunes
- List Fine Tunes
GET /fine-tune/:id
- Get Particular Fine Tune with id
POST /train-model
- Train OpenAI Model
POST /completion
- OpenAI Completion code
try {
const completion = await openai.createCompletion({
model: 'text-davinci-003',
prompt: 'Hello world',
temperature: 0.7,
max_tokens: 256,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
});
console.log(completion.data.choices[0].text);
} catch (error) {
if (error.response) {
console.log(error.response.status);
console.log(error.response.data);
} else {
console.log(error.message);
}
}
Linting is done using ESLint and Prettier.
In this app, ESLint is configured to follow the Airbnb JavaScript style guide with some modifications. It also extends eslint-config-prettier to turn off all rules that are unnecessary or might conflict with Prettier.
To modify the ESLint configuration, update the .eslintrc.json
file. To modify the Prettier configuration, update the .prettierrc
file.
To prevent a certain file or directory from being linted, add it to .eslintignore
and .prettierignore
.
To maintain a consistent coding style across different IDEs, the project contains .editorconfig
Contributions are more than welcome! Please check out the contributing guide.