Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit b2d9d5f

Browse files
authored
Added examples and revamped the API desc (#823)
1 parent cc32b87 commit b2d9d5f

File tree

12 files changed

+134
-37
lines changed

12 files changed

+134
-37
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ Cortex currently supports 3 inference engines:
2828
### Prerequisites
2929
Ensure that your system meets the following requirements to run Cortex:
3030
- **Dependencies**:
31-
- **Node.js**: version 18 and above is required to run the installation.
31+
- **Node.js**: Version 18 and above is required to run the installation.
3232
- **NPM**: Needed to manage packages.
3333
- **CPU Instruction Sets**: Available for download from the [Cortex GitHub Releases](https://github.com/janhq/cortex/releases) page.
34+
- **OpenMPI**: Required for Linux. Install by using the following command:
35+
```bash
36+
sudo apt install openmpi-bin libopenmpi-dev
37+
```
3438
- **OS**:
3539
- MacOSX 13.6 or higher.
3640
- Windows 10 or higher.

cortex-js/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ Cortex currently supports 3 inference engines:
2828
### Prerequisites
2929
Ensure that your system meets the following requirements to run Cortex:
3030
- **Dependencies**:
31-
- **Node.js**: version 18 and above is required to run the installation.
31+
- **Node.js**: Version 18 and above is required to run the installation.
3232
- **NPM**: Needed to manage packages.
3333
- **CPU Instruction Sets**: Available for download from the [Cortex GitHub Releases](https://github.com/janhq/cortex/releases) page.
34+
- **OpenMPI**: Required for Linux. Install by using the following command:
35+
```bash
36+
sudo apt install openmpi-bin libopenmpi-dev
37+
```
3438
- **OS**:
3539
- MacOSX 13.6 or higher.
3640
- Windows 10 or higher.

cortex-js/src/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export const getApp = async () => {
3030
const config = new DocumentBuilder()
3131
.setTitle('Cortex API')
3232
.setDescription(
33-
'Cortex API provides a command-line interface (CLI) for seamless interaction with large language models (LLMs). It is fully compatible with the [OpenAI API](https://platform.openai.com/docs/api-reference) and enables straightforward command execution and management of LLM interactions.',
33+
'Cortex API provides a command-line interface (CLI) for seamless interaction with Large Language Models (LLMs). It is fully compatible with the [OpenAI API](https://platform.openai.com/docs/api-reference) and enables straightforward command execution and management of LLM interactions.',
3434
)
3535
.setVersion('1.0')
3636
.addTag(
3737
'Inference',
38-
'This endpoint initiates interaction with a Language Learning Model (LLM).',
38+
'This endpoint initiates interaction with a Large Language Models (LLM).',
3939
)
4040
.addTag(
4141
'Assistants',

cortex-js/src/infrastructure/controllers/configs.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ConfigsController {
2828
@ApiOperation({
2929
summary: 'List configs',
3030
description:
31-
'Lists the currently available configs, including the default and user-defined configurations',
31+
'Lists the currently available configs, including the default and user-defined configurations.',
3232
})
3333
@Get()
3434
findAll() {
@@ -44,7 +44,7 @@ export class ConfigsController {
4444
@ApiOperation({
4545
summary: 'Get a config',
4646
description:
47-
'Retrieves a config instance, providing basic information about the config',
47+
'Retrieves a config instance, providing basic information about the config.',
4848
})
4949
@ApiParam({
5050
name: 'name',
@@ -64,7 +64,7 @@ export class ConfigsController {
6464
})
6565
@ApiOperation({
6666
summary: 'Configure a model',
67-
description: "Updates a config by it's group and key",
67+
description: "Updates a specific configuration setting by its group and key.",
6868
parameters: [
6969
{
7070
in: 'path',

cortex-js/src/infrastructure/controllers/engines.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class EnginesController {
2525
@ApiOperation({
2626
summary: 'List available engines',
2727
description:
28-
'Lists the currently available engines, including local and remote engines',
28+
'Lists the currently available engines, including local and remote engines.',
2929
})
3030
@Get()
3131
findAll() {
@@ -41,7 +41,7 @@ export class EnginesController {
4141
@ApiOperation({
4242
summary: 'Get an engine',
4343
description:
44-
'Retrieves an engine instance, providing basic information about the engine',
44+
'Retrieves an engine instance, providing basic information about the engine.',
4545
})
4646
@ApiParam({
4747
name: 'name',

cortex-js/src/infrastructure/dtos/configs/config-update.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IsOptional, IsString } from 'class-validator';
44
export class ConfigUpdateDto {
55
@ApiProperty({
66
example: 'apiKey',
7-
description: 'The configuration key.',
7+
description: 'The configuration API key.',
88
})
99
@IsString()
1010
@IsOptional()
@@ -14,7 +14,7 @@ export class ConfigUpdateDto {
1414
@ApiProperty({
1515
type: String,
1616
example: 'sk-xxxxxx',
17-
description: 'The value of the configuration.',
17+
description: 'The value of the configuration API key.',
1818
})
1919
@IsString()
2020
@IsOptional()
@@ -23,7 +23,7 @@ export class ConfigUpdateDto {
2323
@ApiProperty({
2424
type: String,
2525
example: 'openai',
26-
description: 'The configuration name.',
26+
description: 'The name of the configuration.',
2727
})
2828
@IsString()
2929
@IsOptional()

cortex-js/src/infrastructure/dtos/embeddings/embeddings-request.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import { ApiProperty } from '@nestjs/swagger';
33

44
export class CreateEmbeddingsDto {
55
@ApiProperty({
6+
example: 'llama3',
67
description: 'The name of the embedding model to be used.',
78
type: String,
89
})
910
model: string;
1011

1112
@ApiProperty({
13+
example: ['Hello World'],
1214
description:
1315
'The text or token array(s) to be embedded. This can be a single string, an array of strings, or an array of token arrays to embed multiple inputs in one request.',
1416
type: [String],
1517
})
1618
input: string | string[];
1719

1820
@ApiProperty({
21+
example: 'float',
1922
description:
2023
'Specifies the format for the embeddings. Supported formats include `float` and `int`. This field is optional.',
2124
type: String,
@@ -24,6 +27,7 @@ export class CreateEmbeddingsDto {
2427
encoding_format?: string;
2528

2629
@ApiProperty({
30+
example: 3,
2731
description:
2832
'Defines the number of dimensions for the output embeddings. This feature is supported by certain models only. This field is optional.',
2933
type: Number,

cortex-js/src/infrastructure/dtos/engines/engines.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class EngineDto implements Partial<Extension> {
77
type: String,
88
example: 'cortex.llamacpp',
99
description:
10-
'The name of the engine, which can be referenced in the API endpoints.',
10+
'The name of the engine that you want to retrieve.',
1111
})
1212
@IsString()
1313
name: string;

cortex-js/src/infrastructure/dtos/messages/create-message.dto.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,54 @@ import { Message, MessageContent } from '@/domain/models/message.interface';
44

55
export class CreateMessageDto implements Partial<Message> {
66
@ApiProperty({
7+
example: 'thread_456',
78
description: 'The ID of the thread to which the message will be posted.',
89
})
910
@IsString()
1011
thread_id: string;
1112

12-
@ApiProperty({ description: "The assistant's unique identifier." })
13+
@ApiProperty({
14+
example: 'assistant_789',
15+
description: "The assistant's unique identifier.",
16+
})
1317
@IsString()
1418
assistant_id?: string;
1519

16-
@ApiProperty({ description: 'The sources of the messages.' })
20+
@ApiProperty({
21+
example: 'user',
22+
description: 'The sources of the messages.',
23+
})
1724
role: 'user' | 'assistant';
1825

19-
@ApiProperty({ description: 'The content of the messages.' })
26+
@ApiProperty({
27+
example: [
28+
{
29+
type: 'text',
30+
data: 'Hello, how can I help you today?'
31+
}
32+
],
33+
description: 'The content of the messages.',
34+
})
2035
@IsArray()
2136
content: MessageContent[];
2237

23-
@ApiProperty({ description: 'Current status of the message.' })
38+
@ApiProperty({
39+
example: 'in_progress',
40+
description: 'Current status of the message.',
41+
})
2442
status: 'in_progress' | 'incomplete' | 'completed';
2543

2644
@ApiProperty({
27-
description:
28-
'Optional dictionary for additional unstructured message information.',
45+
example: { urgency: 'high', tags: ['customer_support'] },
46+
description: 'Optional dictionary for additional unstructured message information.',
2947
})
3048
metadata?: Record<string, unknown>;
3149

32-
@ApiProperty({ description: 'Type of the message.' })
50+
@ApiProperty({
51+
example: 'text',
52+
description: 'Type of the message.',
53+
})
3354
@IsString()
3455
type?: string;
3556
}
57+

cortex-js/src/infrastructure/dtos/threads/create-message.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { ApiProperty } from '@nestjs/swagger';
22

33
export class CreateMessageDto {
44
@ApiProperty({
5+
example: 'user',
56
description: `The role of the entity that is creating the message. Allowed values include:
67
- user: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
78
- assistant: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.`,
89
})
910
role: 'user' | 'assistant';
1011

1112
@ApiProperty({
13+
example: 'Tell me a joke',
1214
description: 'The text contents of the message.',
1315
})
1416
content: string;

0 commit comments

Comments
 (0)