Socket
Book a DemoInstallSign in
Socket

@polymath-ai/ingest

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polymath-ai/ingest

An ingest library for Polymath

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
3
Created
Source

Polymath Ingest

This is a libraries that can be used to ingest data from a source and convert it into a format that can be used by the Polymath system.

Standalone ingestion tool

See: @polymath/cli

API

Extend Ingester for use in the CLI

You are able to extend the Ingester class to create your own importer.

  • Create a new class that extends Ingester
  • Implement the getStringsFromSource method a. getStringsFromSource should return an AsyncGenerator of partially filled out bits that is the full string of data from the source. b. The text property of the bit should be the full string of data from the source. The info property of the bit should be an object that contains any additional information about the bit. The info property is optional.
class MYRSS extends Ingester {

  constructor() {
    super();
  }

  async *getStringsFromSource(source: string): AsyncGenerator<Bit> {
    const feed = await (new RSSParser).parseURL(source);
    console.log(feed.title); // feed will have a `foo` property, type as a string

    for (const item of feed.items) {
      yield {
        text: item.content || "",
        info: {
          url: item.link || "",
          title: item.title || "",
        }
      };
    }
  }

}

E.g: > polymath ingest rss https://paul.kinlan.me/index.xml

Embed the Ingest process

It is possible to use the Ingest process directly in your own code, for example if you want to run a custom export as the embeddings are generated. The process will load the correct plugin and start processing it.

import { Ingest } from "@polymath/ingest";

const ingest = new Ingest({ /* options */ });

for await(const bit of ingest.run({ args, options, command })) {
  console.log(`${bit.url}: Embedding: ${bit.embedding}`);)  
}

Keywords

polymath

FAQs

Package last updated on 09 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.