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

pieces-copilot-sdk

v1.1.9

Published

A Pieces OS SDK wrapper that allows anyone to easily create a Pieces Copilot experience with minimal code.

Downloads

13

Readme

Pieces Copilot SDK

This repository contains the Pieces Copilot SDK, a convenient wrapper around the Pieces OS Client SDK. It simplifies the process of interacting with your applications by providing a more user-friendly interface to the underlying Pieces OS Client SDK.

View on NPM

Installation

To use the Pieces Copilot SDK in your project, you need to install it via npm:

npm install pieces-copilot-sdk

For pnpm:

pnpm install pieces-copilot-sdk

For yarn:

yarn add pieces-copilot-sdk

Requirements

You must either have Pieces OS installed on your local machine or have access to a remote instance of Pieces OS to use this SDK.

Usage

First, you need to import the SDK and initialize it with your base URL. The base URL will depend on your setup:

  • If you are using a local instance of Pieces OS:
    • On macOS/Windows, use http://localhost:1000
    • On Linux, use http://localhost:5323
  • If you are using a remote instance of Pieces OS, use the URL you have set up for that.

Here's how you can initialize the SDK:

import { PiecesClient } from 'pieces-copilot-sdk';

// Replace 'your_base_url' with your actual base URL
const piecesClient = new PiecesClient({ baseUrl: 'your_base_url' });

Then, you can use the various methods provided by the SDK to interact with your applications.

Features

  • Simplified Interaction: The Pieces Copilot SDK simplifies the interaction with the Pieces OS Client SDK by providing easy-to-use methods for various operations.
  • Manage Conversations: The SDK provides various methods to manage conversations such as fetching a specific conversation, updating conversation name, and more.
  • Get User Profile Picture: Retrieve the user's profile picture using the getUserProfilePicture() method.

Methods

createConversation({ name?, firstMessage? })

This method creates a new conversation. It takes an optional name and optional first message as parameters. It returns a Promise that resolves to an object containing the new conversation and the answer to the first message (if provided).

Example usage:

const newConversation = await piecesClient.createConversation({
  name: 'Hello World Conversation',
  firstMessage: 'Hello, world!',
});

getConversation({ conversationId, includeRawMessages? })

This method retrieves a conversation by its ID. You can choose to include raw messages in the conversation by setting the includeRawMessages parameter to true. It returns a Promise that resolves to a Conversation object or undefined.

Example usage:

const conversation = await piecesClient.getSpecificConversation({
  conversationId: 'conversationId',
  includeRawMessages: true,
});

getConversations()

This method retrieves all conversations. It returns a Promise that resolves to an array of Conversation objects or undefined.

Example usage:

const conversations = await piecesClient.getConversations();

promptConversation({ message, conversationId, regenerateConversationName? })

This method prompts a conversation with a message. It takes an object with the message, conversation ID, and an optional flag to regenerate the conversation name, which is false by default, as parameters. It returns a Promise that resolves to an object containing the text of the answer, the ID of the user query message, and the ID of the bot response message.

If there are previous messages in the conversation, they will be used as context for the new message.

If there is an error, it will return a Promise that resolves to an object containing only the text of the error message.

Example usage:

const answer = await piecesClient.promptConversation({
  message: 'Hello, world!',
  conversationId: 'conversationId'
});

updateConversationName({ conversationId })

This method generates a new name for a specific conversation based on the messages that have sent. It takes an object with the conversation ID as a parameter. It returns a Promise that resolves to a string (the updated conversation name) or undefined.

Example usage:

const updatedName = await piecesClient.updateConversationName('conversationId');

getUserProfilePicture()

This method retrieves the user's profile picture. It returns a Promise that resolves to a string (the URL of the profile picture) or undefined.

Example usage:

const profilePictureUrl = await piecesClient.getUserProfilePicture();

Contributing

Contributions are welcome! Please read our contributing guidelines before starting.

License

This project is licensed under the terms of the MIT license.