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

Commit ebc0d34

Browse files
authored
Merge pull request #1891 from janhq/doc-improvs
General improvements and additions to the documentation.
2 parents f090e0b + f3024c3 commit ebc0d34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1876
-1198
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ platform/command
2121
platform/src/infrastructure/commanders/test/test_data
2222
**/vcpkg_installed
2323
engine/test.db
24-
!docs/yarn.lock
24+
!docs/yarn.lock
25+
26+
# Local
27+
docs/.yarn/
28+
docs/.yarnrc.yml
29+
docs/bun.lockb
30+
docs/yarn.lock

docs/docs/architecture/cortex-db.mdx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ import Tabs from "@theme/Tabs";
88
import TabItem from "@theme/TabItem";
99

1010
:::warning
11-
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
11+
🚧 Cortex.cpp is currently under active development. Our documentation outlines the intended behavior
12+
of Cortex, which may not yet be fully implemented in the codebase.
1213
:::
1314

14-
This document outlines the architecture of the database designed to store and manage various types of entities and their associated metadata.
15+
![sqlite-view](/img/sqlite_view_harlequin.png)
16+
**db view via [Harlequin](https://harlequin.sh/)**
17+
18+
19+
This document outlines Cortex database architecture which is designed to store and manage models, engines,
20+
files and more.
21+
22+
## Tables Structure
1523

16-
## Table Structure
1724
### schema Table
25+
1826
The `schema` table is designed to hold schema version for cortex database. Below is the structure of the table:
1927

2028
| Column Name | Data Type | Description |
2129
|--------------------|-----------|---------------------------------------------------------|
22-
| schema_version | INTEGER | A unique schema version for database. |
30+
| version | INTEGER | A unique schema version for database. |
2331

2432
### models Table
2533
The `models` table is designed to hold metadata about various AI models. Below is the structure of the table:
@@ -49,3 +57,33 @@ The `hardware` table is designed to hold metadata about hardware information. Be
4957
| activated | INTEGER | A boolean value (0 or 1) indicating whether the hardware is activated or not. |
5058
| priority | INTEGER | An integer value representing the priority associated with the hardware. |
5159

60+
61+
### engines Table
62+
The `engines` table is designed to hold metadata about the different engines available for useage with Cortex.
63+
Below is the structure of the table:
64+
65+
| Column Name | Data Type | Description |
66+
|--------------|-----------|---------------------------------------------------------|
67+
| id | INTEGER | A unique identifier for each engine (Primary Key). |
68+
| engine_name | TEXT | The name of the engine. |
69+
| type | TEXT | |
70+
| api_key | TEXT | |
71+
| url | TEXT | |
72+
| version | TEXT | The current version of the engine. |
73+
| variant | TEXT | |
74+
| status | TEXT | Current status of the engine (e.g., "downloaded", "downloadable"). |
75+
| metadata | TEXT | Additional metadata or information about the engine. |
76+
| date_ceated | TEXT | Date when the engine was downloaded. |
77+
| date_updated | TEXT | Date when the engine was last updated. |
78+
79+
### files Table
80+
The `files` table is designed to hold metadata about objects dowloaded via Cortex.
81+
82+
| Column Name | Data Type | Description |
83+
|-------------|-----------|---------------------------------|
84+
| id | TEXT | The primary key for the table |
85+
| object | TEXT | The type of hardware. |
86+
| purpose | TEXT | Purpose of file |
87+
| filename | TEXT | The name of the file. |
88+
| created_at | INTEGER | Date when file was created |
89+
| bytes | INTEGER | |

docs/docs/architecture/cortexrc.mdx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import Tabs from "@theme/Tabs";
88
import TabItem from "@theme/TabItem";
99

1010
:::warning
11-
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
11+
🚧 Cortex.cpp is currently under active development. Our documentation outlines the intended behavior of
12+
Cortex, which may not be fully implemented in the codebase yet.
1213
:::
1314

14-
Cortex.cpp supports reading its configuration from a file called `.cortexrc`. Using this file, you can also change the data folder, Cortex.cpp API server port, and host.
15+
Cortex supports using a config-based approach to configuring most of its functionality. During the
16+
installation process, a `.cortexrc` will be generated with some sensible defaults in it. Using this
17+
file, you can change the location and name of the data directory, the Cortex API server port, the host and more.
1518

1619
## File Location
1720

@@ -31,25 +34,52 @@ You can configure the following parameters in the `.cortexrc` file:
3134
| `apiServerPort` | Port number for the Cortex.cpp API server. | `39281` |
3235
| `logFolderPath` | Path the folder where logs are located | User's home folder. |
3336
| `logLlamaCppPath` | The llama-cpp engine . | `./logs/cortex.log` |
34-
| `logTensorrtLLMPath` | The tensorrt-llm engine log file path. | `./logs/cortex.log` |
3537
| `logOnnxPath` | The onnxruntime engine log file path. | `./logs/cortex.log` |
3638
| `maxLogLines` | The maximum log lines that write to file. | `100000` |
3739
| `checkedForUpdateAt` | The last time for checking updates. | `0` |
3840
| `latestRelease` | The lastest release vesion. | Empty string |
3941
| `huggingFaceToken` | HuggingFace token. | Empty string |
4042

43+
44+
In the future, every parameter will be editable from the Cortex CLI. At present, only a selected few are configurable.
45+
4146
Example of the `.cortexrc` file:
4247

4348
```
44-
logFolderPath: /Users/<username>/cortexcpp
49+
logFolderPath: /home/<user>/cortexcpp
4550
logLlamaCppPath: ./logs/cortex.log
4651
logTensorrtLLMPath: ./logs/cortex.log
4752
logOnnxPath: ./logs/cortex.log
48-
dataFolderPath: /Users/<username>/cortexcpp
53+
dataFolderPath: /home/<user>/cortexcpp
4954
maxLogLines: 100000
5055
apiServerHost: 127.0.0.1
5156
apiServerPort: 39281
52-
checkedForUpdateAt: 1730501224
53-
latestRelease: v1.0.1
57+
checkedForUpdateAt: 1737636738
58+
checkedForLlamacppUpdateAt: 1737636592699
59+
latestRelease: v1.0.8
60+
latestLlamacppRelease: v0.1.49
5461
huggingFaceToken: ""
62+
gitHubUserAgent: ""
63+
gitHubToken: ""
64+
llamacppVariant: linux-amd64-avx2-cuda-12-0
65+
llamacppVersion: v0.1.49
66+
enableCors: true
67+
allowedOrigins:
68+
- http://localhost:39281
69+
- http://127.0.0.1:39281
70+
- http://0.0.0.0:39281
71+
proxyUrl: ""
72+
verifyProxySsl: true
73+
verifyProxyHostSsl: true
74+
proxyUsername: ""
75+
proxyPassword: ""
76+
noProxy: example.com,::1,localhost,127.0.0.1
77+
verifyPeerSsl: true
78+
verifyHostSsl: true
79+
sslCertPath: ""
80+
sslKeyPath: ""
81+
supportedEngines:
82+
- llama-cpp
83+
- onnxruntime
84+
- tensorrt-llm
5585
```
Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
---
2-
title: Data Folder and App Folder
3-
description: Cortex.cpp's data folder and app folder.
2+
title: Data and App Directories
3+
description: Cortex's data and app directories.
44
slug: "data-folder"
55
---
66

77
import Tabs from "@theme/Tabs";
88
import TabItem from "@theme/TabItem";
99

1010
:::warning
11-
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
11+
🚧 Cortex.cpp is currently under active development. Our documentation outlines the
12+
intended behavior of Cortex and some functionality may not be fully implemented yet.
1213
:::
1314

1415
When you install Cortex.cpp, three types of files will be generated on your device:
1516

1617
- **Binary Files**
1718
- **Configuration Files**
18-
- **Data Folder**
19+
- **A Data Directory**
1920

2021
## Binary Files - under the App Folder
22+
2123
These are the executable files of the Cortex.cpp application. The file format varies depending on the operating system:
2224

2325
- **Windows**:
@@ -30,53 +32,73 @@ These are the executable files of the Cortex.cpp application. The file format va
3032
- cli: `/usr/local/bin/cortex`
3133
- server: `/usr/local/bin/cortex-server`
3234

33-
## Cortex.cpp Data Folder
34-
The data folder stores the engines, models, and logs required by Cortex.cpp. This folder is located at:
35+
## Cortex Data Directory
36+
37+
The data DIRECTORY stores the engines, models used by Cortex and the logs generated by the
38+
server and CLI. The data directory is located at:
3539

3640
- **Windows**: `C:\Users\<username>\cortexcpp`
3741
- **Linux**: `/home/<username>/cortexcpp`
3842
- **macOS**: `/Users/<username>\cortexcpp`
3943

40-
### Folder Structure
41-
The Cortex.cpp data folder typically follows this structure:
42-
43-
<Tabs>
44-
<TabItem value="Stable" label="Stable">
45-
```yaml
46-
~/.cortex
47-
├── models/
48-
│ └── model.list
49-
│ └── huggingface.co/
50-
│ └── <repo_name>/
51-
└── <branch_name>/
52-
└── model.yaml
53-
└── model.gguf
54-
│ └── cortex.so/
55-
│ └── <repo_name>/
56-
│ └── <branch_name>/
57-
└── ...engine_files
58-
└── model.yaml
59-
│ └── imported/
60-
└── imported_model.yaml
61-
├── logs/
62-
│ └── cortex.txt
63-
└── cortex-cli.txt
64-
└── engines/
65-
└── llamacpp
66-
```
67-
</TabItem>
68-
</Tabs>
69-
70-
#### `cortexcpp`
71-
The main directory that stores all Cortex-related files, located in the user's home directory.
44+
### Directory Structure
45+
46+
The Cortex data directory can be found in the user's home directory, and
47+
it typically follows the structure below:
48+
49+
```
50+
~/cortexcpp
51+
├── cortex.db
52+
├── engines/
53+
│   ├── cortex.llamacpp/
54+
│   ├── deps/
55+
│   │   ├── libcublasLt.so.12
56+
│   │   └── libcudart.so.12
57+
│   └── linux-amd64-avx2-cuda-12-0/
58+
│   └── ...
59+
├── files
60+
├── logs/
61+
│   ├── cortex-cli.log
62+
│   └── cortex.log
63+
├── models/
64+
│   ├── cortex.so/
65+
│   │   ├── deepseek-r1-distill-llama-8b/
66+
│   │   │   └── 8b-gguf-q2-k/
67+
│   │   │   ├── metadata.yml
68+
│   │   │   ├── model.gguf
69+
│   │   │   └── model.yml
70+
│   │   └── ...
71+
│   └── huggingface.co/
72+
│   ├── bartowski/
73+
│   │   └── phi-4-GGUF/
74+
│   │   ├── phi-4-Q3_K_S.gguf
75+
│   │   └── phi-4-Q3_K_S.yml
76+
│   └── unsloth/
77+
│   └── DeepSeek-R1-Distill-Qwen-1.5B-GGUF/
78+
│   ├── DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf
79+
│   └── DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.yml
80+
└── threads
81+
```
82+
7283
#### `models/`
73-
Contains the AI models used by Cortex for processing and generating responses.
84+
85+
Contains all of the models used by Cortex for processing and generating responses. These models can come from
86+
anywhere in the HuggingFace model Hub or the Cortex model Hub.
87+
7488
:::info
7589
For more information regarding the `model.list` and `model.yaml`, please see [here](/docs/capabilities/models/model-yaml).
7690
:::
91+
7792
#### `logs/`
78-
Stores log files that are essential for troubleshooting and monitoring the performance of the Cortex.cpp API server and CLI.
7993

80-
We use Trantor for logging, which ensures non-blocking, thread-safe, multi-stream file logging without affecting system performance. Trantor automatically creates a new log file for each server session, based on the date and time, simplifying debugging. It also supports setting limits on log file size and the number of log files per session.
94+
Stores log files from the Cortex server and CLI. These are essential for troubleshooting and
95+
monitoring performance.
96+
97+
We use [Trantor](https://github.com/an-tao/trantor) for logging, which ensures non-blocking, thread-safe,
98+
and multi-stream file logging without affecting your system's performance. Trantor automatically creates a
99+
new log file for each server session based on the date and time, simplifying debugging. It also supports
100+
setting limits on log file size and the number of log files per session.
101+
81102
#### `engines/`
82-
Stores the necessary dependencies and engine files needed to run Cortex on supported engines.
103+
104+
Stores the necessary dependencies and engine files needed to run run models on via the supported engines.

docs/docs/architecture/updater.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ import Tabs from "@theme/Tabs";
88
import TabItem from "@theme/TabItem";
99

1010
:::warning
11-
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
11+
🚧 Cortex.cpp is currently under active development. Our documentation outlines the intended behavior of
12+
Cortex, which may not yet be fully implemented in the codebase.
1213
:::
1314

14-
This document outlines the architectural design for a C++ updater responsible for downloading and executing installers for two binaries: CLI and Server.
15+
This document outlines the architectural design for a C++ updater responsible for downloading and executing
16+
the installers for the CLI and Server binaries.
1517

1618
## Overview
1719

18-
The updater is designed to check for available updates, download the necessary installer files, and execute them to update the CLI and Server binaries. The architecture consists of several key components that work together to achieve this functionality.
20+
The updater is designed to check for available updates, download the necessary installer files, and execute
21+
them to update the CLI and Server binaries.
1922

2023
## Components
2124

@@ -24,7 +27,7 @@ The updater is designed to check for available updates, download the necessary i
2427
- **Purpose**: Responsible for checking the current version of the installed binaries and determining if updates are available.
2528
- **Responsibilities**:
2629
- Retrieve the current version from local installations.
27-
- Fetch the latest version information from a remote source, latest version information is saved to `.cortexrc`.
30+
- Fetch information regarding the latest version from a remote source and save such info in `.cortexrc`.
2831
- Determine if an update is necessary based on version comparison.
2932

3033
### 2. **Installer Download Manager**
@@ -61,7 +64,8 @@ The updater is designed to check for available updates, download the necessary i
6164
- It fetches the latest version information from a remote source.
6265

6366
3. **Update Decision**:
64-
- If newer versions are available, the updater proceeds to download the installers; otherwise, it informs the user that no updates are necessary.
67+
- If newer versions are available, the updater proceeds to download the installers; otherwise, it informs the
68+
user that no updates are necessary.
6569

6670
4. **Download Process**:
6771
- The Installer Download Manager downloads the latest installer files using HTTP requests.
@@ -72,5 +76,6 @@ The updater is designed to check for available updates, download the necessary i
7276
- It monitors the installation process, capturing any output or errors.
7377

7478
6. **Completion Notification**:
75-
- After successful installation, the User Interface notifies users of completion or any issues encountered during installation.
76-
- Logs are updated with relevant information about the update process.
79+
- After successful installation, the User Interface notifies users of completion or any issues encountered
80+
during installation.
81+
- Logs are updated with relevant information about the update process.

0 commit comments

Comments
 (0)