Using Prompt Slugs with Python SDK
Prompt slugs created on the RagaAI Playground can be used with the Python SDK. It covers the initialisation of the SDK, managing prompts, retrieving prompt versions, and compiling prompts using the SDK.
1. Prerequisites
Ensure you have the RagaAI Python SDK installed:
Obtain your
access_key
andsecret_key
from the RagaAI admin, and have yourbase_url
for the API endpoint.
2. Initialise RagaAICatalyst and PromptManager
First, you need to initialise the RagaAICatalyst
instance and the PromptManager
for your specific project.
Replace the placeholders your_access_key
, your_secret_key
, your-api-base-url.com
, and your-project-name
with your actual credentials and project details.
3. List Available Prompts
You can list all the prompts available in your project using the list_prompts
method.
This will output a list of prompt slugs that have been created in the project.
4. List Prompt Versions
Each prompt can have multiple versions. You can list the versions of a specific prompt using its slug.
Replace your_prompt_name
with the name of the prompt you want to query.
5. Get a Prompt Object
You can retrieve a prompt object by its name or by specifying both its name and version. This will allow you to access its details and use it further.
Replace your_prompt_name
and your_version
with the appropriate prompt name and version.
6. Get Prompt Variables
You can get a list of variables required by the prompt to generate a response. These variables need to be provided when compiling the prompt.
This will output a dictionary of variables required by the prompt.
7. Compile Prompt
Once you have the prompt object and its required variables, you can compile the prompt by providing the necessary values for the variables.
Replace the query
, context
, and llm_response
with appropriate values based on the prompt variables.
8. Get Prompt Parameters
You can also retrieve additional parameters associated with the prompt, which provide further configuration options.
This process enables you to effectively use prompts created in the RagaAI Playground through the Python SDK.
Last updated