-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b6ce13c
Showing
81 changed files
with
4,840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_DOC_URL="https://platform.openai.com/docs/api-reference/chat/create" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "standard", | ||
"env": { | ||
"browser": true, | ||
"mocha": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.*.sw* | ||
node_modules | ||
package-lock.json | ||
coverage | ||
.nyc_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@mirnes-cajlakovic:registry=https://npm.pkg.github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# openai-schemas | ||
[](https://badge.fury.io/js/openai-schemas) | ||
[](http://standardjs.com) | ||
|
||
This is a collection json schema objects for validating openai endpoints requests and responses. This library also contains tools for scraping new schemas from the official api docs on openai.com when they are updated. | ||
|
||
## Installation | ||
To install the package, use the following command: | ||
``` | ||
npm install openai-schemas | ||
``` | ||
|
||
## Usage | ||
This package can be used in several ways to access the `create` function within the `chat` schema. Below are the methods to require or import this function: | ||
|
||
##### Method 1 | ||
Using destructuring at the top level: | ||
```javascript | ||
const { create } = require('openai-schemas').schemas.chat; | ||
console.log(create); | ||
``` | ||
|
||
##### Method 2 | ||
Destructuring one level deeper: | ||
```javascript | ||
const { chat: { create } } = require('openai-schemas').schemas; | ||
console.log(create); | ||
``` | ||
|
||
##### Method 3 | ||
Destructuring with full path: | ||
```javascript | ||
const { schemas: { chat: { create } } } = require('openai-schemas'); | ||
console.log(create); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { Update } = require('../index') | ||
|
||
Update.updateSchemas() | ||
.then((path) => console.log('Schemas have been updated.\n', path)) | ||
.catch((error) => console.log('Schemas failed to update.\n', error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const schemasIndex = [] | ||
const schemasPath = path.join(__dirname, 'schemas') | ||
fs.readdirSync(schemasPath) | ||
.filter((dir) => { | ||
return fs.statSync(path.join(schemasPath, dir)).isDirectory() | ||
}) | ||
.map((dir) => { | ||
const dirPath = path.join(schemasPath, dir) | ||
fs.readdirSync(dirPath) | ||
.filter((file) => { | ||
return path.extname(file) === '.json' | ||
}) | ||
.map((file) => { | ||
const name = path.basename(file, path.extname(file)) | ||
schemasIndex.push({ name, dir, src: path.join('./schemas/', dir, name) }) | ||
}) | ||
}) | ||
|
||
const modules = { | ||
Parse: require('./src/Parse'), | ||
Scrape: require('./src/Scrape'), | ||
Update: require('./src/Update'), | ||
schemas: {} | ||
} | ||
|
||
for (const schema of schemasIndex) { | ||
if (!modules.schemas[schema.dir]) { | ||
modules.schemas[schema.dir] = {} | ||
} | ||
modules.schemas[schema.dir][schema.name] = require('./' + schema.src) | ||
} | ||
|
||
module.exports = modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "openai-schemas", | ||
"version": "1.0.0", | ||
"description": "This is a collection json schema objects for validating openai endpoints requests and responses. This library also contains tools for scraping new schemas from the official api docs on openai.com when they are updated.", | ||
"keywords": [ | ||
"openai", | ||
"openai-api", | ||
"machine-learning", | ||
"artificial-intelligence", | ||
"chatgpt", | ||
"chat-gpt", | ||
"gpt", | ||
"gpt-3", | ||
"gpt-4", | ||
"ai", | ||
"agi", | ||
"node", | ||
"node.js", | ||
"json", | ||
"schemas" | ||
], | ||
"author": "Mirnes Cajlakovic", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:mirnes-cajlakovic/openai-schemas.git" | ||
}, | ||
"publishConfig": { | ||
"@mirnes-cajlakovic:registry": "https://npm.pkg.github.com/" | ||
}, | ||
"scripts": { | ||
"update": "node -r dotenv/config bin/update.js", | ||
"lint": "eslint src/ test/", | ||
"test": "npm run lint && nyc --reporter=html --reporter=text mocha", | ||
"coverage": "nyc check-coverage --lines 100 --branches 100 --functions 100 --statements 100" | ||
}, | ||
"dependencies": { | ||
"puppeteer": "^21.5.2" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.3.10", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.55.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"jsdom": "^23.0.1", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"proxyquire": "^2.1.3", | ||
"sinon": "^17.0.1" | ||
}, | ||
"nyc": { | ||
"include": "src/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
{ | ||
"title": "assistants/createAssistant", | ||
"description": "Create an assistant with a model and instructions.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"model": { | ||
"type": [ | ||
"" | ||
], | ||
"description": "ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them." | ||
}, | ||
"name": { | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"description": "The name of the assistant. The maximum length is 256 characters." | ||
}, | ||
"description": { | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"description": "The description of the assistant. The maximum length is 512 characters." | ||
}, | ||
"instructions": { | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"description": "The system instructions that the assistant uses. The maximum length is 32768 characters." | ||
}, | ||
"tools": { | ||
"type": [ | ||
"array" | ||
], | ||
"description": "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, retrieval, or function.", | ||
"items": { | ||
"oneOf": [ | ||
{ | ||
"title": "Code interpreter tool", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"type": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The type of tool being defined: code_interpreter" | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Retrieval tool", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"type": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The type of tool being defined: retrieval" | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Function tool", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"type": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The type of tool being defined: function" | ||
}, | ||
"function": { | ||
"type": [ | ||
"object" | ||
], | ||
"description": null | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"file_ids": { | ||
"type": [ | ||
"array" | ||
], | ||
"description": "A list of file IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order." | ||
}, | ||
"metadata": { | ||
"type": [ | ||
"map" | ||
], | ||
"description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"title": "assistants/createAssistantFile", | ||
"description": "Create an assistant file by attaching a File to an assistant.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the assistant for which to create a File." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"title": "assistants/deleteAssistant", | ||
"description": "Delete an assistant.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the assistant to delete." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"title": "assistants/deleteAssistantFile", | ||
"description": "Delete an assistant file.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the assistant that the file belongs to." | ||
}, | ||
"file_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the file to delete." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"title": "assistants/fileObject", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The identifier, which can be referenced in API endpoints." | ||
}, | ||
"object": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The object type, which is always assistant.file." | ||
}, | ||
"created_at": { | ||
"type": [ | ||
"integer" | ||
FE58 td> | ], | |
"description": "The Unix timestamp (in seconds) for when the assistant file was created." | ||
}, | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The assistant ID that the file is attached to." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"title": "assistants/getAssistant", | ||
"description": "Retrieves an assistant.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the assistant to retrieve." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"title": "assistants/getAssistantFile", | ||
"description": "Retrieves an AssistantFile.", | ||
"type": [ | ||
"object" | ||
], | ||
"properties": { | ||
"assistant_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the assistant who the file belongs to." | ||
}, | ||
"file_id": { | ||
"type": [ | ||
"string" | ||
], | ||
"description": "The ID of the file we're getting." | ||
} | ||
} | ||
} |
Oops, something went wrong.