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

dpgjs

v2024.4.21

Published

DSPyGen JS is a JavaScript/TypeScript library designed to streamline the development of data processing and generation pipelines, with a special focus on integrating language models and other AI-driven processes. This README provides an overview of the ke

Downloads

2

Readme

DSPyGen JS

DSPyGen JS is a JavaScript/TypeScript library designed to streamline the development of data processing and generation pipelines, with a special focus on integrating language models and other AI-driven processes. This README provides an overview of the key components and functionalities within the library, tailored specifically to the TypeScript code snippets provided earlier.

Overview

DSPyGen JS leverages modern TypeScript features to offer developers a robust framework for building and managing complex data processing and generation pipelines. Key functionalities include interfacing with language models, handling events with a custom actor model, and validating data against JSON schemas.

Key Features

  • GroqLM Integration: A class for interacting with Groq language models, supporting basic requests and forwarding prompts to the model.
  • Event Handling: Utilize the Actor model for concurrent operations and message handling within the pipeline.
  • Data Validation: Classes that validate data objects against predefined JSON schemas, ensuring the integrity of data throughout the pipeline.
  • Utilities: Helper functions and classes for common tasks, such as extracting JSON from strings and handling custom event data.

Installation

To use DSPyGen JS in your project, ensure you have Node.js and npm or yarn installed. Then, add DSPyGen JS to your project dependencies using npm or yarn:

npm install dpgjs
# or
yarn add dpgjs

Usage

GroqLM Integration

The GroqLM class allows for seamless interaction with Groq's language models. It's designed to handle various communication errors gracefully and provides a simple interface for making predictions:

import { GroqLM, GroqModels } from "dpgjs";

const model = new GroqLM(GroqModels.llama2);
model.forward(prompt)
  .then(response => console.log(response))
  .catch(error => console.error(error));

Actor System for Event Handling

DSPyGen JS employs an actor system to manage concurrency and facilitate message passing between different components of your pipeline:

import { ActorSystem, BaseActor, BaseMessage } from "dpgjs";

class MyActor extends BaseActor {
  handleMessage(message: BaseMessage) {
    // Handle message
  }
}

const system = new ActorSystem();
const actor = system.actorOf(MyActor);

Data Validation with JSON Schema

Validating data objects against JSON schemas is streamlined with the VEvent class, which automatically validates its properties upon creation:

import { VEvent } from "dpgjs";

const eventData = {
  // Event data following the VEvent schema
};
const event = new VEvent(eventData);

Extracting JSON from Strings

The utility function extract can be used to parse strings and extract JSON objects, simplifying the process of dealing with unstructured data:

import { extract } from "dpgjs";

const jsonString = extract('{"key": "value"}');
console.log(jsonString); // Outputs the parsed JSON object

Testing

DSPyGen JS comes with built-in support for unit testing using Vitest, allowing you to ensure the reliability and correctness of your pipeline components:

import { describe, it, expect } from "vitest";
import { MyComponent } from "dpgjs";

describe("MyComponent", () => {
  it("should behave correctly", () => {
    const component = new MyComponent();
    expect(component.doSomething()).toBe(true);
  });
});

Conclusion

DSPyGen JS provides a comprehensive set of tools for building data processing and generation pipelines, emphasizing ease of use, flexibility, and reliability. Whether you're working with complex language models or need a robust system for event handling and data validation, DSPyGen JS offers a solid foundation for your projects.