docs: Update developer build engine content
This commit is contained in:
parent
9876cf2156
commit
ba02b5898d
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Your First Engine
|
title: Build Your First Engine
|
||||||
slug: /developer/build-engine/your-first-engine/
|
slug: /developer/build-engine/build-your-first-engine/
|
||||||
description: A quick start on how to build your first engine
|
description: A quick start on how to build your first engine.
|
||||||
keywords:
|
keywords:
|
||||||
[
|
[
|
||||||
Jan AI,
|
Jan AI,
|
||||||
@ -17,8 +17,50 @@ keywords:
|
|||||||
]
|
]
|
||||||
---
|
---
|
||||||
|
|
||||||
:::caution
|
To quickly build your own inference engine using Jan's template, follow the steps below:
|
||||||
This is currently under development.
|
|
||||||
|
## Step 1: Clone or Download the Jan Extension Template
|
||||||
|
1. Navigate to the Extension Template repository here: https://github.com/janhq/extension-template.
|
||||||
|
2. Clone or download the repository.
|
||||||
|
|
||||||
|
## Step 2: Setup the Plugin Metadata
|
||||||
|
1. Navigate to the `package.json` file.
|
||||||
|
2. Update your plugin metadata such as:
|
||||||
|
- Name
|
||||||
|
- Main Entry
|
||||||
|
- Description
|
||||||
|
- Version
|
||||||
|
|
||||||
|
## Step 3: Update the Engine Code
|
||||||
|
You can update the plugin source code provided in the extension template in `/src` folder with your own code. The source code will be run when your plugin extension functions are invoked. The source code will also tell how your plugin behaves when added to Jan. To update, follow the steps below:
|
||||||
|
1. Navigate to the `/src` folder.
|
||||||
|
2. Select the `index.ts` file.
|
||||||
|
3. Customize the code to your needs.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
Most functions in Jan Plugin Extensions operate asynchronously.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
A quickstart on how to integrate tensorrt llm
|
## Step 4: Setup the Engine
|
||||||
|
1. Navigate to your engine folder.
|
||||||
|
2. Install the dependencies using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
3. Compile the source code using the following command:
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 5: Install the Engine
|
||||||
|
1. Navigate to your plugin folder.
|
||||||
|
2. Bundle the Typescript files into a single bundled assets `tgz` file by using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run bundle
|
||||||
|
```
|
||||||
|
3. Open your Jan application.
|
||||||
|
4. Click **Settings** > **Extensions**.
|
||||||
|
5. Click the **Select** button next to the **Manual Import** section.
|
||||||
|
6. Select the `.tgz` file that you have generated.
|
||||||
|
|||||||
@ -17,6 +17,16 @@ keywords:
|
|||||||
]
|
]
|
||||||
---
|
---
|
||||||
|
|
||||||
:::caution
|

|
||||||
This is currently under development.
|
|
||||||
:::
|
The diagram above illustrates the class hierarchy and interface implementation for an extension. The plugin that you have created has two important aspects:
|
||||||
|
- `BaseExtension`
|
||||||
|
- `InferenceInterface`
|
||||||
|
### BaseExtension
|
||||||
|
This class acts as a base that defines the properties and methods for your engine. These methods include:
|
||||||
|
- `type`: Defines the type of the extension.
|
||||||
|
- `onLoad`: A method that will be called when the extension is loaded or registered into the Jan application.
|
||||||
|
- `onUnload`: A method for cleanup tasks when the extension is being removed or unloaded from the Jan application.
|
||||||
|
### InferenceInterface
|
||||||
|
This interface defines the methods that must be provided to implement your engine's interface.
|
||||||
|
- `inference(req) -> resp`: A method responsible for handling inference operations. It takes a request `req` as input and returns a response `resp`. This method's implementation should contain the logic for processing input data and producing an inference result.
|
||||||
BIN
docs/docs/developer/03-build-engine/asset/plugin.png
Normal file
BIN
docs/docs/developer/03-build-engine/asset/plugin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
Loading…
x
Reference in New Issue
Block a user