summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/python/src/opencode_ai/models/agent_config.py
blob: 5c56c8b48dafd7d11bbcecae68da7f5d86ef5537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Literal, TypeVar, Union, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.agent_config_permission import AgentConfigPermission
    from ..models.agent_config_tools import AgentConfigTools


T = TypeVar("T", bound="AgentConfig")


@_attrs_define
class AgentConfig:
    """
    Attributes:
        model (Union[Unset, str]):
        temperature (Union[Unset, float]):
        top_p (Union[Unset, float]):
        prompt (Union[Unset, str]):
        tools (Union[Unset, AgentConfigTools]):
        disable (Union[Unset, bool]):
        description (Union[Unset, str]): Description of when to use the agent
        mode (Union[Literal['all'], Literal['primary'], Literal['subagent'], Unset]):
        permission (Union[Unset, AgentConfigPermission]):
    """

    model: Union[Unset, str] = UNSET
    temperature: Union[Unset, float] = UNSET
    top_p: Union[Unset, float] = UNSET
    prompt: Union[Unset, str] = UNSET
    tools: Union[Unset, "AgentConfigTools"] = UNSET
    disable: Union[Unset, bool] = UNSET
    description: Union[Unset, str] = UNSET
    mode: Union[Literal["all"], Literal["primary"], Literal["subagent"], Unset] = UNSET
    permission: Union[Unset, "AgentConfigPermission"] = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        model = self.model

        temperature = self.temperature

        top_p = self.top_p

        prompt = self.prompt

        tools: Union[Unset, dict[str, Any]] = UNSET
        if not isinstance(self.tools, Unset):
            tools = self.tools.to_dict()

        disable = self.disable

        description = self.description

        mode: Union[Literal["all"], Literal["primary"], Literal["subagent"], Unset]
        if isinstance(self.mode, Unset):
            mode = UNSET
        else:
            mode = self.mode

        permission: Union[Unset, dict[str, Any]] = UNSET
        if not isinstance(self.permission, Unset):
            permission = self.permission.to_dict()

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if model is not UNSET:
            field_dict["model"] = model
        if temperature is not UNSET:
            field_dict["temperature"] = temperature
        if top_p is not UNSET:
            field_dict["top_p"] = top_p
        if prompt is not UNSET:
            field_dict["prompt"] = prompt
        if tools is not UNSET:
            field_dict["tools"] = tools
        if disable is not UNSET:
            field_dict["disable"] = disable
        if description is not UNSET:
            field_dict["description"] = description
        if mode is not UNSET:
            field_dict["mode"] = mode
        if permission is not UNSET:
            field_dict["permission"] = permission

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.agent_config_permission import AgentConfigPermission
        from ..models.agent_config_tools import AgentConfigTools

        d = dict(src_dict)
        model = d.pop("model", UNSET)

        temperature = d.pop("temperature", UNSET)

        top_p = d.pop("top_p", UNSET)

        prompt = d.pop("prompt", UNSET)

        _tools = d.pop("tools", UNSET)
        tools: Union[Unset, AgentConfigTools]
        if isinstance(_tools, Unset):
            tools = UNSET
        else:
            tools = AgentConfigTools.from_dict(_tools)

        disable = d.pop("disable", UNSET)

        description = d.pop("description", UNSET)

        def _parse_mode(data: object) -> Union[Literal["all"], Literal["primary"], Literal["subagent"], Unset]:
            if isinstance(data, Unset):
                return data
            mode_type_0 = cast(Literal["subagent"], data)
            if mode_type_0 != "subagent":
                raise ValueError(f"mode_type_0 must match const 'subagent', got '{mode_type_0}'")
            return mode_type_0
            mode_type_1 = cast(Literal["primary"], data)
            if mode_type_1 != "primary":
                raise ValueError(f"mode_type_1 must match const 'primary', got '{mode_type_1}'")
            return mode_type_1
            mode_type_2 = cast(Literal["all"], data)
            if mode_type_2 != "all":
                raise ValueError(f"mode_type_2 must match const 'all', got '{mode_type_2}'")
            return mode_type_2

        mode = _parse_mode(d.pop("mode", UNSET))

        _permission = d.pop("permission", UNSET)
        permission: Union[Unset, AgentConfigPermission]
        if isinstance(_permission, Unset):
            permission = UNSET
        else:
            permission = AgentConfigPermission.from_dict(_permission)

        agent_config = cls(
            model=model,
            temperature=temperature,
            top_p=top_p,
            prompt=prompt,
            tools=tools,
            disable=disable,
            description=description,
            mode=mode,
            permission=permission,
        )

        agent_config.additional_properties = d
        return agent_config

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties