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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mavenagi/knowledge-base-integration

v1.0.1

Published

This library facilitates integration between MavenAGI and external knowledge bases. It allows you to create the hooks necessary to sync data from various sources into a MavenAGI knowledge base from a Maven AGI App Studio app.

Downloads

43

Readme

@mavenagi/knowledge-base-integration

This library facilitates integration between MavenAGI and external knowledge bases. It allows you to create the hooks necessary to sync data from various sources into a MavenAGI knowledge base from a Maven AGI App Studio app.

Installation

npm install @mavenagi/knowledge-base-integration

Usage

To use this library, create an instance of MavenAGIKnowledgeBaseIntegration with custom functions for your specific integration:

import MavenAGIKnowledgeBaseIntegration, { KnowledgeDocumentContentType } from '@mavenagi/knowledge-base-integration';

const integration = new MavenAGIKnowledgeBaseIntegration({
  preInstallTest: async ({ settings, organizationId, agentId }) => {
    // Implement your pre-install test logic here
  },
  generatePaginatedResults: async function* ({ settings, organizationId, agentId }) {
    // Implement your data fetching logic in an async generator here
    // yield results as an array of { id, title, content } objects
  },
  translateContent: (content: string) => {
    // Optional: Implement your content translation logic here
    // If not provided, content will be passed through unchanged
  },
  contentType: KnowledgeDocumentContentType.Html // Optional, defaults to HTML
});

Returned Methods

preInstall(config: IntegrationConfig): Promise

This method tests the connection to your data provider before installation.

postInstall(config: IntegrationConfig): Promise

This method creates or updates the knowledge base and syncs all data after installation.

knowledgeBaseRefreshed(config: IntegrationConfig): Promise

This method syncs all data when the knowledge base is refreshed.

Example

// src/index.ts
import MavenAGIKnowledgeBaseIntegration, { type IntegrationConfig, KnowledgeDocumentContentType } from '@mavenagi/knowledge-base-integration';

const { preInstall, postInstall, knowledgeBaseRefreshed } = 
  new MavenAGIKnowledgeBaseIntegration({
    preInstallTest: async ({ settings }: IntegrationConfig) => {
      const response = await fetch(
        `${settings.apiURL}/api/v2/test_endpoint`,
        {
          headers: {
            AUTH_HEADER: settings.authHeader
          }
        }
      );
      if (!response.ok) throw new Error('Failed to connect to API');
    },
    generatePaginatedResults: async function* ({ settings }: IntegrationConfig) {
      let nextPageUrl =
        `${settings.confluenceUrl}/api/v2/documents`;
      while (nextPageUrl) {
        const response = await fetch(nextPageUrl, {
          headers: {
            AUTH_HEADER: settings.authHeader
          }
        });
        const data = await response.json();
        yield data.results.map(({ title, id, body }) => ({ title, id, content: body.html }));
        nextPageUrl = data._links.next;
      }
    },
    translateContent: (content: string) => {
      // Optional: Implement content translation if needed
      return content;
    },
    contentType: KnowledgeDocumentContentType.Html
  })

export default {
  preInstall,
  postInstall,
  knowledgeBaseRefreshed,
  executeAction() => {}
}

Development

To build the project:

npm run build

To run tests:

npm run test