Coder Social home page Coder Social logo

pieces-copilot-sdk's Introduction

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

askQuestion({ question })

This method allows the user to ask a question and receive a response. It takes a single argument, question, which is a string representing the query. The method returns a string containing the response to the question.

Example usage:

const response = await piecesClient.askQuestion({
  question: "What is Pieces for Developers?"
})

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!',
});

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'
});

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,
});

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');

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();

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.

pieces-copilot-sdk's People

Contributors

mason-at-pieces avatar masnwilliams avatar

Stargazers

Vishal Pawar avatar Marc G avatar Emmanuel Duchene avatar Arindam Majumder  avatar Shivay-at-pieces avatar Jim Bennett avatar

Watchers

 avatar

Forkers

vishalpawar1010

pieces-copilot-sdk's Issues

Unexpected Token on Import

Still figuring out this issue but it is known that when trying to import the package, it throws an error on next.js projects.

Add Method for Ingesting Files as Context

Overview

The idea of this is to allow users to "upload" any info into a conversation and then that information is used as context in the conversation.

This ingestion method should be separate from the current methods for reusability in other methods.

Tasks

  • Create an ingestion method that lets people upload files (can start with just code files and you can use the language list I have in /lib/const.ts to check the file extensions)
    • Parameters should take a conversationId and either a file or directory path
  • Should return one or an array of seeded assets which can then be used as relevance when creating a conversation or prompting a conversation.
  • Need to add an optional parameter in the createConversation method that is of the type SeededAsset | SeededAsset[].
  • If the parameter exists, ensure it gets added when creating a new conversation.
    • Also need to ensure that we are accounting for any context that is added mid-conversation, which should be appended to the conversation context.

Add Methods Around LLMs

Overview

Need to add methods that give the ability to easily download local llms, delete local llms, select a new llm, etc.

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.