Skip to content

Commit

Permalink
feat: close ChatGPTNextWeb#291 gpt-4 model uses black icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed Apr 20, 2023
1 parent b2c711a commit 7e8973c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
12 changes: 9 additions & 3 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CopyIcon from "../icons/copy.svg";
import DownloadIcon from "../icons/download.svg";
import LoadingIcon from "../icons/three-dots.svg";
import BotIcon from "../icons/bot.svg";
import BlackBotIcon from "../icons/black-bot.svg";
import AddIcon from "../icons/add.svg";
import DeleteIcon from "../icons/delete.svg";
import MaxIcon from "../icons/max.svg";
Expand All @@ -30,6 +31,7 @@ import {
createMessage,
useAccessStore,
Theme,
ModelType,
} from "../store";

import {
Expand Down Expand Up @@ -64,13 +66,17 @@ const Emoji = dynamic(async () => (await import("emoji-picker-react")).Emoji, {
loading: () => <LoadingIcon />,
});

export function Avatar(props: { role: Message["role"] }) {
export function Avatar(props: { role: Message["role"]; model?: ModelType }) {
const config = useChatStore((state) => state.config);

if (props.role !== "user") {
return (
<div className="no-dark">
<BotIcon className={styles["user-avtar"]} />
{props.model?.startsWith("gpt-4") ? (
<BlackBotIcon className={styles["user-avtar"]} />
) : (
<BotIcon className={styles["user-avtar"]} />
)}
</div>
);
}
Expand Down Expand Up @@ -727,7 +733,7 @@ export function Chat(props: {
>
<div className={styles["chat-message-container"]}>
<div className={styles["chat-message-avatar"]}>
<Avatar role={message.role} />
<Avatar role={message.role} model={message.model} />
</div>
{(message.preview || message.streaming) && (
<div className={styles["chat-message-status"]}>
Expand Down
28 changes: 28 additions & 0 deletions app/icons/black-bot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions app/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Message = ChatCompletionResponseMessage & {
streaming?: boolean;
isError?: boolean;
id?: number;
model?: ModelType;
};

export function createMessage(override: Partial<Message>): Message {
Expand Down Expand Up @@ -58,7 +59,7 @@ export interface ChatConfig {
disablePromptHint: boolean;

modelConfig: {
model: string;
model: ModelType;
temperature: number;
max_tokens: number;
presence_penalty: number;
Expand Down Expand Up @@ -96,7 +97,9 @@ export const ALL_MODELS = [
name: "gpt-3.5-turbo-0301",
available: true,
},
];
] as const;

export type ModelType = (typeof ALL_MODELS)[number]["name"];

export function limitNumber(
x: number,
Expand Down Expand Up @@ -387,6 +390,7 @@ export const useChatStore = create<ChatStore>()(
role: "assistant",
streaming: true,
id: userMessage.id! + 1,
model: get().config.modelConfig.model,
});

// get recent messages
Expand Down

0 comments on commit 7e8973c

Please sign in to comment.