cohere-python
55 строк · 1.9 Кб
1# This file was auto-generated by Fern from our API Definition.
2
3import datetime as dt
4import typing
5
6from ..core.datetime_utils import serialize_datetime
7from .tool_parameter_definitions_value import ToolParameterDefinitionsValue
8
9try:
10import pydantic.v1 as pydantic # type: ignore
11except ImportError:
12import pydantic # type: ignore
13
14
15class Tool(pydantic.BaseModel):
16name: str = pydantic.Field()
17"""
18The name of the tool to be called. Valid names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
19"""
20
21description: str = pydantic.Field()
22"""
23The description of what the tool does, the model uses the description to choose when and how to call the function.
24"""
25
26parameter_definitions: typing.Optional[typing.Dict[str, ToolParameterDefinitionsValue]] = pydantic.Field(
27default=None
28)
29"""
30The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
31
32```
33{
34"my_param": {
35"description": <string>,
36"type": <string>, // any python data type, such as 'str', 'bool'
37"required": <boolean>
38}
39}
40```
41"""
42
43def json(self, **kwargs: typing.Any) -> str:
44kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
45return super().json(**kwargs_with_defaults)
46
47def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
48kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
49return super().dict(**kwargs_with_defaults)
50
51class Config:
52frozen = True
53smart_union = True
54extra = pydantic.Extra.allow
55json_encoders = {dt.datetime: serialize_datetime}
56