Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added openai gpt4o mini model #1814

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion app/api/chat/openai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export async function POST(request: Request) {
temperature: chatSettings.temperature,
max_tokens:
chatSettings.model === "gpt-4-vision-preview" ||
chatSettings.model === "gpt-4o"
chatSettings.model === "gpt-4o" ||
chatSettings.model === "gpt-4o-mini"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mini supports 16k output tokens - would this limit it to 4k?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will.

It should be

const response = await openai.chat.completions.create({
  model: chatSettings.model as ChatCompletionCreateParamsBase["model"],
  messages: messages as ChatCompletionCreateParamsBase["messages"],
  temperature: chatSettings.temperature,
  max_tokens:
    chatSettings.model === "gpt-4-vision-preview" ||
    chatSettings.model === "gpt-4o"
      ? 4096
      : chatSettings.model === "gpt-4o-mini"
      ? 16383
      : null, 
  stream: true
});

Copy link
Contributor Author

@meetpateltech meetpateltech Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's fixed! Thanks.

? 4096
: null, // TODO: Fix
stream: true
Expand Down
6 changes: 6 additions & 0 deletions lib/chat-setting-limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ export const CHAT_SETTING_LIMITS: Record<LLMID, ChatSettingLimits> = {
MAX_TOKEN_OUTPUT_LENGTH: 4096,
MAX_CONTEXT_LENGTH: 128000
},
"gpt-4o-mini": {
MIN_TEMPERATURE: 0.0,
MAX_TEMPERATURE: 2.0,
MAX_TOKEN_OUTPUT_LENGTH: 4096,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way MAX_TOKEN_OUTPUT_LENGTH: 4096 will also limit gpt-4o mini maximum response length to 4k tokens, it should be 16383 tokens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated it! thanks 🙌

MAX_CONTEXT_LENGTH: 128000
},

// PERPLEXITY MODELS
"pplx-7b-online": {
Expand Down
17 changes: 17 additions & 0 deletions lib/models/llm/openai-llm-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import { LLM } from "@/types"
const OPENAI_PLATORM_LINK = "https://platform.openai.com/docs/overview"

// OpenAI Models (UPDATED 1/25/24) -----------------------------

const GPT4oMini: LLM = {
modelId: "gpt-4o-mini",
modelName: "GPT-4o Mini",
provider: "openai",
hostedId: "gpt-4o-mini",
platformLink: OPENAI_PLATORM_LINK,
imageInput: true,
pricing: {
currency: "USD",
unit: "1M tokens",
inputCost: 0.15,
outputCost: 0.6
}
}

const GPT4o: LLM = {
modelId: "gpt-4o",
modelName: "GPT-4o",
Expand Down Expand Up @@ -82,6 +98,7 @@ const GPT3_5Turbo: LLM = {
}

export const OPENAI_LLM_LIST: LLM[] = [
GPT4oMini,
GPT4o,
GPT4Turbo,
GPT4Vision,
Expand Down
1 change: 1 addition & 0 deletions types/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type LLMID =

// OpenAI Models (UPDATED 5/13/24)
export type OpenAILLMID =
| "gpt-4o-mini" // GPT-4o Mini
| "gpt-4o" // GPT-4o
| "gpt-4-turbo-preview" // GPT-4 Turbo
| "gpt-4-vision-preview" // GPT-4 Vision
Expand Down