-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathagent_log_response.py
More file actions
219 lines (175 loc) · 7.53 KB
/
agent_log_response.py
File metadata and controls
219 lines (175 loc) · 7.53 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
# This file was auto-generated by Fern from our API Definition.
from __future__ import annotations
import datetime as dt
import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.unchecked_base_model import UncheckedBaseModel
from .agent_log_response_tool_choice import AgentLogResponseToolChoice
from .chat_message import ChatMessage
class AgentLogResponse(UncheckedBaseModel):
"""
General request for creating a Log
"""
output_message: typing.Optional[ChatMessage] = pydantic.Field(default=None)
"""
The message returned by the provider.
"""
prompt_tokens: typing.Optional[int] = pydantic.Field(default=None)
"""
Number of tokens in the prompt used to generate the output.
"""
reasoning_tokens: typing.Optional[int] = pydantic.Field(default=None)
"""
Number of reasoning tokens used to generate the output.
"""
output_tokens: typing.Optional[int] = pydantic.Field(default=None)
"""
Number of tokens in the output generated by the model.
"""
prompt_cost: typing.Optional[float] = pydantic.Field(default=None)
"""
Cost in dollars associated to the tokens in the prompt.
"""
output_cost: typing.Optional[float] = pydantic.Field(default=None)
"""
Cost in dollars associated to the tokens in the output.
"""
finish_reason: typing.Optional[str] = pydantic.Field(default=None)
"""
Reason the generation finished.
"""
messages: typing.Optional[typing.List[ChatMessage]] = pydantic.Field(default=None)
"""
The messages passed to the to provider chat endpoint.
"""
tool_choice: typing.Optional[AgentLogResponseToolChoice] = pydantic.Field(default=None)
"""
Controls how the model uses tools. The following options are supported:
- `'none'` means the model will not call any tool and instead generates a message; this is the default when no tools are provided as part of the Prompt.
- `'auto'` means the model can decide to call one or more of the provided tools; this is the default when tools are provided as part of the Prompt.
- `'required'` means the model must call one or more of the provided tools.
- `{'type': 'function', 'function': {name': <TOOL_NAME>}}` forces the model to use the named function.
"""
agent: "AgentResponse" = pydantic.Field()
"""
Agent that generated the Log.
"""
start_time: typing.Optional[dt.datetime] = pydantic.Field(default=None)
"""
When the logged event started.
"""
end_time: typing.Optional[dt.datetime] = pydantic.Field(default=None)
"""
When the logged event ended.
"""
output: typing.Optional[str] = pydantic.Field(default=None)
"""
Generated output from your model for the provided inputs. Can be `None` if logging an error, or if creating a parent Log with the intention to populate it later.
"""
created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
"""
User defined timestamp for when the log was created.
"""
error: typing.Optional[str] = pydantic.Field(default=None)
"""
Error message if the log is an error.
"""
provider_latency: typing.Optional[float] = pydantic.Field(default=None)
"""
Duration of the logged event in seconds.
"""
stdout: typing.Optional[str] = pydantic.Field(default=None)
"""
Captured log and debug statements.
"""
provider_request: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Raw request sent to provider.
"""
provider_response: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Raw response received the provider.
"""
inputs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
The inputs passed to the prompt template.
"""
source: typing.Optional[str] = pydantic.Field(default=None)
"""
Identifies where the model was called from.
"""
metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
"""
Any additional metadata to record.
"""
source_datapoint_id: typing.Optional[str] = pydantic.Field(default=None)
"""
Unique identifier for the Datapoint that this Log is derived from. This can be used by Humanloop to associate Logs to Evaluations. If provided, Humanloop will automatically associate this Log to Evaluations that require a Log for this Datapoint-Version pair.
"""
trace_parent_id: typing.Optional[str] = pydantic.Field(default=None)
"""
The ID of the parent Log to nest this Log under in a Trace.
"""
batches: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
"""
Array of Batch IDs that this Log is part of. Batches are used to group Logs together for offline Evaluations
"""
user: typing.Optional[str] = pydantic.Field(default=None)
"""
End-user ID related to the Log.
"""
environment: typing.Optional[str] = pydantic.Field(default=None)
"""
The name of the Environment the Log is associated to.
"""
save: typing.Optional[bool] = pydantic.Field(default=None)
"""
Whether the request/response payloads will be stored on Humanloop.
"""
log_id: typing.Optional[str] = pydantic.Field(default=None)
"""
This will identify a Log. If you don't provide a Log ID, Humanloop will generate one for you.
"""
id: str = pydantic.Field()
"""
Unique identifier for the Log.
"""
evaluator_logs: typing.List["EvaluatorLogResponse"] = pydantic.Field()
"""
List of Evaluator Logs associated with the Log. These contain Evaluator judgments on the Log.
"""
trace_flow_id: typing.Optional[str] = pydantic.Field(default=None)
"""
Identifier for the Flow that the Trace belongs to.
"""
trace_id: typing.Optional[str] = pydantic.Field(default=None)
"""
Identifier for the Trace that the Log belongs to.
"""
trace_children: typing.Optional[typing.List["LogResponse"]] = pydantic.Field(default=None)
"""
Logs nested under this Log in the Trace.
"""
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 .agent_response import AgentResponse # 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 .evaluator_log_response import EvaluatorLogResponse # noqa: E402, F401, I001
from .flow_log_response import FlowLogResponse # noqa: E402, F401, I001
from .prompt_log_response import PromptLogResponse # noqa: E402, F401, I001
from .tool_log_response import ToolLogResponse # noqa: E402, F401, I001
from .log_response import LogResponse # noqa: E402, F401, I001
update_forward_refs(AgentLogResponse)