Last updated
Was this helpful?
Last updated
Was this helpful?
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.
Ensure you have the RagaAI Python SDK installed:
Obtain your access_key
and secret_key
from the RagaAI admin, and have your base_url
for the API endpoint.
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.
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.
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.
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.
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.
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.
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.