θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions server/utils/agents/aibitat/providers/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ const Provider = require("./ai-provider.js");
const { RetryError } = require("../error.js");

/**
* The agent provider for the OpenAI API.
* The agent provider for the OpenAI API.
* By default, the model is set to 'gpt-3.5-turbo'.
*/
class OpenAIProvider extends Provider {
model;
static COST_PER_TOKEN = {
"gpt-3.5-turbo": {
input: 0.0015,
output: 0.002,
},
"gpt-3.5-turbo-16k": {
input: 0.003,
output: 0.004,
},
"gpt-4": {
input: 0.03,
output: 0.06,
},
"gpt-4-turbo": {
input: 0.01,
output: 0.03,
},
"gpt-4o": {
input: 0.005,
output: 0.015,
Expand All @@ -21,14 +33,10 @@ class OpenAIProvider extends Provider {
input: 0.06,
output: 0.12,
},
"gpt-3.5-turbo": {
input: 0.0015,
output: 0.002,
},
"gpt-3.5-turbo-16k": {
input: 0.003,
output: 0.004,
},
"gpt-4o-mini": {
input: 0.00015,
output: 0.0006,
}
};

constructor(config = {}) {
Expand Down
184 changes: 148 additions & 36 deletions server/utils/helpers/customModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,53 +66,165 @@ async function openAiModels(apiKey = null) {
console.error(`OpenAI:listModels`, e.message);
return [
{
name: "gpt-3.5-turbo",
id: "gpt-3.5-turbo",
object: "model",
created: 1677610602,
owned_by: "openai",
organization: "OpenAi",
"name": "gpt-3.5-turbo",
"id": "gpt-3.5-turbo",
"object": "model",
"created": 1677610602,
"owned_by": "openai",
"organization": "OpenAi"
},
{
name: "gpt-4o",
id: "gpt-4o",
object: "model",
created: 1677610602,
owned_by: "openai",
organization: "OpenAi",
"name": "gpt-4o",
"id": "gpt-4o",
"object": "model",
"created": 1677610602,
"owned_by": "openai",
"organization": "OpenAi"
},
{
name: "gpt-4",
id: "gpt-4",
object: "model",
created: 1687882411,
owned_by: "openai",
organization: "OpenAi",
"name": "gpt-3.5-turbo-16k",
"id": "gpt-3.5-turbo-16k",
"object": "model",
"created": 1683758102,
"owned_by": "openai-internal",
"organization": "OpenAi"
},
{
name: "gpt-4-turbo",
id: "gpt-4-turbo",
object: "model",
created: 1712361441,
owned_by: "system",
organization: "OpenAi",
"name": "gpt-4-0613",
"id": "gpt-4-0613",
"object": "model",
"created": 1686588896,
"owned_by": "openai",
"organization": "OpenAi"
},
{
name: "gpt-4-32k",
id: "gpt-4-32k",
object: "model",
created: 1687979321,
owned_by: "openai",
organization: "OpenAi",
"name": "gpt-4",
"id": "gpt-4",
"object": "model",
"created": 1687882411,
"owned_by": "openai",
"organization": "OpenAi"
},
{
name: "gpt-3.5-turbo-16k",
id: "gpt-3.5-turbo-16k",
object: "model",
created: 1683758102,
owned_by: "openai-internal",
organization: "OpenAi",
"name": "gpt-4-32k",
"id": "gpt-4-32k",
"object": "model",
"created": 1687979321,
"owned_by": "openai",
"organization": "OpenAi"
},
{
"name": "gpt-3.5-turbo-instruct",
"id": "gpt-3.5-turbo-instruct",
"object": "model",
"created": 1692901427,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-3.5-turbo-instruct-0914",
"id": "gpt-3.5-turbo-instruct-0914",
"object": "model",
"created": 1694122472,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4-1106-preview",
"id": "gpt-4-1106-preview",
"object": "model",
"created": 1698957206,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-3.5-turbo-1106",
"id": "gpt-3.5-turbo-1106",
"object": "model",
"created": 1698959748,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4-0125-preview",
"id": "gpt-4-0125-preview",
"object": "model",
"created": 1706037612,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4-turbo-preview",
"id": "gpt-4-turbo-preview",
"object": "model",
"created": 1706037777,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-3.5-turbo-0125",
"id": "gpt-3.5-turbo-0125",
"object": "model",
"created": 1706048358,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4-turbo",
"id": "gpt-4-turbo",
"object": "model",
"created": 1712361441,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4-turbo-2024-04-09",
"id": "gpt-4-turbo-2024-04-09",
"object": "model",
"created": 1712601677,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4o-2024-05-13",
"id": "gpt-4o-2024-05-13",
"object": "model",
"created": 1715368132,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4o-mini-2024-07-18",
"id": "gpt-4o-mini-2024-07-18",
"object": "model",
"created": 1721172717,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4o-mini",
"id": "gpt-4o-mini",
"object": "model",
"created": 1721172741,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "gpt-4o-2024-08-06",
"id": "gpt-4o-2024-08-06",
"object": "model",
"created": 1722814719,
"owned_by": "system",
"organization": "OpenAi"
},
{
"name": "chatgpt-4o-latest",
"id": "chatgpt-4o-latest",
"object": "model",
"created": 1723515131,
"owned_by": "system",
"organization": "OpenAi"
}
];
});

Expand Down