npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@equinor/fusion-framework-module-ai

v2.0.1

Published

AI module for Fusion Framework providing AI/LLM integration capabilities

Readme

@equinor/fusion-framework-module-ai

AI services module for Fusion Framework applications, providing integration with language models, embeddings, and vector stores.

Features

  • Language Models: Support for various AI language models (OpenAI, Azure OpenAI, etc.)
  • Embeddings: Text embedding services for semantic search and similarity
  • Vector Stores: Vector database integration for storing and searching embeddings
  • Flexible Configuration: Support for both eager and lazy initialization
  • Type Safety: Full TypeScript support with comprehensive type definitions

Installation

pnpm add @equinor/fusion-framework-module-ai

Usage

Basic Configuration

import { Framework } from '@equinor/fusion-framework';
import { enableAI, type AIServiceType } from '@equinor/fusion-framework-module-ai';
import { AzureOpenAIModel } from '@equinor/fusion-framework-module-ai/lib/azure/AzureOpenAIModel';
import { AzureOpenAiEmbed } from '@equinor/fusion-framework-module-ai/lib/azure/AzureOpenAiEmbed';
import { AzureVectorStore } from '@equinor/fusion-framework-module-ai/lib/azure/AzureVectorStore';

const framework = new Framework({
  name: 'AI Example App',
  modules: [
    enableAI(config => 
      config
        .setModel('gpt-4', new AzureOpenAIModel({
          apiKey: process.env.AZURE_OPENAI_API_KEY!,
          modelName: 'gpt-4'
        }))
        .setEmbedding('embeddings', new AzureOpenAiEmbed({
          apiKey: process.env.AZURE_OPENAI_API_KEY!,
          modelName: 'text-embedding-ada-002'
        }))
        .setVectorStore('vector-db', new AzureVectorStore({
          endpoint: process.env.AZURE_SEARCH_ENDPOINT!,
          apiKey: process.env.AZURE_SEARCH_API_KEY!,
          indexName: 'documents'
        }))
    )
  ]
});

Lazy Initialization with Factory Functions

const framework = new Framework({
  name: 'AI App with Lazy Loading',
  modules: [
    enableAI(config => 
      config
        .setModel('gpt-4-lazy', (args) => new AzureOpenAIModel({
          apiKey: args.env.AZURE_OPENAI_API_KEY,
          modelName: 'gpt-4'
        }))
        .setEmbedding('embeddings-lazy', (args) => new AzureOpenAiEmbed({
          apiKey: args.env.AZURE_OPENAI_API_KEY,
          modelName: 'text-embedding-ada-002'
        }))
        .setVectorStore('vector-db-lazy', (args) => new AzureVectorStore({
          endpoint: args.env.AZURE_SEARCH_ENDPOINT,
          apiKey: args.env.AZURE_SEARCH_API_KEY,
          indexName: 'documents'
        }))
    )
  ]
});

Using the AI Provider

async function useAIProvider(framework: Framework) {
  const frameworkInstance = await framework.initialize();
  const aiProvider = frameworkInstance.modules.ai;

  // Get configured services
  const chatService = aiProvider.getService('chat', 'gpt-4') as IModel;
  const embeddingService = aiProvider.getService('embeddings', 'embeddings') as IEmbed;
  const searchService = aiProvider.getService('search', 'vector-db') as IVectorStore;

  // Use the services
  const response = await chatService.execute([
    { role: 'user', content: 'Hello, how are you?' }
  ]);

  const embeddings = await embeddingService.execute('This is a test document');
  
  const searchResults = await searchService.execute('search query');
}

API Reference

AIConfigurator

The AIConfigurator class provides a fluent API for configuring AI services.

Methods

  • setModel(identifier: string, modelOrFactory: ValueOrCallback<IModel>): this
  • setEmbedding(identifier: string, embeddingOrFactory: ValueOrCallback<IEmbed>): this
  • setVectorStore(identifier: string, vectorStoreOrFactory: ValueOrCallback<IVectorStore>): this

AIProvider

The AIProvider class provides access to configured AI services.

Methods

  • getService(type: AIServiceType, identifier: string): IModel | IEmbed | IVectorStore - Get a configured AI service

Types

AIServiceType

Type for AI service types.

type AIServiceType = 'chat' | 'embeddings' | 'search';

ValueOrCallback

Represents either a value of type T or a callback that creates a value of type T.

type ValueOrCallback<T> = T | ConfigBuilderCallback<T>;

AIModuleConfig

Configuration object generated by the AIConfigurator.

type AIModuleConfig = {
  models?: Record<string, ValueOrCallback<IModel>>;
  embeddings?: Record<string, ValueOrCallback<IEmbed>>;
  vectorStores?: Record<string, ValueOrCallback<IVectorStore>>;
};

Error Handling

The AI module provides comprehensive error handling:

  • Service Not Found: Clear error messages when requesting non-existent services
  • Configuration Errors: Validation of configuration parameters
  • Service Errors: Wrapped service-specific errors with context

Contributing

Please refer to the main Fusion Framework contributing guidelines for information on how to contribute to this module.