🚀 feat: o1 (#4019)

* feat: o1 default response sender string

* feat: add o1 models to default openai models list, add `no_system_messages` error type; refactor: use error type as localization key

* refactor(MessageEndpointIcon): differentiate openAI icon model color for o1 models

* refactor(AnthropicClient): use new input/output tokens keys; add prompt caching for claude-3-opus

* refactor(BaseClient): to use new input/output tokens keys; update typedefs

* feat: initial o1 model handling, including token cost complexity

* EXPERIMENTAL: special handling for o1 model with custom instructions
This commit is contained in:
Danny Avila 2024-09-12 18:15:43 -04:00 committed by GitHub
parent 9a393be012
commit 45b42830a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 229 additions and 36 deletions

View file

@ -17,6 +17,14 @@ import {
import { IconProps } from '~/common';
import { cn } from '~/utils';
function getOpenAIColor(_model: string | null | undefined) {
const model = _model?.toLowerCase() ?? '';
if (model && /\bo1\b/i.test(model)) {
return '#000000';
}
return model.includes('gpt-4') ? '#AB68FF' : '#19C37D';
}
function getGoogleIcon(model: string | null | undefined, size: number) {
if (model?.toLowerCase().includes('code') === true) {
return <CodeyIcon size={size * 0.75} />;
@ -119,8 +127,7 @@ const MessageEndpointIcon: React.FC<IconProps> = (props) => {
},
[EModelEndpoint.openAI]: {
icon: <GPTIcon size={size * 0.5555555555555556} />,
bg:
typeof model === 'string' && model.toLowerCase().includes('gpt-4') ? '#AB68FF' : '#19C37D',
bg: getOpenAIColor(model),
name: 'ChatGPT',
},
[EModelEndpoint.gptPlugins]: {

View file

@ -42,7 +42,8 @@ const errorMessages = {
[ErrorTypes.NO_USER_KEY]: 'com_error_no_user_key',
[ErrorTypes.INVALID_USER_KEY]: 'com_error_invalid_user_key',
[ErrorTypes.NO_BASE_URL]: 'com_error_no_base_url',
[ErrorTypes.INVALID_REQUEST]: 'com_error_invalid_request',
[ErrorTypes.INVALID_REQUEST]: `com_error_${ErrorTypes.INVALID_REQUEST}`,
[ErrorTypes.NO_SYSTEM_MESSAGES]: `com_error_${ErrorTypes.NO_SYSTEM_MESSAGES}`,
[ErrorTypes.EXPIRED_USER_KEY]: (json: TExpiredKey, localize: LocalizeFunction) => {
const { expiredAt, endpoint } = json;
return localize('com_error_expired_user_key', endpoint, expiredAt);

View file

@ -24,8 +24,10 @@ export default {
com_error_no_base_url: 'No base URL found. Please provide one and try again.',
com_warning_resubmit_unsupported:
'Resubmitting the AI message is not supported for this endpoint.',
com_error_invalid_request:
com_error_invalid_request_error:
'The AI service rejected the request due to an error. This could be caused by an invalid API key or an improperly formatted request.',
com_error_no_system_messages:
'The selected AI service or model does not support system messages. Try using prompts instead of custom instructions.',
com_error_invalid_user_key: 'Invalid key provided. Please provide a valid key and try again.',
com_error_expired_user_key:
'Provided key for {0} expired at {1}. Please provide a new key and try again.',