SDK Functions
convert_otlp_traces_data
convert_otlp_traces_datadbnl.convert_otlp_traces_data(data: pd.Series[Any],
format: Literal['otlp_json',
'otlp_proto'] | None = None
) → pd.Series[Any]Converts a Series of OTLP TracesData to a Series of DBNL spans matching the DBNL semantic convention.
The resulting Series can be used as is to fill the spans column of a DataFrame to be logged with the dbnl.log function.
For a complete specification of the TracesData format, see the OTLP specification
Parameters:
data– Series of OTLP TracesDataformat– OTLP TracesData format (otlp_jsonorotlp_proto) orNoneto infer from data
Returns: Series of spans data
create_llm_model
create_llm_modeldbnl.create_llm_model(*,
name: str,
description: str | None = None,
type: Literal['completion',
'embedding'] | None = 'completion',
provider: str,
model: str,
params: dict[str,
Any] = {}
) → LLMModelCreate an LLM Model.
Parameters:
name– Model namedescription– Model description, defaults toNonetype– Model type (e.g. completion or embedding), defaults to “completion”provider– Model provider (e.g. openai, bedrock, etc.)model– Model (e.g. gpt-4, gpt-3.5-turbo, etc.)params– Model provider parameters (e.g. api key), defaults to{}
Returns: LLM Model
create_metric
create_metricCreate a new Metric
Parameters:
name– Name for the Metricexpression_template– Expression template string e.g.token_count({RUN}.question)description– Optional description of what computation the metric is performinggreater_is_better– Flag indicating whether greater values are semantically ‘better’ than lesser values
Raises:
DBNLNotLoggedInError– dbnl SDK is not logged in. Seelogin.DBNLInputValidationError– Input does not conform to expected format
Returns: Created Metric
create_project
create_projectCreate a new Project
Returns: Project
Examples:
delete_llm_model
delete_llm_modelDelete an LLM Model by id.
delete_metric
delete_metricDelete a Metric by ID
Parameters:
metric_id– ID of the metric to delete
Raises:
DBNLNotLoggedInError– dbnl SDK is not logged in. Seelogin.DBNLAPIValidationError– dbnl API failed to validate the request
Returns:
None
flatten_otlp_traces_data
flatten_otlp_traces_dataFlattens a Series of OTLP TracesData to a DataFrame matching the DBNL semantic convention.
The resulting DataFrame can be used as is to be logged with the dbnl.log function and will included all minimally required columns (timestamp, input, output) as well as the spans column for further flattening server-side.
For a complete specification of the TracesData format, see the OTLP specification
Parameters:
data– Series of OTLP TracesDataformat– OTLP TracesData format (otlp_jsonorotlp_proto) orNoneto infer from data
Returns: DataFrame with columns timestamp, input, output, spans
get_llm_model
get_llm_modelGet an LLM Model by id.
Parameters:
llm_model_id– Model id
Returns: LLM Model if found
get_llm_model_by_name
get_llm_model_by_nameGet an LLM Model by name
get_or_create_llm_model
get_or_create_llm_modelGet an LLM Model by name, or create it if it does not exist.
Parameters:
name– Model namedescription– Model description, defaults toNonetype– Model type (e.g. completion or embedding), defaults to “completion”provider– Model provider (e.g. openai, bedrock, etc.)model– Model (e.g. gpt-4, gpt-3.5-turbo, etc.)params– Model provider parameters (e.g. api key), defaults to{}
Returns: Model
get_or_create_project
get_or_create_projectGet the Project with the specified name or create a new one if it does not exist
Raises:
DBNLNotLoggedInError– dbnl SDK is not logged in. Seelogin.DBNLAPIValidationError– dbnl API failed to validate the request
Returns: Newly created or matching existing Project
Examples:
get_project
get_projectRetrieve a Project by id.
Examples:
get_project_by_name
get_project_by_nameRetrieve a Project by name.
Examples:
log
logLog data for a date range to a project.
Parameters:
project– The Project id to send the logs to.data– Pandas DataFrame with the data. See the DBNL Semantic Convention.data_start_time– Data start date.data_end_time– Data end time.wait_timeout– If set, the function will block for up towait_timeoutseconds until the data is done processing, defaults to 10 minutes.
Raises:
DBNLNotLoggedInError– dbnl SDK is not logged in. Seelogin.DBNLInputValidationError– Input does not conform to expected format
Examples:
login
loginSetup dbnl SDK to make authenticated requests. After login is run successfully, the dbnl client will be able to issue secure and authenticated requests against hosted endpoints of the dbnl service.
Parameters:
api_token– dbnl API token for authentication; token can be found at/tokenspage of the dbnl app. IfNoneis provided, the environment variableDBNL_API_TOKENwill be used by default.namespace_id– The namespace ID to use for the session.api_url– The base url of the Distributional API. By default, this is set tolocalhost:8080/api,for sandbox users. For other users, please contact your sys admin. IfNoneis provided, the environment variableDBNL_API_URLwill be used by default.app_url– An optional base url of the Distributional app. If this variable is not set, the app url is inferred from theDBNL_API_URLvariable. For on-prem users, please contact your sys admin if you cannot reach the Distributional UI.
update_llm_model
update_llm_modelUpdate an LLM Model by id.
Parameters:
llm_model_id– Model idname– Model namedescription– Model description, defaults toNonemodel– Model (e.g. gpt-4, gpt-3.5-turbo, etc.)params– Model provider parameters (e.g. api key), defaults to{}
Returns: Updated LLM Model
Was this helpful?

