Faisal Amir 2a0601f75a
feat: remote engine management (#4364)
* feat: remote engine management

* chore: fix linter issue

* chore: remove unused imports

* fix: populate engines, models and legacy settings (#4403)

* fix: populate engines, models and legacy settings

* chore: legacy logics update configured remote engine

* fix: check exist path before reading

* fix: engines and models persist - race condition

* chore: update issue state

* test: update test cases

* chore: bring back Cortex extension settings

* chore: setup button gear / plus based apikey

* chore: fix remote engine from welcome screen

* chore: resolve linter issue

* chore: support request headers template

* chore: update engines using header_template instead of api_key_template

* chore: update models on changes

* fix: anthropic response template

* chore: fix welcome screen and debounce update value input

* chore: update engines list on changes

* chore: update engines list on change

* chore: update desc form add modal remote engines

* chore: bump cortex version to latest RC

* chore: fix linter

* fix: transform payload of Anthropic and OpenAI

* fix: typo

* fix: openrouter model id for auto routing

* chore: remove remote engine URL setting

* chore: add cohere engine and model support

* fix: should not clean on app launch - models list display issue

* fix: local engine check logic

* chore: bump app version to latest release 0.5.13

* test: fix failed tests

---------

Co-authored-by: Louis <louis@jan.ai>
2025-01-14 17:29:56 +07:00
..
2024-09-23 13:54:52 +07:00
2024-08-15 10:44:47 +07:00
2024-02-15 08:38:05 +07:00

@janhq/core

This module includes functions for communicating with core APIs, registering app extensions, and exporting type definitions.

Usage

Import the package

// Web / extension runtime
import * as core from "@janhq/core";

// Node runtime
import * as node from "@janhq/core/node";

Build an Extension

  1. Download an extension template, for example, https://github.com/janhq/extension-template.

  2. Update the source code:

    1. Open index.ts in your code editor.
    2. Rename the extension class from SampleExtension to your preferred extension name.
    3. Import modules from the core package.
      import * as core from "@janhq/core";
      
    4. In the onLoad() method, add your code:
      // Example of listening to app events and providing customized inference logic:
      import * as core from "@janhq/core";
      
      export default class MyExtension extends BaseExtension {
        // On extension load
        onLoad() {
          core.events.on(MessageEvent.OnMessageSent, (data) => MyExtension.inference(data, this));
        }
      
        // Customized inference logic
        private static inference(incomingMessage: MessageRequestData) {
      
          // Prepare customized message content
          const content: ThreadContent = {
            type: ContentType.Text,
            text: {
              value: "I'm Jan Assistant!",
              annotations: [],
            },
          };
      
          // Modify message and send out
          const outGoingMessage: ThreadMessage = {
            ...incomingMessage,
            content
          };
        }
      }
      
  3. Build the extension:

    1. Navigate to the extension directory.
    2. Install dependencies.
      yarn install
      
    3. Compile the source code. The following command keeps running in the terminal and rebuilds the extension when you modify the source code.
      yarn build
      
    4. Select the generated .tgz from Jan > Settings > Extension > Manual Installation.