AIServiceClientBase Class

Base class for all AI Services.

Has an ai_model_id and service_id, any other fields have to be defined by the subclasses.

The ai_model_id can refer to a specific model, like 'gpt-35-turbo' for OpenAI, or can just be a string that is used to identify the model in the service.

The service_id is used in Semantic Kernel to identify the service, if empty the ai_model_id is used.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Inheritance
AIServiceClientBase
AIServiceClientBase

Constructor

AIServiceClientBase(*, ai_model_id: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], service_id: str = '')

Keyword-Only Parameters

Name Description
ai_model_id
Required
service_id
Required

Methods

get_prompt_execution_settings_class

Get the request settings class.

get_prompt_execution_settings_from_settings

Get the request settings from a settings object.

instantiate_prompt_execution_settings

Create a request settings object.

All arguments are passed to the constructor of the request settings object.

model_post_init

Update the service_id if it is not set.

service_url

Get the URL of the service.

Override this in the subclass to return the proper URL. If the service does not have a URL, return None.

get_prompt_execution_settings_class

Get the request settings class.

get_prompt_execution_settings_class() -> type[PromptExecutionSettings]

get_prompt_execution_settings_from_settings

Get the request settings from a settings object.

get_prompt_execution_settings_from_settings(settings: PromptExecutionSettings) -> PromptExecutionSettings

Parameters

Name Description
settings
Required

instantiate_prompt_execution_settings

Create a request settings object.

All arguments are passed to the constructor of the request settings object.

instantiate_prompt_execution_settings(**kwargs) -> PromptExecutionSettings

model_post_init

Update the service_id if it is not set.

model_post_init(_AIServiceClientBase__context: object | None = None)

Parameters

Name Description
_AIServiceClientBase__context
Default value: None

service_url

Get the URL of the service.

Override this in the subclass to return the proper URL. If the service does not have a URL, return None.

service_url() -> str | None

Attributes

model_computed_fields

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True, 'validate_assignment': True}

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.fields from Pydantic V1.

model_fields: ClassVar[Dict[str, FieldInfo]] = {'ai_model_id': FieldInfo(annotation=str, required=True, metadata=[StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]), 'service_id': FieldInfo(annotation=str, required=False, default='')}

ai_model_id

ai_model_id: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]

service_id

service_id: str