Prem SDK
Installation
You can install the Prem Python or JavaScript SDKs directly from PyPI or npm.
Usage
Getting Started
To use the Prem SDK, you need to obtain an API key. You can then create a Prem
instance to make requests to the API.
Chat completion
The chat.completions
module is set to use default launchpad parameters unless otherwise specified. Optional parameters can also be defined as needed.
Here’s an example:
Chat completion with stream
You can also create a completion with a stream to receive the response in chunks by passing the stream
parameter as true
(default is false
).
Optional parameters
By default, the chat.completions
module uses the default launchpad parameters. You can also specify the following optional parameters:
session_id
: A unique identifier to maintain session context, useful for tracking conversations or data across multiple requests.repositories
: Options for Retrieval Augmented Generation (RAG). Will override launched model settings. (More about that on next section)model
: The model to use for completion. If omitted, the default launchpad model will be used.system_prompt
: The system prompt to use for completion. If omitted, the default launchpad system prompt will be used.max_tokens
: The maximum number of tokens to generate for completion. If omitted, the default launchpad max tokens will be used.stream
: If set, partial message deltas will be sent, like in ChatGPT.temperature
: The temperature to use for completion. If omitted, the default launchpad temperature will be used.
Example:
Repositories
Repositories act as storage for documents, organized to facilitate efficient information retrieval. Manipulating repository content is straightforward. Using PremSDK you can create new repositories and upload documents to existing repositories.
Repository creation
To create a repository, you can use the create
method provided by the repository
API. Here’s an example of how to create a repository:
This will return a response containing the repository ID, name, organization, and description.
Document creation
To add a document to a repository, you can use the repositories.create
method. Here’s an example of how to create and upload a document:
This will return a response containing the document ID, name, repository ID, and other details. Here is how the output looks like:
This will upload the documents and the changes will be reflected on the application.
Chat Completion with Retrieval Augmented Generation (RAG)
If you have created and linked repositories in the launchpad or created through the SDK and want to utilize it to enhance your chat completions by leveraging contextual data from specified repositories
.
Just to recall, A repository
is a collection of documents
, each containing information that can be utilized by the RAG system to provide enriched and context-aware responses.
If you’ve linked your repositories in the launchpad, relax—you’re all set for effortless chat completions! The system automatically uses those parameters by default, ensuring a seamless and easy experience.
However, if you wish to customize the process, you can specify the repositories
parameter to fit your exact needs. Just define:
ids
: Your selected repository IDs.similarity_threshold
: The least similarity score for content relevance.limit
: The number of content pieces to include.
For guidance on managing repositories, see the Repositories section.
Now we are ready to take a look into how we can do Function Calling using PremSDK in the next section.