Follow this step-by-step guide to get started using Annotations in your AI projects.
First, follow the Getting Started with Galileo guide if you don’t already have a Galileo Project set up.
Then, use the following steps to add annotations to your Project.
Open your Galileo application in your code editor.
In this guide, we are using the finished demo application from the Getting Started guide.
Each code snippet in the following steps will be added to the end of the Getting Started demo code.
Create descriptive tags and metadata to be attached to your logs. Both Spans and Traces can have their own tags and metadata.
Define tags
as a list of relevant labels, and metadata
as a dictionary of label types and their values. The individual tag and metadata values must be strings.
answer
variable is set to the raw text output of the model so that it can be used later.Initialize logging by importing and calling the Galileo Logger.
The Project name and Log Stream name are used as inputs to define in which Galileo Project and log stream the logs will be created.
After running our application, the logs will appear in the chosen Project’s log stream in the Galileo Console.
Initialize a new Trace to start listening for data to log.
By using the tags
and metadata
inputs, our annotations are attached to the Trace.
Create a new Span containing the data created by running the LLM.
By using the tags
and metadata
inputs, our annotations are attached to the Span.
NOTE : In this guide, the tags and metadata used for the Span and the Trace are identical. But, they don’t have to be. You can use different tags and metadata for Spans and the Traces they’re attached to.
To close the new Trace and complete the logging session, we use logger.conclude()
with the LLM’s raw text output as the input.
Then, logger.flush()
pushes the logs to the selected Project’s Log Stream.
By adding each previous code snippet to your Galileo application, it is ready to run and create annotated logs.
Below is the final combined application code for the Getting Started demo application, with our annotated log functionality added to it.
Run your Galileo application.
If your application file is named app
(as in the Getting Started demo), you can run it by using the following command in your terminal.
In the Galileo Console, select your Project and Log Stream in the top-left corner.
For each time you run your application, you will see a new Trace entry in your Log Stream.
Each metadata key-value pair is displayed in its own column, which can be used for sorting and filtering.
Click on an entry in the list.
You will see the data logged to the Trace. This includes:
input=prompt
)logger.conclude(answer)
)With the Trace open, click the llm
button below Trace
in the data map on the left.
You will see the data logged to the Span. This includes:
input=[{"role": "system", "content": prompt}]
)output=response.choices[0].message.content
)Continue testing, customizing, and incorporating tags and metadata into your AI project development process and implementation.
Use Annotations to:
Follow this step-by-step guide to get started using Annotations in your AI projects.
First, follow the Getting Started with Galileo guide if you don’t already have a Galileo Project set up.
Then, use the following steps to add annotations to your Project.
Open your Galileo application in your code editor.
In this guide, we are using the finished demo application from the Getting Started guide.
Each code snippet in the following steps will be added to the end of the Getting Started demo code.
Create descriptive tags and metadata to be attached to your logs. Both Spans and Traces can have their own tags and metadata.
Define tags
as a list of relevant labels, and metadata
as a dictionary of label types and their values. The individual tag and metadata values must be strings.
answer
variable is set to the raw text output of the model so that it can be used later.Initialize logging by importing and calling the Galileo Logger.
The Project name and Log Stream name are used as inputs to define in which Galileo Project and log stream the logs will be created.
After running our application, the logs will appear in the chosen Project’s log stream in the Galileo Console.
Initialize a new Trace to start listening for data to log.
By using the tags
and metadata
inputs, our annotations are attached to the Trace.
Create a new Span containing the data created by running the LLM.
By using the tags
and metadata
inputs, our annotations are attached to the Span.
NOTE : In this guide, the tags and metadata used for the Span and the Trace are identical. But, they don’t have to be. You can use different tags and metadata for Spans and the Traces they’re attached to.
To close the new Trace and complete the logging session, we use logger.conclude()
with the LLM’s raw text output as the input.
Then, logger.flush()
pushes the logs to the selected Project’s Log Stream.
By adding each previous code snippet to your Galileo application, it is ready to run and create annotated logs.
Below is the final combined application code for the Getting Started demo application, with our annotated log functionality added to it.
Run your Galileo application.
If your application file is named app
(as in the Getting Started demo), you can run it by using the following command in your terminal.
In the Galileo Console, select your Project and Log Stream in the top-left corner.
For each time you run your application, you will see a new Trace entry in your Log Stream.
Each metadata key-value pair is displayed in its own column, which can be used for sorting and filtering.
Click on an entry in the list.
You will see the data logged to the Trace. This includes:
input=prompt
)logger.conclude(answer)
)With the Trace open, click the llm
button below Trace
in the data map on the left.
You will see the data logged to the Span. This includes:
input=[{"role": "system", "content": prompt}]
)output=response.choices[0].message.content
)Continue testing, customizing, and incorporating tags and metadata into your AI project development process and implementation.
Use Annotations to: