Git Product home page Git Product logo

jiggybase's Introduction

JiggyBase

JiggyBase is a Python library for interacting with the JiggyBase service at https://jiggy.ai.

Use it to manage your JiggyBase organization and collections, including uploading documents into a collection.

Requirements

  • Python 3.6 or above

Installation

pip install jiggybase

Client Usage

To start using JiggyBase in your Python code, you first need to import it:

import jiggybase

After importing, you need to create a JiggyBase client object:

jb = jiggybase.JiggyBase()

Assuming you already created a collection 'my-collection', you can add files to the collection as follows:

collection = jb.collection('my-collection')

collection.upsert_file('/path/to/my/doc')

The document is now available in the collection and can be accessed by the collection's ChatGPT plugin, via chat.jiggy.ai, or via the associated chat API endpoint.

JiggyBase Client

These are the top level methods of th JiggyBase client, primarily used for getting the user's organizations or all collections across all organizations.

  • collection_names() - Returns a list of all of the Collection names that the user can access
  • collection(name: str) - Returns the Collection object matching the given name.
  • collections() - Returns a list of all Collection objects in all organizations the user is a member of.
  • orgs() - Returns a list of Org objects the user is a member of.
  • get_org(name_or_id: str) - Returns the Org object matching the given name or ID.
  • api_keys() - Returns a list of the user's ApiKey objects.
  • authenticated_user() - Returns the authenticated user's User object.

Organization

Organizations in JiggyBase are a mechanism for separating different customers within the JiggyBase service. Users can be a member of mutiple unrelated organizations. A new user who subscribes to a JiggyBase service tier has their own oganization that they control as administrator of the organization. Users can also be invited to an organization by existing members of the organization.

For an Org object (e.g., my_org = jb.get_org("<org_name>")), you have access to the following methods:

  • collections() - Returns a list of Collection objects within the organization.
  • collection(name: str) - Returns the Collection object matching the given name.
  • update([name: Optional[str] = None, description: Optional[str] = None]) - Updates the organization's name or description.

Collection

A collection is a group of documents that can be used to augment ChatGPT language models with your personalized information by using information from your collection to inform ChatGPT responses. A collection can be exposed as a ChatGPT Plugin, via the JiggyBase ChatCompletion API, or via chat.jiggy.ai. You have full control over who can access to your collection.

For a Collection object (e.g., my_collection = jb.collection("<collection_name>")), you have access to the following methods:

  • upsert_file(file_path: str[, mimetype: str = None]) - Uploads a file to the collection.
  • upsert(documents: List[Document]) - Adds a list of Document objects to the collection.
  • query(queries: Union[str, List[str], Query][, top_k : int = 10]) - Queries the collection and returns a QueryResponse object.
  • get_doc(id: str) - Retrieves a document by its ID.
  • get_chunks([start: int = 0, limit: int = 10, reverse: bool = True]) - Iterates through the chunks in a collection.
  • delete_docs([ids: Optional[List[str]] = None, document_metadata_filter: Optional[DocumentMetadataFilter] = None, delete_all: Optional[bool] = False]) - Deletes items in the collection by document IDs, metadata filter, or deletes all documents.
  • set_description(self, description: str) - Updates the description of the collection.
  • delete() - Deletes the collection permanently.
  • get_chat_config() - Retrieves the chat configuration for the collection.

Organization User Management

An organization supports multiple roles for members, including 'admin', 'member', and 'viewer'. A viwer role can access the data in the collection for chat purposes. A member can upload new documents to the collection.

  • members() - Returns a list of OrgMember objects within the organization.
  • add_member(email: str, role: OrgRole) - Adds a new member to the organization with the given email and role.
  • delete_member(email: str) - Deletes a member from the organization using the given email.

Organization Prompt Management

JiggyBase supports user-customized prompts for the JiggyBase ChatCompletion API. The following methods are provided to manage the customized prompts.

  • prompt_tasks([name=None, version=None]) - Returns a list of PromptTask objects, optionally filtering by name and version.
  • create_prompt_task(name: str, version: int, prompts: List[PromptMessage][, type: Optional[PromptTaskType] = None, description: Optional[str] = None]) - Creates a new PromptTask object with the specified parameters.
  • update_prompt_task(name: str, prompts: List[PromptMessage]) - Updates the specified prompt task's prompts.
  • get_prompt_task(prompt_task_id: int) - Retrieves a PromptTask object using the given prompt_task_id.
  • delete_prompt_task(prompt_task_id: int) - Deletes a PromptTask object using the given prompt_task_id.

jiggybase_upload

This utility is installed via pip and allows you to upload files or directories to your JiggyBase collection using command-line arguments. It's included in the jiggybase/examples directory.

Usage

jiggybase_upload [--org <organization>] [--collection <collection>] [--dir <directory>] [--file <file>]
  • --org: The name of your JiggyBase organization. Alternatively, set JIGGYBASE_ORG environment variable, or be a member of a single organization.
  • --collection: The name of your JiggyBase collection. Alternatively, set the JIGGYBASE_COLLECTION environment variable, or have a single collection in your organization.
  • --dir: The directory you want to upload.
  • --file: The file you want to upload.

If neither --file nor --dir options are provided, the script will automatically process other arguments as a file or directory.

jiggybase's People

Contributors

wskish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jiggybase's Issues

Collection not loading

One of my collections never loads. The loading continues but it never ends, and I can't see the list of documents. I tried deleting it, and it does not allow for it either. I think this happened after a file was too large.

cannot import create_prompt_task

Hi Team,

I encountered an issue while trying to import the 'create_prompt_task' function from the 'jiggybase' module as instructed in the readme.md. I got an 'ImportError: cannot import name 'create_prompt_task' from 'jiggybase''. This error occurred while running Python version 3.10.

I've included the code and error below for reference :

from jiggybase.models import PromptMessage
from jiggybase import create_prompt_task


prompts = [

PromptMessage(
    content="Does Apple undertake climate scenario planning? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    ),

    PromptMessage(
    content="Does Apple disclose an internal price of carbon? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    ),

    PromptMessage(
    content="Does Apple ensure consistency between its climate change policy and the positions taken by trade associations of which it is a member? Please provide direct evidence from the report in the collection called ‘Climate disclosures’. If there’s isn’t enough evidence, express the fact that the report has not enough information to answer conclusively.",
    role="user",
    position=1,
    extras=None,
    )
]

# Create the prompt task
create_prompt_task(
    name="Apple_Climate_Change",
    version=1,
    prompts=prompts,
    type=None,
    description="Apple 2022 ESG report"
)
#Here's the error : 
ImportError                               Traceback (most recent call last)

<ipython-input-19-ea878baf213f> in <cell line: 3>()
      1 # Import the necessary modules
      2 from jiggybase.models import PromptMessage
----> 3 from jiggybase import create_prompt_task
      4 
      5 # Define the prompts

ImportError: cannot import name 'create_prompt_task' from 'jiggybase' (/usr/local/lib/python3.10/dist-packages/jiggybase/__init__.py)`

Could you please assist me in resolving this issue? Thanks in advance for your help.

Best,
ELM

PydanticUserError('`const` is removed, use `Literal` instead', code='removed-kwargs')

pydantic v2 is unsupported


PydanticUserError Traceback (most recent call last)
in <cell line: 5>()
3
4 get_ipython().system('pip install jiggybase')
----> 5 import jiggybase
6 import jiggybase.collection
7 import jiggybase.models

6 frames
/usr/local/lib/python3.10/dist-packages/pydantic/fields.py in Field(default, default_factory, alias, alias_priority, validation_alias, serialization_alias, title, description, examples, exclude, include, discriminator, json_schema_extra, frozen, validate_default, repr, init_var, kw_only, pattern, strict, gt, ge, lt, le, multiple_of, allow_inf_nan, max_digits, decimal_places, min_length, max_length, **extra)
747 const = extra.pop('const', None) # type: ignore
748 if const is not None:
--> 749 raise PydanticUserError('const is removed, use Literal instead', code='removed-kwargs')
750
751 min_items = extra.pop('min_items', None) # type: ignore

PydanticUserError: const is removed, use Literal instead

For further information visit https://errors.pydantic.dev/2.1.1/u/removed-kwargs

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.