# coding: utf-8 """ goose-server An AI agent The version of the OpenAPI document: 1.9.0 Contact: ai-oss-tools@block.xyz Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. """ # noqa: E501 from __future__ import annotations import pprint import re # noqa: F401 import json from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List from goose_api.models.config_key import ConfigKey from goose_api.models.model_info import ModelInfo from typing import Optional, Set from typing_extensions import Self class ProviderMetadata(BaseModel): """ Metadata about a provider's configuration requirements and capabilities """ # noqa: E501 config_keys: List[ConfigKey] = Field(description="Required configuration keys") default_model: StrictStr = Field(description="The default/recommended model for this provider") description: StrictStr = Field(description="Description of the provider's capabilities") display_name: StrictStr = Field(description="Display name for the provider in UIs") known_models: List[ModelInfo] = Field(description="A list of currently known models with their capabilities TODO: eventually query the apis directly") model_doc_link: StrictStr = Field(description="Link to the docs where models can be found") name: StrictStr = Field(description="The unique identifier for this provider") __properties: ClassVar[List[str]] = ["config_keys", "default_model", "description", "display_name", "known_models", "model_doc_link", "name"] model_config = ConfigDict( populate_by_name=True, validate_assignment=True, protected_namespaces=(), ) def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) def to_json(self) -> str: """Returns the JSON representation of the model using alias""" # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead return json.dumps(self.to_dict()) @classmethod def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ProviderMetadata from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's `self.model_dump(by_alias=True)`: * `None` is only added to the output dict for nullable fields that were set at model initialization. Other fields with value `None` are ignored. """ excluded_fields: Set[str] = set([ ]) _dict = self.model_dump( by_alias=True, exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each item in config_keys (list) _items = [] if self.config_keys: for _item_config_keys in self.config_keys: if _item_config_keys: _items.append(_item_config_keys.to_dict()) _dict['config_keys'] = _items # override the default output from pydantic by calling `to_dict()` of each item in known_models (list) _items = [] if self.known_models: for _item_known_models in self.known_models: if _item_known_models: _items.append(_item_known_models.to_dict()) _dict['known_models'] = _items return _dict @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: """Create an instance of ProviderMetadata from a dict""" if obj is None: return None if not isinstance(obj, dict): return cls.model_validate(obj) _obj = cls.model_validate({ "config_keys": [ConfigKey.from_dict(_item) for _item in obj["config_keys"]] if obj.get("config_keys") is not None else None, "default_model": obj.get("default_model"), "description": obj.get("description"), "display_name": obj.get("display_name"), "known_models": [ModelInfo.from_dict(_item) for _item in obj["known_models"]] if obj.get("known_models") is not None else None, "model_doc_link": obj.get("model_doc_link"), "name": obj.get("name") }) return _obj