[docs]classBaseServices(BaseServiceServices):"""Appropriate services used by the Client"""TextService:type[_TextService]=_TextServiceRequestService:type[_RequestService]=_RequestServiceTuneService:type[_TuneService]=_TuneServiceModelService:type[_ModelService]=_ModelServiceFileService:type[_FileService]=_FileServicePromptService:type[_PromptService]=_PromptServiceSystemPromptService:type[_SystemPromptService]=_SystemPromptServiceUserService:type[_UserService]=_UserServiceTagService:type[_TagService]=_TagServiceFolderService:type[_FolderService]=_FolderServiceTaskService:type[_TaskService]=_TaskServiceDeploymentService:type[_DeploymentService]=_DeploymentService
[docs]classClient(BaseService[BaseConfig,BaseServices]):""" The `Client` class provides an interface for interacting with various services through an API client. It can be initialized with either an `api_client` or `credentials` along with optional configurations and services. Example:: from genai import Credentials, Client credentials = Credentials.from_env() client = Client(credentials=credentials) Attributes: text: An instance of the `TextService` class for text-related operations. request: An instance of the `RequestService` class for making request-related operations. tune: An instance of the `TuneService` class for tuning models. model: An instance of the `ModelService` class for managing models. file: An instance of the `FileService` class for managing files. prompt: An instance of the `PromptService` class for working with prompts. system_prompt: An instance of the `SystemPromptService` class for working with system prompts. user: An instance of the `UserService` class for managing user-related operations. tag: An instance of the `TagService` class for working with tags. folder: An instance of the `FolderService` class for working with folder. task: An instance of the `TaskService` class for working with tasks. """Config=BaseConfigServices=BaseServices@overloaddef__init__(self,*,api_client:ApiClient,config:Optional[ModelLike[BaseConfig]]=None,services:Optional[BaseServices]=None,)->None:...@overloaddef__init__(self,*,credentials:Credentials,config:Optional[ModelLike[BaseConfig]]=None,services:Optional[BaseServices]=None,)->None:...
[docs]def__init__(self,*,credentials:Optional[Credentials]=None,api_client:Optional[ApiClient]=None,config:Optional[ModelLike[BaseConfig]]=None,services:Optional[BaseServices]=None,)->None:""" Args: credentials: The credentials used to authenticate the API client. api_client: The API client used to make requests to the API. config: The configuration for the API client. services: The services object containing instances of various service classes. Raises: ValueError: Either 'api_client' or 'credentials' needs to be passed. Note: The `api_client` parameter must be provided either directly or through `credentials`. If no `services` parameter is provided, the client will use the default one. """config=to_model_instance(config,self.Config)if(notapi_clientandnotcredentials)or(api_clientandcredentials):raiseValueError("Either 'api_client' or 'credentials' needs to passed.")ifnotapi_client:assertcredentialsapi_client=ApiClient(credentials=credentials,config=config.api_client_config)assertapi_clientandconfigsuper().__init__(api_client=api_client,config=config)ifnotservices:services=self.Services()self.text=services.TextService(api_client=api_client)self.request=services.RequestService(api_client=api_client)self.tune=services.TuneService(api_client=api_client)self.model=services.ModelService(api_client=api_client)self.file=services.FileService(api_client=api_client)self.prompt=services.PromptService(api_client=api_client)self.system_prompt=services.SystemPromptService(api_client=api_client)self.user=services.UserService(api_client=api_client)self.tag=services.TagService(api_client=api_client)self.folder=services.FolderService(api_client=api_client)self.task=services.TaskService(api_client=api_client)self.deployment=services.DeploymentService(api_client=api_client)