Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
AI-Maria committed Jun 3, 2024
1 parent 69fe944 commit 4e37ff9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 39 deletions.
4 changes: 0 additions & 4 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export const getChatCompletion = async (

const modelmapping: Partial<Record<ModelOptions, string>> = {
'gpt-3.5-turbo': 'gpt-35-turbo',
'gpt-3.5-turbo-16k': 'gpt-35-turbo-16k',
'gpt-3.5-turbo-1106': 'gpt-35-turbo-1106',
'gpt-3.5-turbo-0125': 'gpt-35-turbo-0125',
};

const model = modelmapping[config.model] || config.model;
Expand Down Expand Up @@ -101,7 +98,6 @@ export const getChatCompletionStream = async (

const modelmapping: Partial<Record<ModelOptions, string>> = {
'gpt-3.5-turbo': 'gpt-35-turbo',
'gpt-3.5-turbo-16k': 'gpt-35-turbo-16k',
};

const model = modelmapping[config.model] || config.model;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chat/ChatContent/Message/NewMessageButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useStore from '@store/store';

import PlusIcon from '@icon/PlusIcon';

import { ChatInterface } from '@type/chat';
import { ChatInterface, TextContentInterface } from '@type/chat';
import { generateDefaultChat } from '@constants/chat';

const NewMessageButton = React.memo(
Expand Down Expand Up @@ -38,7 +38,7 @@ const NewMessageButton = React.memo(
JSON.stringify(useStore.getState().chats)
);
updatedChats[currentChatIndex].messages.splice(messageIndex + 1, 0, {
content: '',
content: [{'type': 'text', 'text': ''} as TextContentInterface],
role: 'user',
});
setChats(updatedChats);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Chat/ChatContent/Message/View/EditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PopupModal from '@components/PopupModal';
import TokenCount from '@components/TokenCount';
import CommandPrompt from '../CommandPrompt';
import FolderIcon from '@icon/FolderIcon';
import { modelTypes } from '@constants/chat';
import { defaultModel, modelTypes } from '@constants/chat';

const EditView = ({
content: content,
Expand Down Expand Up @@ -243,7 +243,7 @@ const EditViewButtons = memo(
const { t } = useTranslation();
const generating = useStore.getState().generating;
const advancedMode = useStore((state) => state.advancedMode);
const model = useStore((state) => state.chats != undefined ? state.chats![state.currentChatIndex].config.model : "");
const model = useStore((state) => state.chats != undefined ? state.chats![state.currentChatIndex].config.model : defaultModel);
const fileInputRef = useRef(null);

const handleUploadButtonClick = () => {
Expand Down
14 changes: 0 additions & 14 deletions src/constants/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ Respond using Markdown.`;
export const modelOptions: ModelOptions[] = [
'gpt-3.5-turbo',
'gpt-4-vision-preview',
// 'gpt-3.5-turbo-16k',
// 'gpt-3.5-turbo-1106',
// 'gpt-3.5-turbo-0125',
// 'gpt-4',
// 'gpt-4-32k',
// 'gpt-4-1106-preview',
// 'gpt-4-0125-preview',
// 'gpt-4-turbo',
// 'gpt-4-turbo-2024-04-09',
// 'gpt-4o',
// 'gpt-4o-2024-05-13',
// 'gpt-3.5-turbo-0301',
// 'gpt-4-0314',
// 'gpt-4-32k-0314',
];

export const defaultModel = 'gpt-3.5-turbo';
Expand Down
18 changes: 2 additions & 16 deletions src/types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Theme } from './theme';

export type Content = 'text' | 'image_url';
export type ImageDetail = 'low' | 'high' | 'auto';
export const imageDetails: ImageDetail[] = ['low', 'high', 'auto'];
export const imageDetails: ImageDetail[] = ['auto'];
export type Role = 'user' | 'assistant' | 'system';
export const roles: Role[] = ['user', 'assistant', 'system'];

Expand Down Expand Up @@ -78,22 +78,8 @@ export interface Folder {
}

export type ModelOptions =
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4'
| 'gpt-4-32k'
| 'gpt-4-1106-preview'
| 'gpt-4-0125-preview'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-3.5-turbo'
| 'gpt-3.5-turbo-16k'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-0125'
'gpt-3.5-turbo'
| 'gpt-4-vision-preview';
// | 'gpt-3.5-turbo-0301';
// | 'gpt-4-0314'
// | 'gpt-4-32k-0314'

export type ModelType = 'text' | 'image';

Expand Down
4 changes: 3 additions & 1 deletion src/utils/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ConfigInterface,
FolderCollection,
MessageInterface,
TextContentInterface,
} from '@type/chat';
import { roles } from '@type/chat';
import {
Expand Down Expand Up @@ -102,7 +103,8 @@ export const convertOpenAIToBetterChatGPTFormat = (
// Extract message if it exists
if (node.message) {
const { role } = node.message.author;
const content = node.message.content.parts?.join('') || '';
const text = node.message.content.parts?.join('') || '';
const content = [{'type': 'text', 'text': text} as TextContentInterface];
if (content.length > 0) messages.push({ role, content });
}

Expand Down

0 comments on commit 4e37ff9

Please sign in to comment.