diff --git a/docs/docs/developer/03-build-engine/01-your-first-engine.md b/docs/docs/developer/03-build-engine/01-your-first-engine.md index 0670d63c4..2ec645339 100644 --- a/docs/docs/developer/03-build-engine/01-your-first-engine.md +++ b/docs/docs/developer/03-build-engine/01-your-first-engine.md @@ -1,7 +1,7 @@ --- -title: Your First Engine -slug: /developer/build-engine/your-first-engine/ -description: A quick start on how to build your first engine +title: Build Your First Engine +slug: /developer/build-engine/build-your-first-engine/ +description: A quick start on how to build your first engine. keywords: [ Jan AI, @@ -17,8 +17,50 @@ keywords: ] --- -:::caution -This is currently under development. +To quickly build your own inference engine using Jan's template, follow the steps below: + +## 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 \ No newline at end of file +## 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. diff --git a/docs/docs/developer/03-build-engine/02-engine-anatomy.md b/docs/docs/developer/03-build-engine/02-engine-anatomy.md index 1e7f559da..5d26fdff1 100644 --- a/docs/docs/developer/03-build-engine/02-engine-anatomy.md +++ b/docs/docs/developer/03-build-engine/02-engine-anatomy.md @@ -17,6 +17,16 @@ keywords: ] --- -:::caution -This is currently under development. -::: +![plugin-diagram](./asset/plugin.png) + +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. \ No newline at end of file diff --git a/docs/docs/developer/03-build-engine/asset/plugin.png b/docs/docs/developer/03-build-engine/asset/plugin.png new file mode 100644 index 000000000..f5f032e0d Binary files /dev/null and b/docs/docs/developer/03-build-engine/asset/plugin.png differ