session#
phoenix.launch_app#
- launch_app(reference=None, corpus=None, trace=None, default_umap_parameters=None, host=None, port=None, run_in_thread=True, notebook_environment=None, use_temp_dir=True)#
Launches the phoenix application and returns a session to interact with.
- Parameters:
primary (Dataset, optional) – The primary dataset to analyze
reference (Dataset, optional) – The reference dataset to compare against. If not provided, drift analysis will not be available.
corpus (Dataset, optional) – The dataset containing corpus for LLM context retrieval.
trace (TraceDataset, optional) – The trace dataset containing the trace data.
host (str, optional) – The host on which the server runs. It can also be set using environment variable PHOENIX_HOST, otherwise it defaults to 127.0.0.1.
port (int, optional) – The port on which the server listens. When using traces this should not be used and should instead set the environment variable PHOENIX_PORT. Defaults to 6006.
run_in_thread (bool, optional, default=True) – Whether the server should run in a Thread or Process.
default_umap_parameters (Dict[str, Union[int, float]], optional, default=None) – User specified default UMAP parameters eg: {“n_neighbors”: 10, “n_samples”: 5, “min_dist”: 0.5}
notebook_environment (str, optional, default=None) – The environment the notebook is running in. This is either ‘local’, ‘colab’, or ‘sagemaker’. If not provided, phoenix will try to infer the environment. This is only needed if there is a failure to infer the environment.
use_temp_dir (bool, optional, default=True) – Whether to use a temporary directory to store the data. If set to False, the data will be stored in the directory specified by PHOENIX_WORKING_DIR environment variable via SQLite.
- Returns:
session – The session object that can be used to view the application
- Return type:
Examples
>>> import phoenix as px >>> # construct an inference set to analyze >>> inferences = px.Inferences(...) >>> session = px.launch_app(inferences)
phoenix.active_session#
- active_session()#
Returns the active session if one exists, otherwise returns None
phoenix.close_app#
- close_app()#
Closes the phoenix application. The application server is shut down and will no longer be accessible.
- Parameters:
delete_data (bool, optional) – If set to true, all stored phoenix data, including traces and evaluations. Default False.
phoenix.delete_all#
- delete_all()#
Deletes the entire contents of the working directory. This will delete, traces, evaluations, and any other data stored in the working directory.
phoenix.Session#
A session that maintains the state of the Phoenix app. Obtain the active session as follows:
session = px.active_session()
- class Session(database_url, primary_inferences, reference_inferences=None, corpus_inferences=None, trace_dataset=None, default_umap_parameters=None, host=None, port=None, notebook_env=None)#
Bases:
TraceDataExtractor
,ABC
Session that maintains a 1-1 shared state with the Phoenix App.
- abstract property active#
Whether session is active, i.e. whether server still serves
- property database_url#
- abstract end()#
Ends the session and closes the app service
- property exports#
Exported data sorted in descending order by modification date.
- Returns:
dataframes – List of dataframes
- Return type:
list
- get_evaluations(project_name=None)#
Get the evaluations for a project.
- Parameters:
project_name (str, optional) – The name of the project. If not provided, the project name set in the environment variable PHOENIX_PROJECT_NAME will be used. Otherwise, ‘default’ will be used.
- Returns:
evaluations – A list of evaluations for the specified project.
- Return type:
List[Evaluations]
- notebook_env#
The notebook environment that the session is running in.
- query_spans(*queries, start_time=None, end_time=None, limit=DEFAULT_SPAN_LIMIT, root_spans_only=None, project_name=None, stop_time=None, timeout=DEFAULT_TIMEOUT_IN_SECONDS)#
Queries the spans in the project based on the provided parameters.
- Parameters:
queries (*SpanQuery) – Variable-length argument list of SpanQuery objects representing the queries to be executed.
start_time (datetime, optional) – datetime representing the start time of the query.
end_time (datetime, optional) – datetime representing the end time of the query.
root_spans_only (boolean, optional) – whether to include only root spans in the results.
project_name (string, optional) – name of the project to query. Defaults to the project name set in the environment variable PHOENIX_PROJECT_NAME or ‘default’ if not set.
- Returns:
- DataFrame
DataFrame or list of DataFrames containing the query results.
- Return type:
results
- trace_dataset#
- property url#
Returns the url for the phoenix app
- view(height=1000)#
Returns an IFrame that can be displayed in a notebook to view the app.
- Parameters:
height (int, optional) – The height of the IFrame in pixels. Defaults to 1000.