-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathagent_response.py
More file actions
266 lines (213 loc) · 9.61 KB
/
agent_response.py
File metadata and controls
266 lines (213 loc) · 9.61 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# This file was auto-generated by Fern from our API Definition.
from __future__ import annotations
import datetime as dt
import typing
import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .agent_response_reasoning_effort import AgentResponseReasoningEffort
from .agent_response_stop import AgentResponseStop
from .agent_response_template import AgentResponseTemplate
from .environment_response import EnvironmentResponse
from .evaluator_aggregate import EvaluatorAggregate
from .input_response import InputResponse
from .model_endpoints import ModelEndpoints
from .model_providers import ModelProviders
from .response_format import ResponseFormat
from .template_language import TemplateLanguage
from .user_response import UserResponse
from .version_status import VersionStatus
class AgentResponse(UncheckedBaseModel):
"""
Base type that all File Responses should inherit from.
Attributes defined here are common to all File Responses and should be overridden
in the inheriting classes with documentation and appropriate Field definitions.
"""
path: str = pydantic.Field()
"""
Path of the Agent, including the name, which is used as a unique identifier.
"""
id: str = pydantic.Field()
"""
Unique identifier for the Agent.
"""
directory_id: typing.Optional[str] = pydantic.Field(default=None)
"""
ID of the directory that the file is in on Humanloop.
"""
model: str = pydantic.Field()
"""
The model instance used, e.g. `gpt-4`. See [supported models](https://humanloop.com/docs/reference/supported-models)
"""
endpoint: typing.Optional[ModelEndpoints] = pydantic.Field(default=None)
"""
The provider model endpoint used.
"""
template: typing.Optional[AgentResponseTemplate] = pydantic.Field(default=None)
"""
The template contains the main structure and instructions for the model, including input variables for dynamic values.
For chat models, provide the template as a ChatTemplate (a list of messages), e.g. a system message, followed by a user message with an input variable.
For completion models, provide a prompt template as a string.
Input variables should be specified with double curly bracket syntax: `{{input_name}}`.
"""
template_language: typing.Optional[TemplateLanguage] = pydantic.Field(default=None)
"""
The template language to use for rendering the template.
"""
provider: typing.Optional[ModelProviders] = pydantic.Field(default=None)
"""
The company providing the underlying model service.
"""
max_tokens: typing.Optional[int] = pydantic.Field(default=None)
"""
The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt
"""
temperature: typing.Optional[float] = pydantic.Field(default=None)
"""
What sampling temperature to use when making a generation. Higher values means the model will be more creative.
"""
top_p: typing.Optional[float] = pydantic.Field(default=None)
"""
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
"""
stop: typing.Optional[AgentResponseStop] = pydantic.Field(default=None)
"""
The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.
"""
presence_penalty: typing.Optional[float] = pydantic.Field(default=None)
"""
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.
"""
frequency_penalty: typing.Optional[float] = pydantic.Field(default=None)
"""
Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.
"""
other: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Other parameter values to be passed to the provider call.
"""
seed: typing.Optional[int] = pydantic.Field(default=None)
"""
If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
"""
response_format: typing.Optional[ResponseFormat] = pydantic.Field(default=None)
"""
The format of the response. Only `{"type": "json_object"}` is currently supported for chat.
"""
reasoning_effort: typing.Optional[AgentResponseReasoningEffort] = pydantic.Field(default=None)
"""
Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.
"""
tools: typing.List["AgentResponseToolsItem"] = pydantic.Field()
"""
List of tools that the Agent can call. These can be linked files or inline tools.
"""
attributes: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Additional fields to describe the Prompt. Helpful to separate Prompt versions from each other with details on how they were created or used.
"""
max_iterations: typing.Optional[int] = pydantic.Field(default=None)
"""
The maximum number of iterations the Agent can run. This is used to limit the number of times the Agent model is called.
"""
version_name: typing.Optional[str] = pydantic.Field(default=None)
"""
Unique name for the Agent version. Version names must be unique for a given Agent.
"""
version_description: typing.Optional[str] = pydantic.Field(default=None)
"""
Description of the version, e.g., the changes made in this version.
"""
description: typing.Optional[str] = pydantic.Field(default=None)
"""
Description of the Agent.
"""
tags: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
"""
List of tags associated with the file.
"""
readme: typing.Optional[str] = pydantic.Field(default=None)
"""
Long description of the file.
"""
name: str = pydantic.Field()
"""
Name of the Agent.
"""
schema_: typing_extensions.Annotated[
typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]], FieldMetadata(alias="schema")
] = pydantic.Field(default=None)
"""
The JSON schema for the Prompt.
"""
version_id: str = pydantic.Field()
"""
Unique identifier for the specific Agent Version. If no query params provided, the default deployed Agent Version is returned.
"""
type: typing.Optional[typing.Literal["agent"]] = None
environments: typing.Optional[typing.List[EnvironmentResponse]] = pydantic.Field(default=None)
"""
The list of environments the Agent Version is deployed to.
"""
created_at: dt.datetime
updated_at: dt.datetime
created_by: typing.Optional[UserResponse] = pydantic.Field(default=None)
"""
The user who created the Agent.
"""
committed_by: typing.Optional[UserResponse] = pydantic.Field(default=None)
"""
The user who committed the Agent Version.
"""
committed_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
"""
The date and time the Agent Version was committed.
"""
status: VersionStatus = pydantic.Field()
"""
The status of the Agent Version.
"""
last_used_at: dt.datetime
version_logs_count: int = pydantic.Field()
"""
The number of logs that have been generated for this Agent Version
"""
total_logs_count: int = pydantic.Field()
"""
The number of logs that have been generated across all Agent Versions
"""
inputs: typing.List[InputResponse] = pydantic.Field()
"""
Inputs associated to the Agent. Inputs correspond to any of the variables used within the Agent template.
"""
evaluators: typing.Optional[typing.List["MonitoringEvaluatorResponse"]] = pydantic.Field(default=None)
"""
Evaluators that have been attached to this Agent that are used for monitoring logs.
"""
evaluator_aggregates: typing.Optional[typing.List[EvaluatorAggregate]] = pydantic.Field(default=None)
"""
Aggregation of Evaluator results for the Agent Version.
"""
raw_file_content: typing.Optional[str] = pydantic.Field(default=None)
"""
The raw content of the Agent. Corresponds to the .agent file.
"""
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:
class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow
from .agent_linked_file_response import AgentLinkedFileResponse # noqa: E402, F401, I001
from .evaluator_response import EvaluatorResponse # noqa: E402, F401, I001
from .flow_response import FlowResponse # noqa: E402, F401, I001
from .monitoring_evaluator_response import MonitoringEvaluatorResponse # noqa: E402, F401, I001
from .prompt_response import PromptResponse # noqa: E402, F401, I001
from .tool_response import ToolResponse # noqa: E402, F401, I001
from .version_deployment_response import VersionDeploymentResponse # noqa: E402, F401, I001
from .version_id_response import VersionIdResponse # noqa: E402, F401, I001
from .agent_response_tools_item import AgentResponseToolsItem # noqa: E402, F401, I001
update_forward_refs(AgentResponse)