Overview
This guide shows you how to log spans to Galileo using the@log decorator in Python, or the log wrapper in TypeScript to log function calls using the async OpenAI SDK as LLM spans.
In this guide you will:
Before you start
To complete this how-to, you will need:- An OpenAI API key
- A Galileo project configured
- Your Galileo API key
Install dependencies
To use Galileo, you need to install some package dependencies, and configure environment variables.Install Required Dependencies
Create a .env file, and add the following values
Create the basic app to call OpenAI
Create a file for your application called app.py or app.ts.
Add the following code to call OpenAI to ask a question
package.json file:Run the app to ensure everything is working
Add simple logging with the Galileo log decorator or wrapper
Galileo has a@log decorator in Python, and a log wrapper in TypeScript that logs function calls as spans. If these decorated or wrapped calls are called whilst there is an active trace, they are added to that trace. If there is no active trace, a new one is created for this span.
In this guide, you will be adding the decorator or wrapper to log the function that calls OpenAI.
Import the log decorator
Decorate or wrap the function
Run the app
prompt, the output as the returned response. The duration will also be logged.View the logged trace

