Giter Club home page Giter Club logo

superagent-js's Introduction

Superagent Javascript SDK 🥷

This is the offical Javascript SDK for superagent.sh.

GitHub Contributors GitHub Last Commit GitHub Issues GitHub Pull Requests Github License Discord

Getting started

1. Installation

Install the superagentai-js package.

npm i superagentai-js

2. Usage

import SuperagentSDK from "superagentai-js";

const superagent = new SuperagentSDK(process.env.SUPERAGENT_API_TOKEN);

Examples

API Reference

The SDK exposes the following three resources: Prompts, Documents and Agents. Below you will find a schematic overivew of each resource:

Agents

// List all agents
await superagent.agents().list();

// Retuns a specific agent
await superagent.agents().get("<AGENT_ID>");

// Delete agent
await superagent.agents().delete("<AGENT_ID>");

// Create agent
await superagent.agents().create({
  name: "Ny agent",
  llm: {
    provider: "openai-chat",
    model: "gpt-4",
    api_key: process.env.OPENAI_API_KEY,
  },
  has_memory: true,
  promptId: "<PROMPT_ID>",
  documentId: "<DOCUMENT_ID>",
  toolId: "<TOOL_ID>",
});

// Run an agent
await superagent.agents().predict({
  input: { human_input: "Hello" },
  has_streaming: true,
});

Tools

// List all tools
await superagent.tools().list();

// Retuns a specific tool
await superagent.tools().get("<TOOL_ID>");

// Delete tool
await superagent.tools().delete("<TOOL_ID>");

// Create tool
await superagent.tools().create({
  name: "My tool",
  type: "SEARCH",
});

Documents

// List all documents
await superagent.documents().list();

// Retuns a specific document
await superagent.documents().get("<DOCUMENT_ID>");

// Delete document
await superagent.documents().delete("<DOCUMENT_ID>");

// Create document
await superagent.documents().create({
  name: "Ny agent",
  url: "https://digitalassets.tesla.com/tesla-contents/image/upload/IR/TSLA-Q1-2023-Update",
  type: "PDF",
  authorization: null,
  splitter: { type: "character", chunk_size: 1000, chunk_overlap: 0 },
});

Prompts

  // List all prompts
  await superagent.prompts().list();

  // Retuns a specific prompt
  await superagent.prompts().get("<PROMPT_ID>");

  // Update a specific prompt
  await superagent.prompts().update("<PROMPT_ID>", {name: "Some updated name"});

  // Delete prompt
  await superagent.prompts().delete("<PROMPT_ID>");

  // Create prompt
  await superagent.prompts().create({
    name: "My prompt",
    input_variables: ["human_input", "chat_history"],
    template="You are an AI assistant that should answer a humans question. \n {chat_history} \n\n Human input: {human_input} \n Answer:"
  });

superagent-js's People

Contributors

homanp avatar petarsrepo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.