diff --git a/apps/chat/src/components/Chat/ModelList.tsx b/apps/chat/src/components/Chat/ModelList.tsx index f2f4ad0b6a..3329cf7929 100644 --- a/apps/chat/src/components/Chat/ModelList.tsx +++ b/apps/chat/src/components/Chat/ModelList.tsx @@ -219,48 +219,50 @@ const ModelGroup = ({ entity={currentEntity} size={24} /> -
-
- - {entities.length === 1 - ? getOpenAIEntityFullName(currentEntity) - : currentEntity.name} - -
- - {isCustomApplicationsEnabled && - isApplicationId(currentEntity.id) && ( - openApplicationModal} - /> - )} +
+
+
+ + {entities.length === 1 + ? getOpenAIEntityFullName(currentEntity) + : currentEntity.name} + +
+ + {isCustomApplicationsEnabled && + isApplicationId(currentEntity.id) && ( + openApplicationModal} + /> + )} +
+ {description && ( + { + if ((e.target as HTMLAnchorElement)?.tagName === 'A') { + e.stopPropagation(); + } + }} + data-qa="group-entity-descr" + > + + {description} + + + )}
- {description && ( - { - if ((e.target as HTMLAnchorElement)?.tagName === 'A') { - e.stopPropagation(); - } - }} - data-qa="group-entity-descr" - > - - {description} - - - )}
{!notAllowExpandDescription && description && @@ -366,7 +368,7 @@ export const ModelList = ({ const modelsMapKeys = Object.keys(modelsMap); - onSelect(recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]); + onSelect(recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]?.reference); selectedConversations.forEach((conv) => { if ( conv.model.id === currentEntity?.reference || @@ -376,7 +378,10 @@ export const ModelList = ({ ConversationsActions.updateConversation({ id: conv.id, values: { - model: { id: recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]] }, + model: { + id: + recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]?.reference, + }, }, }), ); diff --git a/apps/chat/src/components/Chat/Publish/ReviewApplicationDialogView.tsx b/apps/chat/src/components/Chat/Publish/ReviewApplicationDialogView.tsx index 3d9448cd19..92d2774bfc 100644 --- a/apps/chat/src/components/Chat/Publish/ReviewApplicationDialogView.tsx +++ b/apps/chat/src/components/Chat/Publish/ReviewApplicationDialogView.tsx @@ -70,19 +70,17 @@ export function ReviewApplicationDialogView() { {t('Features data:')} -
+
{'{'} -
-                  
+
{Object.entries(application?.features || {}).map( - ([key, value]) => ( + ([key, value], index, array) => ( - {key} {value} -
+ {`"${key}" : "${value}"${index !== array.length - 1 ? ',\n' : ''}`}
), )} -
+
{'}'}
@@ -119,7 +117,7 @@ export function ReviewApplicationDialogView() { {t('Completion URL:')} - + {application?.completionUrl}
diff --git a/apps/chat/src/components/Common/ApplicationDialog.tsx b/apps/chat/src/components/Common/ApplicationDialog.tsx index 4c8c5e8103..f404e93008 100644 --- a/apps/chat/src/components/Common/ApplicationDialog.tsx +++ b/apps/chat/src/components/Common/ApplicationDialog.tsx @@ -533,7 +533,7 @@ const ApplicationDialogView: React.FC = ({ className="mb-1 flex text-xs text-secondary" htmlFor="maxInputAttachments" > - {t('Max attachments')} + {t('Max. attachments number')} ), messages: [], model: { - id: model.id, + id: model.reference, }, prompt: DEFAULT_SYSTEM_PROMPT, temperature: diff --git a/apps/chat/src/store/overlay/overlay.epics.ts b/apps/chat/src/store/overlay/overlay.epics.ts index ec28b859a1..aad8a39549 100644 --- a/apps/chat/src/store/overlay/overlay.epics.ts +++ b/apps/chat/src/store/overlay/overlay.epics.ts @@ -286,16 +286,19 @@ const setOverlayOptionsEpic: AppEpic = (action$, state$) => if (currentConversation) { const models = ModelsSelectors.selectModels(state$.value); - const newAiEntity = models.find(({ id }) => id === finalModelId) as - | DialAIEntityModel - | undefined; + const newAiEntity = models.find( + ({ reference, id }) => + id === finalModelId || reference === finalModelId, + ) as DialAIEntityModel | undefined; actions.push( of( ConversationsActions.updateConversation({ id: currentConversation.id, values: { - model: { id: finalModelId }, + model: { + id: newAiEntity?.reference ?? finalModelId, + }, }, }), ), diff --git a/apps/chat/src/utils/server/index.ts b/apps/chat/src/utils/server/index.ts index f9650829d3..30bba401a7 100644 --- a/apps/chat/src/utils/server/index.ts +++ b/apps/chat/src/utils/server/index.ts @@ -108,20 +108,7 @@ export const OpenAIStream = async ({ body, }); - if ( - res.status === 400 && - retries === 0 && - model.limits?.isMaxRequestTokensCustom - ) { - retries += 1; - const json = await res.json(); - logger.info( - json, - `Getting 400 error and retrying chat request to ${model.id} model`, - ); - messagesToSend = hardLimitMessages(messagesToSend); - continue; - } else if (res.status !== 200) { + if (res.status !== 200) { let result: DialAIErrorResponse; try { result = (await res.json()) as DialAIErrorResponse; @@ -134,19 +121,37 @@ export const OpenAIStream = async ({ ); } - if (result.error) { - throw new DialAIError( - result.error.message ?? '', - result.error.type ?? '', - result.error.param ?? '', - result.error.code ?? res.status.toString(10), - result.error.display_message, - ); - } else { + if (!result.error) { throw new Error( `Core API returned an error: ${JSON.stringify(result, null, 2)}`, ); } + + const dial_error = new DialAIError( + result.error.message ?? '', + result.error.type ?? '', + result.error.param ?? '', + result.error.code ?? res.status.toString(10), + result.error.display_message, + ); + + if ( + res.status === 400 && + dial_error.code === 'truncate_prompt_error' && + retries === 0 && + model.limits?.isMaxRequestTokensCustom + ) { + retries += 1; + const json = await res.json(); + logger.info( + json, + `Getting error with status ${res.status} and code '${dial_error.code}'. Retrying chat request to ${model.id} model`, + ); + messagesToSend = hardLimitMessages(messagesToSend); + continue; + } + + throw dial_error; } break;