Use this file to discover all available pages before exploring further.
Prompts in Galileo allow you to create, store, and reuse LLM prompts across your experiments. They provide a structured way to manage your LLM interactions.
The Prompts page of the Galileo console shows you the existing prompts associated with your selected project. Click on All prompts to view all prompts in your organization. Click the Create Prompt button to create a new prompt.
from galileo import Message, MessageRolefrom galileo.prompts import create_prompt# Create a prompt with system and user messagesprompt = create_prompt( name="storyteller-prompt", template=[ Message(role=MessageRole.system, content="You are a great storyteller."), Message(role=MessageRole.user, content=""" Please write a short story about the following topic: {{topic}} """) ])
When you use datasets in Galileo, the attributes stored in the input in your dataset are made available to your prompt templates using mustache templating. This allows you to create dynamic prompts that adapt to the data in each row.Suppose you have the following dataset:
To reference fields from your dataset in your prompt, use double curly braces:
from galileo import Message, MessageRoleMessage(role=MessageRole.user, content=""" Plan a {{ days }}-day travel itinerary for a trip to {{ city }}. """)
{{ city }} will be replaced with the value of the city field inside the input dictionary.
{{ days }} will be replaced with the value of the days field inside the input dictionary.
To list all prompt templates in a project or organization:
from galileo.prompts import get_prompts# List all prompt templates in a projecttemplates = get_prompts()# Print template namesfor template in templates: print(f"Template: {template.name}")
Prompts can be used in experiments to evaluate different prompt templates:
from galileo.datasets import get_datasetfrom galileo.experiments import run_experimentfrom galileo.prompts import get_promptfrom galileo import GalileoMetrics# Get an existing datasetdataset = get_dataset( name="countries")# Get an existing promptprompt = get_prompt( name="geography-prompt")# Run an experiment with the dataset and promptresults = run_experiment( "geography-experiment", dataset=dataset, prompt_template=prompt, metrics=[GalileoMetrics.completeness], project="my-project",)