Skip to content

Commit

Permalink
fix(chat): remove endpoint from payload if applicationTypeSchemaId wa…
Browse files Browse the repository at this point in the history
…s specified (Issue #2936) (#2942)
  • Loading branch information
IlyaBondar committed Jan 16, 2025
1 parent e2617be commit 216a3fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/chat/src/types/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,29 @@ export interface ApiApplicationModelBase {
url?: string;
reference?: string;
description_keywords?: string[];
application_type_schema_id?: string;
application_properties?: QuickAppConfig | Record<string, unknown>;
applicationTypeSchemaId?: string;
applicationProperties?: QuickAppConfig | Record<string, unknown>;
}

export interface ApiApplicationModelRegular extends ApiApplicationModelBase {
endpoint: string;
function?: never;
}

export interface ApiApplicationModelSchema extends ApiApplicationModelBase {
endpoint?: never;
applicationTypeSchemaId: string;
}

export interface ApiApplicationModelFunction extends ApiApplicationModelBase {
endpoint?: never;
function: Omit<ApiApplicationFunctionType, 'status'>;
}

export type ApiApplicationModel =
| ApiApplicationModelRegular
| ApiApplicationModelFunction;
| ApiApplicationModelFunction
| ApiApplicationModelSchema;

export interface ApplicationInfo extends Entity {
version: string;
Expand Down
11 changes: 8 additions & 3 deletions apps/chat/src/utils/app/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getTopicColors } from '@/src/utils/app/style-helpers';

import {
ApiApplicationModel,
ApiApplicationModelBase,
ApiApplicationModelSchema,
ApiApplicationResponse,
ApplicationInfo,
ApplicationStatus,
Expand Down Expand Up @@ -54,7 +56,7 @@ export const regenerateApplicationId = <T extends ApplicationInfo>(
export const convertApplicationToApi = (
applicationData: Omit<CustomApplicationModel, 'id'>,
): ApiApplicationModel => {
const commonData = {
const commonData: ApiApplicationModelBase = {
display_name: applicationData.name,
display_version: applicationData.version,
icon_url: ApiUtils.encodeApiUrl(applicationData.iconUrl ?? ''),
Expand All @@ -64,8 +66,8 @@ export const convertApplicationToApi = (
max_input_attachments: applicationData.maxInputAttachments,
reference: applicationData.reference || undefined,
description_keywords: applicationData.topics,
application_type_schema_id: applicationData.applicationTypeSchemaId,
application_properties: applicationData.applicationProperties,
applicationTypeSchemaId: applicationData.applicationTypeSchemaId,
applicationProperties: applicationData.applicationProperties,
};

if (applicationData.function) {
Expand All @@ -82,6 +84,9 @@ export const convertApplicationToApi = (
};
}

if (commonData.applicationTypeSchemaId) {
return commonData as ApiApplicationModelSchema;
}
return {
...commonData,
endpoint: applicationData.completionUrl,
Expand Down

0 comments on commit 216a3fc

Please sign in to comment.