Skip to content

Commit

Permalink
Merge branch 'chore/models-api' of github.com:janhq/nitro into chore/…
Browse files Browse the repository at this point in the history
…models-api
  • Loading branch information
vansangpfiev committed Nov 4, 2024
2 parents 16ba286 + 4589ce7 commit 38cde94
Show file tree
Hide file tree
Showing 12 changed files with 511 additions and 38 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Cortex releases 2 preview versions for advanced users to try new features early
#### Windows

1. Clone the Cortex.cpp repository [here](https://github.com/janhq/cortex.cpp).
2. Navigate to the `engine > vcpkg` folder.
2. Navigate to the `engine` folder.
3. Configure the vpkg:

```bash
Expand All @@ -294,16 +294,16 @@ cd vcpkg
vcpkg install
```

4. Build the Cortex.cpp inside the `build` folder:
4. Build the Cortex.cpp inside the `engine/build` folder:

```bash
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder_in_cortex_repo/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
cmake --build . --config Release
```

5. Use Visual Studio with the C++ development kit to build the project using the files generated in the `build` folder.
6. Verify that Cortex.cpp is installed correctly by getting help information.
5. Verify that Cortex.cpp is installed correctly by getting help information.

```sh
cortex -h
Expand All @@ -312,7 +312,7 @@ cortex -h
#### MacOS

1. Clone the Cortex.cpp repository [here](https://github.com/janhq/cortex.cpp).
2. Navigate to the `engine > vcpkg` folder.
2. Navigate to the `engine` folder.
3. Configure the vpkg:

```bash
Expand All @@ -321,17 +321,16 @@ cd vcpkg
vcpkg install
```

4. Build the Cortex.cpp inside the `build` folder:
4. Build the Cortex.cpp inside the `engine/build` folder:

```bash
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake .. -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder_in_cortex_repo/vcpkg/scripts/buildsystems/vcpkg.cmake
make -j4
```

5. Use Visual Studio with the C++ development kit to build the project using the files generated in the `build` folder.
6. Verify that Cortex.cpp is installed correctly by getting help information.
5. Verify that Cortex.cpp is installed correctly by getting help information.

```sh
cortex -h
Expand All @@ -340,7 +339,7 @@ cortex -h
#### Linux

1. Clone the Cortex.cpp repository [here](https://github.com/janhq/cortex.cpp).
2. Navigate to the `engine > vcpkg` folder.
2. Navigate to the `engine` folder.
3. Configure the vpkg:

```bash
Expand All @@ -349,17 +348,16 @@ cd vcpkg
vcpkg install
```

4. Build the Cortex.cpp inside the `build` folder:
4. Build the Cortex.cpp inside the `engine/build` folder:

```bash
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake .. -DCMAKE_TOOLCHAIN_FILE=path_to_vcpkg_folder_in_cortex_repo/vcpkg/scripts/buildsystems/vcpkg.cmake
make -j4
```

5. Use Visual Studio with the C++ development kit to build the project using the files generated in the `build` folder.
6. Verify that Cortex.cpp is installed correctly by getting help information.
5. Verify that Cortex.cpp is installed correctly by getting help information.

```sh
cortex -h
Expand Down
3 changes: 0 additions & 3 deletions docs/docs/architecture/cortex-db.md

This file was deleted.

25 changes: 25 additions & 0 deletions docs/docs/architecture/cortex-db.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: cortex.db
description: cortex.db Overview.
slug: "cortex-db"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

:::warning
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
:::

This document outlines the architecture of the database designed to store and manage various types of entities and their associated metadata.

## Table Structure
### models Table
The `models` table is designed to hold metadata about various AI models. Below is the structure of the table:

| Column Name | Data Type | Description |
|--------------------|-----------|---------------------------------------------------------|
| model_id | TEXT | A unique identifier for each model (Primary Key). |
| author_repo_id | TEXT | The identifier for the repository where the model is stored. |
| branch_name | TEXT | The branch name in the repository that contains the model. |
| path_to_model_yaml | TEXT | The file path to the YAML configuration file for the model. |
35 changes: 21 additions & 14 deletions docs/docs/architecture/cortexrc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,37 @@ Cortex.cpp supports reading its configuration from a file called `.cortexrc`. Us
## File Location
The configuration file is stored in the following locations:

- **Windows**:
- Stable: `C:\Users\<username>\.cortexrc`
- Beta: `C:\Users\<username>\.cortexrc-beta`
- Nighty: `C:\Users\<username>\.cortexrc-nightly`
- **Linux**:
- Stable: `/home/<username>/.cortexrc`
- Beta: `/home/<username>/.cortexrc-beta`
- Nighty: `/home/<username>/.cortexrc-nightly`
- **macOS**:
- Stable: `/Users/<username>/.cortexrc`
- Beta: `/Users/<username>/.cortexrc-beta`
- Nighty: `/Users/<username>/.cortexrc-nightly`
- **Windows**: `C:\Users\<username>\.cortexrc`
- **Linux**: `/home/<username>/.cortexrc`
- **macOS**: `/Users/<username>/.cortexrc`

## Configuration Parameters
You can configure the following parameters in the `.cortexrc` file:
| Parameter | Description | Default Value |
|------------------|--------------------------------------------------|--------------------------------|
| `dataFolderPath` | Path to the folder where `.cortexrc` located. | User's home folder. |
| `apiServerHost` | Host address for the Cortex.cpp API server. | `127.0.0.1` |
| `apiServerPort` | Port number for the Cortex.cpp API server. | `39281` |
| `apiServerHost` | Host address for the Cortex.cpp API server. | `127.0.0.1` |
| `apiServerPort` | Port number for the Cortex.cpp API server. | `39281` |
| `logFolderPath` | Path the folder where logs are located | User's home folder. |
| `logLlamaCppPath` | The llama-cpp engine . | `./logs/cortex.log` |
| `logTensorrtLLMPath` | The tensorrt-llm engine log file path. | `./logs/cortex.log` |
| `logOnnxPath` | The onnxruntime engine log file path. | `./logs/cortex.log` |
| `maxLogLines` | The maximum log lines that write to file. | `100000` |
| `checkedForUpdateAt` | The last time for checking updates. | `0` |
| `latestRelease` | The lastest release vesion. | Empty string |
| `huggingFaceToken` | HuggingFace token. | Empty string |

Example of the `.cortexrc` file:
```
logFolderPath: /Users/<username>/cortexcpp
logLlamaCppPath: ./logs/cortex.log
logTensorrtLLMPath: ./logs/cortex.log
logOnnxPath: ./logs/cortex.log
dataFolderPath: /Users/<username>/cortexcpp
maxLogLines: 100000
apiServerHost: 127.0.0.1
apiServerPort: 39281
checkedForUpdateAt: 1730501224
latestRelease: v1.0.1
huggingFaceToken: ""
```
76 changes: 76 additions & 0 deletions docs/docs/architecture/updater.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Updater
description: Updater Overview.
slug: "updater"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

:::warning
🚧 Cortex.cpp is currently under development. Our documentation outlines the intended behavior of Cortex, which may not yet be fully implemented in the codebase.
:::

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

## Overview

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.

## Components

### 1. **Version Management Module**

- **Purpose**: Responsible for checking the current version of the installed binaries and determining if updates are available.
- **Responsibilities**:
- Retrieve the current version from local installations.
- Fetch the latest version information from a remote source, latest version information is saved to `.cortexrc`.
- Determine if an update is necessary based on version comparison.

### 2. **Installer Download Manager**

- **Purpose**: Handles downloading the installer files from specified URLs.
- **Responsibilities**:
- Manage HTTP requests to fetch installer files.
- Handle errors during download.
- Save downloaded installers in a temporary directory.

### 3. **Installer Execution Module**

- **Purpose**: Executes the downloaded installer files to perform updates.
- **Responsibilities**:
- Launch the installer with appropriate command-line arguments.
- Monitor the installation process and capture any output or errors.
- Ensure that installation completes successfully before proceeding.

### 4. **User Interface (CLI)**

- **Purpose**: Provides a command-line interface for users to initiate updates and view status messages.
- **Responsibilities**:
- Display current version information for CLI and Server: `cortex -v`
- Inform users about available updates and progress during downloading and installation.
- Handle user input for initiating updates: `(sudo) cortex update`

## Workflow

1. **Initialization**:
- The updater starts and initializes all necessary modules.

2. **Version Check**:
- The Version Management Module retrieves the current versions of both CLI and Server from local installations.
- It fetches the latest version information from a remote source.

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

4. **Download Process**:
- The Installer Download Manager downloads the latest installer files using HTTP requests.
- Progress is reported back to the User Interface.

5. **Installer Execution**:
- Once downloaded, the Installer Execution Module runs the installer with silent mode.
- It monitors the installation process, capturing any output or errors.

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

0 comments on commit 38cde94

Please sign in to comment.