Types#

Prompts Types#

class AnthropicPrompt(messages, kwargs)#

Bases: _FormattedPrompt

Represents a formatted prompt for Anthropic message models.

messages#

A sequence of message parameters.

Type:

Sequence[MessageParam]

kwargs#

Keyword arguments specific to Anthropic message model invocation.

Type:

AnthropicMessageModelKwargs

kwargs#
messages#
class GoogleGenerativeaiPrompt(messages: 'Sequence[protos.Content]', kwargs: 'GoogleModelKwargs')#

Bases: _FormattedPrompt

kwargs#
messages#
class OpenAIPrompt(messages, kwargs)#

Bases: _FormattedPrompt

Represents a formatted prompt for OpenAI chat completion models.

messages#

A sequence of chat completion message parameters.

Type:

Sequence[ChatCompletionMessageParam]

kwargs#

Keyword arguments specific to OpenAI chat completion model invocation.

Type:

OpenAIChatCompletionModelKwargs

kwargs#
messages#
class PromptVersion(prompt, /, *, model_name, description=None, model_provider='OPENAI', template_format='MUSTACHE')#

Bases: object

Represents a version of a prompt for different model providers.

format(*, variables=MappingProxyType({}), formatter=None, sdk=None)#

Formats the prompt for a specific SDK.

Parameters:
  • variables (Mapping[str, str]) – A mapping of variable names to values to use in the prompt. Defaults to an empty mapping.

  • formatter (Optional[TemplateFormatter]) – A custom template formatter to use for the prompt. Defaults to None.

  • sdk (Optional[SDK]) – The SDK to format the prompt for. Defaults to None.

Returns:

The formatted prompt.

classmethod from_anthropic(obj, /, *, template_format='MUSTACHE', description=None, model_provider='ANTHROPIC')#

Creates a prompt version from an Anthropic message model.

Parameters:
  • obj (MessageCreateParamsBase) – The message create parameters.

  • template_format (Literal["F_STRING", "MUSTACHE", "NONE"]) – The format of the template to use for the prompt. Defaults to “MUSTACHE”.

  • description (Optional[str]) – A description of the prompt. Defaults to None.

  • model_provider (Literal["ANTHROPIC"]) – The provider of the model to use for the prompt. Defaults to “ANTHROPIC”.

Returns:

The prompt version.

Return type:

PromptVersion

classmethod from_aws(obj, /, *, template_format='MUSTACHE', description=None, model_provider='AWS')#
classmethod from_google_generativeai(obj, /, *, template_format='MUSTACHE', description=None, model_provider='GOOGLE')#
classmethod from_openai(obj, /, *, template_format='MUSTACHE', description=None, model_provider='OPENAI')#

Creates a prompt version from an OpenAI chat completion model.

Parameters:
  • obj (CompletionCreateParamsBase) – The completion create parameters.

  • template_format (Literal["F_STRING", "MUSTACHE", "NONE"]) – The format of the template to use for the prompt. Defaults to “MUSTACHE”.

  • description (Optional[str]) – A description of the prompt. Defaults to None.

  • model_provider (Literal["OPENAI", "AZURE_OPENAI", "DEEPSEEK", "XAI", "OLLAMA"]) – The provider of the model to use for the prompt. Defaults to “OPENAI”.

Returns:

The prompt version.

Return type:

PromptVersion

property id#

Prompt Version ID if stored in the Phoenix backend

Spans Types#

class Concatenation(key='', kwargs=<factory>, separator='\n\n')#

Bases: object

Represents a concatenation operation in a span query.

key = ''#
kwargs#
separator = '\n\n'#
to_dict()#
class Explosion(key='', kwargs=<factory>, primary_index_key='context.span_id')#

Bases: object

Represents an explosion operation in a span query.

key = ''#
kwargs#
primary_index_key = 'context.span_id'#
to_dict()#
class Projection(key='')#

Bases: object

Represents a projection in a span query.

key = ''#
to_dict()#

Convert to dictionary format.

class SpanFilter(condition='', valid_eval_names=None)#

Bases: object

Represents a filter condition in a span query.

condition = ''#
to_dict()#
valid_eval_names = None#
class SpanQuery(_select=None, _filter=None, _explode=None, _concat=None, _rename=None, _index=None, _index_has_been_set=False)#

Bases: object

Represents a query for spans using the query DSL.

concat(key, **kwargs)#

Concatenate a field from the spans.

explode(key, **kwargs)#
rename(**kwargs)#

Rename fields in the result.

select(*fields)#
to_dict()#
where(condition)#

Filter spans based on a condition.

with_index(key)#