From 21d53bb6ed530a68a3df46e8cee528eb97183e4a Mon Sep 17 00:00:00 2001 From: irfanpena Date: Mon, 15 Jul 2024 12:43:09 +0700 Subject: [PATCH] add better example for the request body --- .../dtos/chat/chat-completion-message.dto.ts | 1 + .../dtos/chat/create-chat-completion.dto.ts | 2 +- .../dtos/embeddings/embeddings-request.dto.ts | 2 +- .../dtos/models/create-model.dto.ts | 21 ++++++++++--------- .../infrastructure/dtos/models/model.dto.ts | 7 ++++--- .../threads/create-thread-assistant.dto.ts | 2 +- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/cortex-js/src/infrastructure/dtos/chat/chat-completion-message.dto.ts b/cortex-js/src/infrastructure/dtos/chat/chat-completion-message.dto.ts index 70c71b054..2e3ed859d 100644 --- a/cortex-js/src/infrastructure/dtos/chat/chat-completion-message.dto.ts +++ b/cortex-js/src/infrastructure/dtos/chat/chat-completion-message.dto.ts @@ -8,6 +8,7 @@ export class ChatCompletionMessage { @ApiProperty({ description: 'The role of the entity in the chat completion.', + example: 'user' }) role: 'user' | 'assistant'; } diff --git a/cortex-js/src/infrastructure/dtos/chat/create-chat-completion.dto.ts b/cortex-js/src/infrastructure/dtos/chat/create-chat-completion.dto.ts index 2b215820f..d7d421e3b 100644 --- a/cortex-js/src/infrastructure/dtos/chat/create-chat-completion.dto.ts +++ b/cortex-js/src/infrastructure/dtos/chat/create-chat-completion.dto.ts @@ -22,7 +22,7 @@ export class CreateChatCompletionDto { @ApiProperty({ description: 'The unique identifier of the model.', - example: 'gpt-4', + example: 'mistral', }) @IsString() model: string; diff --git a/cortex-js/src/infrastructure/dtos/embeddings/embeddings-request.dto.ts b/cortex-js/src/infrastructure/dtos/embeddings/embeddings-request.dto.ts index 7fdb6d609..f6517af78 100644 --- a/cortex-js/src/infrastructure/dtos/embeddings/embeddings-request.dto.ts +++ b/cortex-js/src/infrastructure/dtos/embeddings/embeddings-request.dto.ts @@ -3,7 +3,7 @@ import { ApiProperty } from '@nestjs/swagger'; export class CreateEmbeddingsDto { @ApiProperty({ - example: 'llama3', + example: 'mistral', description: 'The name of the embedding model to be used.', type: String, }) diff --git a/cortex-js/src/infrastructure/dtos/models/create-model.dto.ts b/cortex-js/src/infrastructure/dtos/models/create-model.dto.ts index 04d71e130..e3998d0fd 100644 --- a/cortex-js/src/infrastructure/dtos/models/create-model.dto.ts +++ b/cortex-js/src/infrastructure/dtos/models/create-model.dto.ts @@ -12,16 +12,16 @@ import { ApiProperty, getSchemaPath } from '@nestjs/swagger'; export class CreateModelDto implements Partial { // Cortex Meta - @ApiProperty({ description: 'The unique identifier of the model.' }) + @ApiProperty({ description: 'The unique identifier of the model.', example: 'mistral' }) @IsString() model: string; - @ApiProperty({ description: 'The name of the model.' }) + @ApiProperty({ description: 'The name of the model.', example: 'mistral' }) @IsString() name?: string; @ApiProperty({ - description: 'The URL sources from which the model downloaded or accessed.', + description: 'The URL sources from which the model downloaded or accessed.', example: ['https://huggingface.co/cortexso/mistral/tree/gguf'], oneOf: [ { type: 'array', items: { type: 'string' } }, { $ref: getSchemaPath(ModelArtifactDto) }, @@ -33,7 +33,8 @@ export class CreateModelDto implements Partial { // Model Input / Output Syntax @ApiProperty({ description: - "A predefined text or framework that guides the AI model's response generation.", + "A predefined text or framework that guides the AI model's response generation.", example: ` + You are an expert in {subject}. Provide a detailed and thorough explanation on the topic of {topic}.` }) @IsOptional() @IsString() @@ -41,7 +42,7 @@ export class CreateModelDto implements Partial { @ApiProperty({ description: - 'Defines specific tokens or phrases that signal the model to stop producing further output.', + 'Defines specific tokens or phrases that signal the model to stop producing further output.', example: ['End'] }) @IsOptional() @IsArray() @@ -58,14 +59,14 @@ export class CreateModelDto implements Partial { max_tokens?: number; @ApiProperty({ - description: 'Sets probability threshold for more relevant outputs.', + description: 'Sets probability threshold for more relevant outputs.', example: 0.9 }) @IsOptional() @IsNumber() top_p?: number; @ApiProperty({ - description: "Influences the randomness of the model's output.", + description: "Influences the randomness of the model's output.", example: 0.7 }) @IsOptional() @IsNumber() @@ -73,7 +74,7 @@ export class CreateModelDto implements Partial { @ApiProperty({ description: - 'Modifies the likelihood of the model repeating the same words or phrases within a single output.', + 'Modifies the likelihood of the model repeating the same words or phrases within a single output.', example: 0.5 }) @IsOptional() @IsNumber() @@ -81,7 +82,7 @@ export class CreateModelDto implements Partial { @ApiProperty({ description: - 'Reduces the likelihood of repeating tokens, promoting novelty in the output.', + 'Reduces the likelihood of repeating tokens, promoting novelty in the output.', example: 0.6 }) @IsOptional() @IsNumber() @@ -89,7 +90,7 @@ export class CreateModelDto implements Partial { @ApiProperty({ description: - 'Determines the format for output generation. If set to `true`, the output is generated continuously, allowing for real-time streaming of responses. If set to `false`, the output is delivered in a single JSON file.', + 'Determines the format for output generation. If set to `true`, the output is generated continuously, allowing for real-time streaming of responses. If set to `false`, the output is delivered in a single JSON file.', example: true }) @IsOptional() @IsBoolean() diff --git a/cortex-js/src/infrastructure/dtos/models/model.dto.ts b/cortex-js/src/infrastructure/dtos/models/model.dto.ts index 0c0d3dc96..163ac8527 100644 --- a/cortex-js/src/infrastructure/dtos/models/model.dto.ts +++ b/cortex-js/src/infrastructure/dtos/models/model.dto.ts @@ -10,7 +10,7 @@ import { export class ModelDto implements Partial { @ApiProperty({ - example: 'llama3', + example: 'mistral', description: 'The model identifier, which can be referenced in the API endpoints.', }) @@ -19,7 +19,7 @@ export class ModelDto implements Partial { // Prompt Settings @ApiProperty({ - example: 'system\n{system_message}\nuser\n{prompt}\nassistant', + example: `You are an expert in {subject}. Provide a detailed and thorough explanation on the topic of {topic}.`, description: "A predefined text or framework that guides the AI model's response generation.", }) @@ -28,7 +28,7 @@ export class ModelDto implements Partial { @ApiProperty({ type: [String], - example: [], + example: ["End"], description: 'Defines specific tokens or phrases that signal the model to stop producing further output.', }) @@ -116,6 +116,7 @@ export class ModelDto implements Partial { @ApiProperty({ description: 'The prompt to use for internal configuration', + example: "You are an assistant with expert knowledge in {subject}. Please provide a detailed and accurate response to the following query: {query}. Ensure that your response is clear, concise, and informative." }) @IsOptional() @IsString() diff --git a/cortex-js/src/infrastructure/dtos/threads/create-thread-assistant.dto.ts b/cortex-js/src/infrastructure/dtos/threads/create-thread-assistant.dto.ts index 18ae38c2c..8bf2d4204 100644 --- a/cortex-js/src/infrastructure/dtos/threads/create-thread-assistant.dto.ts +++ b/cortex-js/src/infrastructure/dtos/threads/create-thread-assistant.dto.ts @@ -33,7 +33,7 @@ export class CreateThreadAssistantDto implements Assistant { name: string; @ApiProperty({ - example: 'llama3', + example: 'mistral', description: 'The model\'s unique identifier and settings.', type: 'string', })