Skip to content

Commit

Permalink
feat(chat): If the entity type is application and there is no hard co…
Browse files Browse the repository at this point in the history
…de value for it -> backend shouldn't cut the context (#659)

Co-authored-by: Ihar_Makeyenka <[email protected]>
  • Loading branch information
4llower and Ihar_Makeyenka authored Feb 9, 2024
1 parent 3960fb7 commit 0122f90
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/chat/src/utils/server/get-sorted-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,29 @@ export const getSortedEntities = async (token: JWT | null) => {
const existingModelMapping: OpenAIEntityModel | undefined =
OpenAIEntityModels[entity.id];

const maxLength = existingModelMapping
? existingModelMapping.maxLength
: defaultModelLimits.maxLength;

// applications must handle the limit themselves, because they can have complex logic to handle it
const fallbackRequestLimit =
entity.object === EntityType.Application
? Infinity
: defaultModelLimits.requestLimit;

const requestLimit = existingModelMapping
? existingModelMapping.requestLimit
: fallbackRequestLimit;

entities.push({
id: entity.id,
name: entity.display_name ?? existingModelMapping?.name ?? entity.id,
description: entity.description,
iconUrl: entity.icon_url,
type: entity.object,
selectedAddons: entity.addons,
...(existingModelMapping
? {
maxLength: existingModelMapping.maxLength,
requestLimit: existingModelMapping.requestLimit,
}
: defaultModelLimits),
maxLength,
requestLimit,
inputAttachmentTypes: entity.input_attachment_types,
maxInputAttachments: entity.max_input_attachments,
});
Expand Down

0 comments on commit 0122f90

Please sign in to comment.