Skip to content

Commit

Permalink
feat: add support gpt-4o-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonghakseo committed Aug 10, 2024
1 parent a7c0b57 commit e3579f3
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.31.8",
"fs-extra": "10.1.0",
"openai": "4.52.3",
"openai": "4.55.4",
"jest": "29.0.3",
"jest-environment-jsdom": "29.0.3",
"npm-run-all": "^4.1.5",
Expand Down
19 changes: 9 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ declare module "*.json" {
}

declare global {
type Model = "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo" | "gpt-4o-mini";

type ChatGPTSlot = {
type: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo";
type: Model;
system?: string;
/** config */
maxTokens?: number; // max 4000
Expand Down Expand Up @@ -108,7 +110,7 @@ declare global {
type: "RequestQuickChatGPTStream";
input?: {
messages: Chat[];
model: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo";
model: Model;
};
data?: { result: string; chunk?: string; isDone?: boolean };
};
Expand Down
1 change: 0 additions & 1 deletion src/pages/background/lib/infra/chatGPT.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { OpenAI } from "openai";
import { ChatCompletionMessageParam } from "openai/resources";
import { ChatModel } from "openai/src/resources/chat/chat";

export async function chatGPT({
input,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/popup/components/SlotDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export default function SlotDetail({
<MenuItem onClick={() => updateSlot("type", "gpt-3.5-turbo")}>
gpt-3.5-turbo
</MenuItem>
<MenuItem onClick={() => updateSlot("type", "gpt-4o-mini")}>
gpt-4o-mini
</MenuItem>
<MenuItem onClick={() => updateSlot("type", "gpt-4o")}>
gpt-4o
</MenuItem>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/popup/pages/QuickChattingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function QuickChattingPage({
inputText: "",
chats: [],
tempResponse: "",
model: (localStorage.getItem("model") as any) ?? "gpt-3.5-turbo",
model: (localStorage.getItem("model") as Model) ?? "gpt-3.5-turbo",
},
services: {
getChatHistoryFromBackground: () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function QuickChattingPage({
send("RECEIVE_CANCEL");
};

const onSelectModel = (model: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo") => {
const onSelectModel = (model: Model) => {
send("SELECT_GPT_MODEL", { data: model });
localStorage.setItem("model", model);
};
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/getGPTResponseAsStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function getQuickGPTResponseAsStream({
onFinish,
}: {
messages: Chat[];
model: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo";
model: Model;
onDelta: (chunk: string) => unknown;
onFinish: (result: string) => unknown;
}) {
Expand Down
4 changes: 2 additions & 2 deletions src/shared/xState/streamChatStateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Events =
}
| {
type: "SELECT_GPT_MODEL";
data: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo";
data: Model;
}
| { type: "CHANGE_TEXT"; data: string }
| { type: "RECEIVE_ING"; data: string }
Expand All @@ -16,7 +16,7 @@ interface Context {
inputText: string;
chats: Chat[];
tempResponse: string;
model: "gpt-4-turbo" | "gpt-4o" | "gpt-3.5-turbo";
model: Model;
error?: Error;
cancelReceive?: () => unknown;
}
Expand Down

0 comments on commit e3579f3

Please sign in to comment.