Module: gemini_settings
Expand source code
# Copyright (C) 2023-present The Project Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from dataclasses import dataclass
from cl.runtime.settings.settings import Settings
@dataclass(slots=True, kw_only=True)
class GeminiSettings(Settings):
"""Google Gemini settings."""
api_key: str
"""Gemini API key."""
def init(self) -> None:
"""Same as __init__ but can be used when field values are set both during and after construction."""
if not isinstance(self.api_key, str):
raise RuntimeError(f"{type(self).__name__} field 'api_key' must be a string.")
@classmethod
def get_prefix(cls) -> str:
return "gemini"
Classes
class GeminiSettings (*, api_key: str)
-
Google Gemini settings.
Expand source code
@dataclass(slots=True, kw_only=True) class GeminiSettings(Settings): """Google Gemini settings.""" api_key: str """Gemini API key.""" def init(self) -> None: """Same as __init__ but can be used when field values are set both during and after construction.""" if not isinstance(self.api_key, str): raise RuntimeError(f"{type(self).__name__} field 'api_key' must be a string.") @classmethod def get_prefix(cls) -> str: return "gemini"
Ancestors
- Settings
- abc.ABC
Class variables
var is_inside_test
-
Inherited from:
Settings
.is_inside_test
True if we are inside a test.
var process_timestamp
-
Inherited from:
Settings
.process_timestamp
Unique UUIDv7-based timestamp set during the Python process launch.
Static methods
def get_prefix() -> str
-
Inherited from:
Settings
.get_prefix
Dynaconf fields will be filtered by ‘prefix_’ before being passed to the settings class constructor …
def get_project_root() -> str
-
Inherited from:
Settings
.get_project_root
Returns absolute path of the directory containing .env file, and if not present the directory containing the first Dynaconf settings file found. Error …
def instance() -> Self
-
Inherited from:
Settings
.instance
Return singleton instance.
def normalize_path(field_name: str, field_value: str | None) -> str
-
Inherited from:
Settings
.normalize_path
Convert to absolute path if path relative to the location of .env or Dynaconf file is specified.
def normalize_paths(field_name: str, field_value: Iterable[str] | str | None) -> List[str]
-
Inherited from:
Settings
.normalize_paths
Convert to absolute path if path relative to the location of .env or Dynaconf file is specified and convert to list if single value is specified.
Fields
var api_key -> str
-
Gemini API key.
Methods
def init(self) -> None
-
Same as init but can be used when field values are set both during and after construction.