Skip to content

Commit 63e0c67

Browse files
authored
Update gen_ai.* and ai.* attributes (#4665)
All `ai.*` attributes are deprecated. I also added some missing `gen_ai.*` attributes from [Sentry Conventions](https://getsentry.github.io/sentry-conventions/generated/attributes/gen_ai.html).
1 parent 0d569d2 commit 63e0c67

File tree

1 file changed

+112
-3
lines changed

1 file changed

+112
-3
lines changed

sentry_sdk/consts.py

Lines changed: 112 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,172 +113,257 @@ class SPANDATA:
113113

114114
AI_CITATIONS = "ai.citations"
115115
"""
116+
.. deprecated::
117+
This attribute is deprecated. Use GEN_AI_* attributes instead.
118+
116119
References or sources cited by the AI model in its response.
117120
Example: ["Smith et al. 2020", "Jones 2019"]
118121
"""
119122

120123
AI_DOCUMENTS = "ai.documents"
121124
"""
125+
.. deprecated::
126+
This attribute is deprecated. Use GEN_AI_* attributes instead.
127+
122128
Documents or content chunks used as context for the AI model.
123129
Example: ["doc1.txt", "doc2.pdf"]
124130
"""
125131

126132
AI_FINISH_REASON = "ai.finish_reason"
127133
"""
134+
.. deprecated::
135+
This attribute is deprecated. Use GEN_AI_RESPONSE_FINISH_REASONS instead.
136+
128137
The reason why the model stopped generating.
129138
Example: "length"
130139
"""
131140

132141
AI_FREQUENCY_PENALTY = "ai.frequency_penalty"
133142
"""
143+
.. deprecated::
144+
This attribute is deprecated. Use GEN_AI_REQUEST_FREQUENCY_PENALTY instead.
145+
134146
Used to reduce repetitiveness of generated tokens.
135147
Example: 0.5
136148
"""
137149

138150
AI_FUNCTION_CALL = "ai.function_call"
139151
"""
152+
.. deprecated::
153+
This attribute is deprecated. Use GEN_AI_RESPONSE_TOOL_CALLS instead.
154+
140155
For an AI model call, the function that was called. This is deprecated for OpenAI, and replaced by tool_calls
141156
"""
142157

143158
AI_GENERATION_ID = "ai.generation_id"
144159
"""
160+
.. deprecated::
161+
This attribute is deprecated. Use GEN_AI_RESPONSE_ID instead.
162+
145163
Unique identifier for the completion.
146164
Example: "gen_123abc"
147165
"""
148166

149167
AI_INPUT_MESSAGES = "ai.input_messages"
150168
"""
169+
.. deprecated::
170+
This attribute is deprecated. Use GEN_AI_REQUEST_MESSAGES instead.
171+
151172
The input messages to an LLM call.
152173
Example: [{"role": "user", "message": "hello"}]
153174
"""
154175

155176
AI_LOGIT_BIAS = "ai.logit_bias"
156177
"""
178+
.. deprecated::
179+
This attribute is deprecated. Use GEN_AI_* attributes instead.
180+
157181
For an AI model call, the logit bias
158182
"""
159183

160184
AI_METADATA = "ai.metadata"
161185
"""
186+
.. deprecated::
187+
This attribute is deprecated. Use GEN_AI_* attributes instead.
188+
162189
Extra metadata passed to an AI pipeline step.
163190
Example: {"executed_function": "add_integers"}
164191
"""
165192

166193
AI_MODEL_ID = "ai.model_id"
167194
"""
168-
The unique descriptor of the model being execugted
195+
.. deprecated::
196+
This attribute is deprecated. Use GEN_AI_REQUEST_MODEL or GEN_AI_RESPONSE_MODEL instead.
197+
198+
The unique descriptor of the model being executed.
169199
Example: gpt-4
170200
"""
171201

172202
AI_PIPELINE_NAME = "ai.pipeline.name"
173203
"""
204+
.. deprecated::
205+
This attribute is deprecated. Use GEN_AI_PIPELINE_NAME instead.
206+
174207
Name of the AI pipeline or chain being executed.
175-
DEPRECATED: Use GEN_AI_PIPELINE_NAME instead.
176208
Example: "qa-pipeline"
177209
"""
178210

179211
AI_PREAMBLE = "ai.preamble"
180212
"""
213+
.. deprecated::
214+
This attribute is deprecated. Use GEN_AI_* attributes instead.
215+
181216
For an AI model call, the preamble parameter.
182217
Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style.
183218
Example: "You are now a clown."
184219
"""
185220

186221
AI_PRESENCE_PENALTY = "ai.presence_penalty"
187222
"""
223+
.. deprecated::
224+
This attribute is deprecated. Use GEN_AI_REQUEST_PRESENCE_PENALTY instead.
225+
188226
Used to reduce repetitiveness of generated tokens.
189227
Example: 0.5
190228
"""
191229

192230
AI_RAW_PROMPTING = "ai.raw_prompting"
193231
"""
232+
.. deprecated::
233+
This attribute is deprecated. Use GEN_AI_* attributes instead.
234+
194235
Minimize pre-processing done to the prompt sent to the LLM.
195236
Example: true
196237
"""
197238

198239
AI_RESPONSE_FORMAT = "ai.response_format"
199240
"""
241+
.. deprecated::
242+
This attribute is deprecated. Use GEN_AI_* attributes instead.
243+
200244
For an AI model call, the format of the response
201245
"""
202246

203247
AI_RESPONSES = "ai.responses"
204248
"""
249+
.. deprecated::
250+
This attribute is deprecated. Use GEN_AI_RESPONSE_TEXT instead.
251+
205252
The responses to an AI model call. Always as a list.
206253
Example: ["hello", "world"]
207254
"""
208255

209256
AI_SEARCH_QUERIES = "ai.search_queries"
210257
"""
258+
.. deprecated::
259+
This attribute is deprecated. Use GEN_AI_* attributes instead.
260+
211261
Queries used to search for relevant context or documents.
212262
Example: ["climate change effects", "renewable energy"]
213263
"""
214264

215265
AI_SEARCH_REQUIRED = "ai.is_search_required"
216266
"""
267+
.. deprecated::
268+
This attribute is deprecated. Use GEN_AI_* attributes instead.
269+
217270
Boolean indicating if the model needs to perform a search.
218271
Example: true
219272
"""
220273

221274
AI_SEARCH_RESULTS = "ai.search_results"
222275
"""
276+
.. deprecated::
277+
This attribute is deprecated. Use GEN_AI_* attributes instead.
278+
223279
Results returned from search queries for context.
224280
Example: ["Result 1", "Result 2"]
225281
"""
226282

227283
AI_SEED = "ai.seed"
228284
"""
285+
.. deprecated::
286+
This attribute is deprecated. Use GEN_AI_REQUEST_SEED instead.
287+
229288
The seed, ideally models given the same seed and same other parameters will produce the exact same output.
230289
Example: 123.45
231290
"""
232291

233292
AI_STREAMING = "ai.streaming"
234293
"""
294+
.. deprecated::
295+
This attribute is deprecated. Use GEN_AI_RESPONSE_STREAMING instead.
296+
235297
Whether or not the AI model call's response was streamed back asynchronously
236-
DEPRECATED: Use GEN_AI_RESPONSE_STREAMING instead.
237298
Example: true
238299
"""
239300

240301
AI_TAGS = "ai.tags"
241302
"""
303+
.. deprecated::
304+
This attribute is deprecated. Use GEN_AI_* attributes instead.
305+
242306
Tags that describe an AI pipeline step.
243307
Example: {"executed_function": "add_integers"}
244308
"""
245309

246310
AI_TEMPERATURE = "ai.temperature"
247311
"""
312+
.. deprecated::
313+
This attribute is deprecated. Use GEN_AI_REQUEST_TEMPERATURE instead.
314+
248315
For an AI model call, the temperature parameter. Temperature essentially means how random the output will be.
249316
Example: 0.5
250317
"""
251318

252319
AI_TEXTS = "ai.texts"
253320
"""
321+
.. deprecated::
322+
This attribute is deprecated. Use GEN_AI_* attributes instead.
323+
254324
Raw text inputs provided to the model.
255325
Example: ["What is machine learning?"]
256326
"""
257327

258328
AI_TOP_K = "ai.top_k"
259329
"""
330+
.. deprecated::
331+
This attribute is deprecated. Use GEN_AI_REQUEST_TOP_K instead.
332+
260333
For an AI model call, the top_k parameter. Top_k essentially controls how random the output will be.
261334
Example: 35
262335
"""
263336

264337
AI_TOP_P = "ai.top_p"
265338
"""
339+
.. deprecated::
340+
This attribute is deprecated. Use GEN_AI_REQUEST_TOP_P instead.
341+
266342
For an AI model call, the top_p parameter. Top_p essentially controls how random the output will be.
267343
Example: 0.5
268344
"""
269345

270346
AI_TOOL_CALLS = "ai.tool_calls"
271347
"""
348+
.. deprecated::
349+
This attribute is deprecated. Use GEN_AI_RESPONSE_TOOL_CALLS instead.
350+
272351
For an AI model call, the function that was called. This is deprecated for OpenAI, and replaced by tool_calls
273352
"""
274353

275354
AI_TOOLS = "ai.tools"
276355
"""
356+
.. deprecated::
357+
This attribute is deprecated. Use GEN_AI_REQUEST_AVAILABLE_TOOLS instead.
358+
277359
For an AI model call, the functions that are available
278360
"""
279361

280362
AI_WARNINGS = "ai.warnings"
281363
"""
364+
.. deprecated::
365+
This attribute is deprecated. Use GEN_AI_* attributes instead.
366+
282367
Warning messages generated during model execution.
283368
Example: ["Token limit exceeded"]
284369
"""
@@ -383,6 +468,18 @@ class SPANDATA:
383468
Example: "qa-pipeline"
384469
"""
385470

471+
GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons"
472+
"""
473+
The reason why the model stopped generating.
474+
Example: "COMPLETE"
475+
"""
476+
477+
GEN_AI_RESPONSE_ID = "gen_ai.response.id"
478+
"""
479+
Unique identifier for the completion.
480+
Example: "gen_123abc"
481+
"""
482+
386483
GEN_AI_RESPONSE_MODEL = "gen_ai.response.model"
387484
"""
388485
Exact model identifier used to generate the response
@@ -443,12 +540,24 @@ class SPANDATA:
443540
Example: 0.1
444541
"""
445542

543+
GEN_AI_REQUEST_SEED = "gen_ai.request.seed"
544+
"""
545+
The seed, ideally models given the same seed and same other parameters will produce the exact same output.
546+
Example: "1234567890"
547+
"""
548+
446549
GEN_AI_REQUEST_TEMPERATURE = "gen_ai.request.temperature"
447550
"""
448551
The temperature parameter used to control randomness in the output.
449552
Example: 0.7
450553
"""
451554

555+
GEN_AI_REQUEST_TOP_K = "gen_ai.request.top_k"
556+
"""
557+
Limits the model to only consider the K most likely next tokens, where K is an integer (e.g., top_k=20 means only the 20 highest probability tokens are considered).
558+
Example: 35
559+
"""
560+
452561
GEN_AI_REQUEST_TOP_P = "gen_ai.request.top_p"
453562
"""
454563
The top_p parameter used to control diversity via nucleus sampling.

0 commit comments

Comments
 (0)