default: {
    Model: {
        TextEmbedding: typeof TextEmbedding;
        TextGeneration: typeof TextGeneration;
    };
    Pipeline: {
        TextEmbedding: {
            embed: ((text: string) => Promise<Float32Array>);
            init: ((model_name: string, onnx_path: string, options?: Partial<TextEmbeddingOptions>) => Promise<void>);
            release: (() => Promise<void>);
        };
        TextGeneration: {
            generate: ((prompt: string, callback?: ((text: string) => void)) => Promise<string>);
            init: ((model_name: string, onnx_path: string, options?: Partial<InitOptions>) => Promise<void>);
            release: (() => Promise<void>);
        };
    };
}

Type declaration

  • Model: {
        TextEmbedding: typeof TextEmbedding;
        TextGeneration: typeof TextGeneration;
    }
  • Pipeline: {
        TextEmbedding: {
            embed: ((text: string) => Promise<Float32Array>);
            init: ((model_name: string, onnx_path: string, options?: Partial<TextEmbeddingOptions>) => Promise<void>);
            release: (() => Promise<void>);
        };
        TextGeneration: {
            generate: ((prompt: string, callback?: ((text: string) => void)) => Promise<string>);
            init: ((model_name: string, onnx_path: string, options?: Partial<InitOptions>) => Promise<void>);
            release: (() => Promise<void>);
        };
    }
    • TextEmbedding: {
          embed: ((text: string) => Promise<Float32Array>);
          init: ((model_name: string, onnx_path: string, options?: Partial<TextEmbeddingOptions>) => Promise<void>);
          release: (() => Promise<void>);
      }
      • embed: ((text: string) => Promise<Float32Array>)
          • (text): Promise<Float32Array>
          • Generates embeddings from the input text.

            Parameters

            • text: string

              The input text to generate embeddings from.

            Returns Promise<Float32Array>

            Float32Array containing the embedding vector.

      • init: ((model_name: string, onnx_path: string, options?: Partial<TextEmbeddingOptions>) => Promise<void>)
          • (model_name, onnx_path, options?): Promise<void>
          • Loads the model and tokenizer with the specified options.

            Parameters

            • model_name: string

              The name of the model to load.

            • onnx_path: string

              The path to the ONNX model.

            • Optionaloptions: Partial<TextEmbeddingOptions>

              Optional initialization options.

            Returns Promise<void>

      • release: (() => Promise<void>)
          • (): Promise<void>
          • Releases the resources used by the model.

            Returns Promise<void>

    • TextGeneration: {
          generate: ((prompt: string, callback?: ((text: string) => void)) => Promise<string>);
          init: ((model_name: string, onnx_path: string, options?: Partial<InitOptions>) => Promise<void>);
          release: (() => Promise<void>);
      }
      • generate: ((prompt: string, callback?: ((text: string) => void)) => Promise<string>)
          • (prompt, callback?): Promise<string>
          • Generates text based on the given prompt.

            Parameters

            • prompt: string

              The input prompt for text generation.

            • callback: ((text: string) => void) = ...

              Optional callback function to handle intermediate text.

                • (text): void
                • Parameters

                  • text: string

                  Returns void

            Returns Promise<string>

            The generated text.

      • init: ((model_name: string, onnx_path: string, options?: Partial<InitOptions>) => Promise<void>)
          • (model_name, onnx_path, options?): Promise<void>
          • Loads the model and tokenizer with the specified options.

            Parameters

            • model_name: string

              The name of the model to load.

            • onnx_path: string

              The path to the ONNX model.

            • Optionaloptions: Partial<InitOptions>

              Optional initialization options.

            Returns Promise<void>

      • release: (() => Promise<void>)
          • (): Promise<void>
          • Releases the resources used by the model.

            Returns Promise<void>