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

@gpt-mind/core

v0.1.0

Published

The core classes of the GPT Mind library

Downloads

1

Readme

GPT Mind Core

The Mind library is a JavaScript library for building conversational agents that can generate responses based on a set of pre-defined rules. It allows you to define a state map, bindings between agents, and a set of agents that can generate responses based on input statements.

Installation

You can install the Mind library using npm:

npm install @gpt-mind/core

Usage

To use the Mind library, you need to create an instance of the Mind class and pass it a configuration object. The configuration object should have the following properties:

  • stateMap: An object representing the current state of the conversation.
  • bindings: An object mapping agents to other agents that they are bound to.
  • agents: An object containing the definitions of the agents.
  • start: An object representing the initial state of the conversation.
  • sources: An object mapping agents to functions that generate responses based on the current state of the conversation.

Here is an example of how to use the Mind library:

import { Mind } from 'mind-library';
imoport OpenAI from 'openai-api';

const openAI = new OpenAI('sk-...');

function complete(query, options) {
  return openAI.complete({
    engine: 'davinci',
    prompt: query,
    maxTokens: 100,
    temperature: 0.9,
    topP: 1,
    presencePenalty: 0,
    frequencyPenalty: 0,
    bestOf: 1,
    n: 1,
    stream: false,
    stop: ['\n', '###'],
    ...options
  });
}

const config = {
  stateMap: {},
  bindings: {
    "input": ["agent1"],
    "agent1": ['agent2'],
    "agent2": ['agent3'],
    "agent3": ['output', 'agent4'],
    "agent4": ["internal"],
    "internal": ['canVisualize', 'think'],
    "canVisualize": ["visualize"],
    "visualize": ["internal"],
    "output": []
  },
  agents: {
    "agent1": "generate a description of the statement \"{{input}}\"",
    "agent2": "generate a response to the statement \"{{agent1}}\"",
    "agent3": "generate a response given statements \"{{agent1}}\"\nand statements \"{{agent2}}\"",
    "agent4": "generate a response free of social mind to the statement \"{{agent1,agent2}}\"",
    "canVisualize": "is there visualizable imagery in the statement \"{{agent1,agent2}}\"",
    "visualize": "generate a detailed description of the imagery in the statement \"{{agent1,agent2}}\"",
  },
  start: {},
  sources: {
    "agent1": (agent, query, options) => complete(query, options),
    "agent2": (agent, query, options) => complete(query, options),
    "agent3": (agent, query, options) => complete(query, options),
    "agent4": (agent, query, options) => complete(query, options),
    "canVisualize": (agent, query, options) => complete(query, options),
    "visualize": (agent, query, options) => Automatic111.txt2img(query, "", { steps: 20 }),
    "think": (agent, query, options) => complete(query, options),
  }
};

const mind = new Mind(config);

mind.on('output', (event, output) => {
  console.log(output);
});

mind.input('agent1', 'Hello');

In this example, we create an instance of the Mind class with a configuration object that defines a set of agents that can generate responses based on input statements. We then register an event listener for the output event, which is triggered when an agent generates a response. Finally, we call the input method of the mind instance to start the conversation with the agent1 agent.

API

Mind(config: Object)

The Mind class constructor takes a configuration object as an argument. The configuration object should have the following properties:

stateMap: An object representing the current state of the conversation. bindings: An object mapping agents to other agents that they are bound to. agents: An object containing the definitions of the agents. start: An object representing the initial state of the conversation. sources: An object mapping agents to functions that generate responses based on the current state of the conversation.

on(event: string, callback: (event: string, output: string) => void)

Registers an event listener for the specified event. The callback function is called when the event is triggered, and is passed two arguments: the name of the event, and the output generated by the agent that triggered the event.

once(event: string, callback: (event: string, output: string) => void)

Registers an event listener for the specified event that will only be called once. The callback function is called when the event is triggered, and is passed two arguments: the name of the event, and the output generated by the agent that triggered the event.

off(event: string, callback: (event: string, output: string) => void)

Removes the specified event listener.

emit(event: string, output: any)

Triggers the specified event with the given output.

input(agent: string, query: string)

Sets the input for the specified agent and triggers the conversation.

run(agent: string)

Runs the specified agent and its bound agents.

complete(agent: any, query: string, options: any)

Generates a response for the specified agent with the given query and options.

Contributing

Contributions are welcome!

Please read the [contributing guidelines](