openlit 1.34.31__py3-none-any.whl → 1.34.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openlit/__init__.py +3 -1
- openlit/instrumentation/ag2/__init__.py +92 -1
- openlit/instrumentation/ag2/ag2.py +425 -4
- openlit/instrumentation/ag2/async_ag2.py +425 -4
- openlit/instrumentation/ag2/utils.py +343 -2
- openlit/semcov/__init__.py +10 -0
- {openlit-1.34.31.dist-info → openlit-1.34.32.dist-info}/METADATA +1 -1
- {openlit-1.34.31.dist-info → openlit-1.34.32.dist-info}/RECORD +10 -10
- {openlit-1.34.31.dist-info → openlit-1.34.32.dist-info}/LICENSE +0 -0
- {openlit-1.34.31.dist-info → openlit-1.34.32.dist-info}/WHEEL +0 -0
@@ -147,7 +147,7 @@ def common_agent_logic(
|
|
147
147
|
scope._span.set_status(Status(StatusCode.OK))
|
148
148
|
|
149
149
|
# Metrics
|
150
|
-
if not disable_metrics and hasattr(scope, "_input_tokens"):
|
150
|
+
if not disable_metrics and metrics is not None and hasattr(scope, "_input_tokens"):
|
151
151
|
record_completion_metrics(
|
152
152
|
metrics,
|
153
153
|
operation_type,
|
@@ -196,7 +196,7 @@ def process_agent_creation(
|
|
196
196
|
scope._end_time = time.time()
|
197
197
|
scope._span = span
|
198
198
|
scope._agent_name = agent_name
|
199
|
-
scope._request_model = llm_config.get("model", "
|
199
|
+
scope._request_model = llm_config.get("model", "unknown")
|
200
200
|
scope._response_model = scope._request_model
|
201
201
|
scope._system_message = system_message
|
202
202
|
scope._server_address, scope._server_port = server_address, server_port
|
@@ -276,3 +276,344 @@ def process_agent_run(
|
|
276
276
|
)
|
277
277
|
|
278
278
|
return response
|
279
|
+
|
280
|
+
|
281
|
+
def process_agent_generate_reply(
|
282
|
+
response,
|
283
|
+
agent_name,
|
284
|
+
request_model,
|
285
|
+
messages,
|
286
|
+
sender,
|
287
|
+
pricing_info,
|
288
|
+
server_port,
|
289
|
+
server_address,
|
290
|
+
environment,
|
291
|
+
application_name,
|
292
|
+
metrics,
|
293
|
+
start_time,
|
294
|
+
span,
|
295
|
+
capture_message_content=False,
|
296
|
+
disable_metrics=False,
|
297
|
+
version="1.0.0",
|
298
|
+
**kwargs,
|
299
|
+
):
|
300
|
+
"""
|
301
|
+
Process agent generate_reply and generate Telemetry
|
302
|
+
"""
|
303
|
+
|
304
|
+
# Create scope object
|
305
|
+
scope = type("GenericScope", (), {})()
|
306
|
+
|
307
|
+
scope._start_time = start_time
|
308
|
+
scope._end_time = time.time()
|
309
|
+
scope._span = span
|
310
|
+
scope._agent_name = agent_name
|
311
|
+
scope._request_model = request_model
|
312
|
+
scope._response_model = request_model
|
313
|
+
scope._server_address, scope._server_port = server_address, server_port
|
314
|
+
scope._messages = messages
|
315
|
+
scope._sender_name = getattr(sender, "name", "Unknown") if sender else "Unknown"
|
316
|
+
|
317
|
+
# Set agent-specific attributes
|
318
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_MESSAGE_TYPE, "generate_reply")
|
319
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_SENDER, scope._sender_name)
|
320
|
+
|
321
|
+
# Process response content
|
322
|
+
if response and isinstance(response, str):
|
323
|
+
scope._response_content = response
|
324
|
+
elif response and hasattr(response, "content"):
|
325
|
+
scope._response_content = response.content
|
326
|
+
else:
|
327
|
+
scope._response_content = str(response) if response else ""
|
328
|
+
|
329
|
+
# Try to extract token information if available
|
330
|
+
try:
|
331
|
+
# Mock token calculation for generate_reply
|
332
|
+
scope._input_tokens = len(str(messages)) // 4 if messages else 0
|
333
|
+
scope._output_tokens = len(scope._response_content) // 4
|
334
|
+
scope._cost = get_chat_model_cost(
|
335
|
+
request_model, pricing_info, scope._input_tokens, scope._output_tokens
|
336
|
+
)
|
337
|
+
except Exception:
|
338
|
+
scope._input_tokens = 0
|
339
|
+
scope._output_tokens = 0
|
340
|
+
scope._cost = 0.0
|
341
|
+
|
342
|
+
common_agent_logic(
|
343
|
+
scope,
|
344
|
+
pricing_info,
|
345
|
+
environment,
|
346
|
+
application_name,
|
347
|
+
metrics,
|
348
|
+
capture_message_content,
|
349
|
+
disable_metrics,
|
350
|
+
version,
|
351
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
352
|
+
)
|
353
|
+
|
354
|
+
return response
|
355
|
+
|
356
|
+
|
357
|
+
def process_agent_receive(
|
358
|
+
message,
|
359
|
+
agent_name,
|
360
|
+
sender_name,
|
361
|
+
agent_instance,
|
362
|
+
pricing_info,
|
363
|
+
server_port,
|
364
|
+
server_address,
|
365
|
+
environment,
|
366
|
+
application_name,
|
367
|
+
metrics,
|
368
|
+
start_time,
|
369
|
+
span,
|
370
|
+
capture_message_content=False,
|
371
|
+
disable_metrics=False,
|
372
|
+
version="1.0.0",
|
373
|
+
**kwargs,
|
374
|
+
):
|
375
|
+
"""
|
376
|
+
Process agent receive and generate Telemetry
|
377
|
+
"""
|
378
|
+
|
379
|
+
# Create scope object
|
380
|
+
scope = type("GenericScope", (), {})()
|
381
|
+
|
382
|
+
scope._start_time = start_time
|
383
|
+
scope._end_time = time.time()
|
384
|
+
scope._span = span
|
385
|
+
scope._agent_name = agent_name
|
386
|
+
scope._sender_name = sender_name
|
387
|
+
scope._server_address, scope._server_port = server_address, server_port
|
388
|
+
scope._message = message
|
389
|
+
|
390
|
+
# Extract model from agent instance
|
391
|
+
if hasattr(agent_instance, "llm_config") and isinstance(
|
392
|
+
agent_instance.llm_config, dict
|
393
|
+
):
|
394
|
+
scope._request_model = agent_instance.llm_config.get("model", "unknown")
|
395
|
+
else:
|
396
|
+
scope._request_model = "unknown"
|
397
|
+
scope._response_model = scope._request_model
|
398
|
+
|
399
|
+
# Set agent-specific attributes
|
400
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_MESSAGE_TYPE, "receive")
|
401
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_SENDER, sender_name)
|
402
|
+
|
403
|
+
# Content capture for received message
|
404
|
+
if capture_message_content:
|
405
|
+
span.set_attribute(SemanticConvention.GEN_AI_CONTENT_PROMPT, str(message))
|
406
|
+
|
407
|
+
common_agent_logic(
|
408
|
+
scope,
|
409
|
+
pricing_info,
|
410
|
+
environment,
|
411
|
+
application_name,
|
412
|
+
metrics,
|
413
|
+
capture_message_content,
|
414
|
+
disable_metrics,
|
415
|
+
version,
|
416
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
417
|
+
)
|
418
|
+
|
419
|
+
|
420
|
+
def process_agent_send(
|
421
|
+
message,
|
422
|
+
agent_name,
|
423
|
+
recipient_name,
|
424
|
+
agent_instance,
|
425
|
+
pricing_info,
|
426
|
+
server_port,
|
427
|
+
server_address,
|
428
|
+
environment,
|
429
|
+
application_name,
|
430
|
+
metrics,
|
431
|
+
start_time,
|
432
|
+
span,
|
433
|
+
capture_message_content=False,
|
434
|
+
disable_metrics=False,
|
435
|
+
version="1.0.0",
|
436
|
+
**kwargs,
|
437
|
+
):
|
438
|
+
"""
|
439
|
+
Process agent send and generate Telemetry
|
440
|
+
"""
|
441
|
+
|
442
|
+
# Create scope object
|
443
|
+
scope = type("GenericScope", (), {})()
|
444
|
+
|
445
|
+
scope._start_time = start_time
|
446
|
+
scope._end_time = time.time()
|
447
|
+
scope._span = span
|
448
|
+
scope._agent_name = agent_name
|
449
|
+
scope._recipient_name = recipient_name
|
450
|
+
scope._server_address, scope._server_port = server_address, server_port
|
451
|
+
scope._message = message
|
452
|
+
|
453
|
+
# Extract model from agent instance
|
454
|
+
if hasattr(agent_instance, "llm_config") and isinstance(
|
455
|
+
agent_instance.llm_config, dict
|
456
|
+
):
|
457
|
+
scope._request_model = agent_instance.llm_config.get("model", "unknown")
|
458
|
+
else:
|
459
|
+
scope._request_model = "unknown"
|
460
|
+
scope._response_model = scope._request_model
|
461
|
+
|
462
|
+
# Set agent-specific attributes
|
463
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_MESSAGE_TYPE, "send")
|
464
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_RECIPIENT, recipient_name)
|
465
|
+
|
466
|
+
# Content capture for sent message
|
467
|
+
if capture_message_content:
|
468
|
+
span.set_attribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION, str(message))
|
469
|
+
|
470
|
+
common_agent_logic(
|
471
|
+
scope,
|
472
|
+
pricing_info,
|
473
|
+
environment,
|
474
|
+
application_name,
|
475
|
+
metrics,
|
476
|
+
capture_message_content,
|
477
|
+
disable_metrics,
|
478
|
+
version,
|
479
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
480
|
+
)
|
481
|
+
|
482
|
+
|
483
|
+
def process_groupchat_operation(
|
484
|
+
group_name,
|
485
|
+
participants,
|
486
|
+
messages,
|
487
|
+
sender,
|
488
|
+
max_turns,
|
489
|
+
request_model,
|
490
|
+
pricing_info,
|
491
|
+
server_port,
|
492
|
+
server_address,
|
493
|
+
environment,
|
494
|
+
application_name,
|
495
|
+
metrics,
|
496
|
+
start_time,
|
497
|
+
span,
|
498
|
+
capture_message_content=False,
|
499
|
+
disable_metrics=False,
|
500
|
+
version="1.0.0",
|
501
|
+
**kwargs,
|
502
|
+
):
|
503
|
+
"""
|
504
|
+
Process GroupChat operation and generate Telemetry
|
505
|
+
"""
|
506
|
+
|
507
|
+
# Create scope object
|
508
|
+
scope = type("GenericScope", (), {})()
|
509
|
+
|
510
|
+
scope._start_time = start_time
|
511
|
+
scope._end_time = time.time()
|
512
|
+
scope._span = span
|
513
|
+
scope._group_name = group_name
|
514
|
+
scope._participants = participants
|
515
|
+
scope._server_address, scope._server_port = server_address, server_port
|
516
|
+
scope._sender_name = getattr(sender, "name", "Unknown") if sender else "Unknown"
|
517
|
+
|
518
|
+
# Add required model attributes for common_agent_logic
|
519
|
+
scope._request_model = request_model
|
520
|
+
scope._response_model = request_model
|
521
|
+
|
522
|
+
# Set agent name for groupchat
|
523
|
+
scope._agent_name = group_name
|
524
|
+
|
525
|
+
# Set GroupChat-specific attributes
|
526
|
+
span.set_attribute(
|
527
|
+
SemanticConvention.GEN_AI_GROUPCHAT_PARTICIPANTS, ",".join(participants)
|
528
|
+
)
|
529
|
+
span.set_attribute(
|
530
|
+
SemanticConvention.GEN_AI_WORKFLOW_AGENT_COUNT, len(participants)
|
531
|
+
)
|
532
|
+
span.set_attribute(SemanticConvention.GEN_AI_WORKFLOW_EXECUTION_TYPE, "groupchat")
|
533
|
+
|
534
|
+
if max_turns:
|
535
|
+
span.set_attribute(SemanticConvention.GEN_AI_GROUPCHAT_TURN_COUNT, max_turns)
|
536
|
+
|
537
|
+
# Content capture for GroupChat
|
538
|
+
if capture_message_content and messages:
|
539
|
+
span.set_attribute(SemanticConvention.GEN_AI_CONTENT_PROMPT, str(messages))
|
540
|
+
|
541
|
+
# Use framework operation type for GroupChat
|
542
|
+
common_agent_logic(
|
543
|
+
scope,
|
544
|
+
pricing_info,
|
545
|
+
environment,
|
546
|
+
application_name,
|
547
|
+
metrics,
|
548
|
+
capture_message_content,
|
549
|
+
disable_metrics,
|
550
|
+
version,
|
551
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK,
|
552
|
+
)
|
553
|
+
|
554
|
+
|
555
|
+
def process_speaker_selection(
|
556
|
+
last_speaker,
|
557
|
+
selected_speaker,
|
558
|
+
selector,
|
559
|
+
agents,
|
560
|
+
request_model,
|
561
|
+
pricing_info,
|
562
|
+
server_port,
|
563
|
+
server_address,
|
564
|
+
environment,
|
565
|
+
application_name,
|
566
|
+
metrics,
|
567
|
+
start_time,
|
568
|
+
span,
|
569
|
+
capture_message_content=False,
|
570
|
+
disable_metrics=False,
|
571
|
+
version="1.0.0",
|
572
|
+
**kwargs,
|
573
|
+
):
|
574
|
+
"""
|
575
|
+
Process speaker selection and generate Telemetry
|
576
|
+
"""
|
577
|
+
|
578
|
+
# Create scope object
|
579
|
+
scope = type("GenericScope", (), {})()
|
580
|
+
|
581
|
+
scope._start_time = start_time
|
582
|
+
scope._end_time = time.time()
|
583
|
+
scope._span = span
|
584
|
+
scope._last_speaker = last_speaker
|
585
|
+
scope._selected_speaker = selected_speaker
|
586
|
+
scope._server_address, scope._server_port = server_address, server_port
|
587
|
+
|
588
|
+
# Add required model attributes for common_agent_logic
|
589
|
+
scope._request_model = request_model
|
590
|
+
scope._response_model = request_model
|
591
|
+
|
592
|
+
# Set agent name for speaker selection
|
593
|
+
scope._agent_name = "speaker_selection"
|
594
|
+
|
595
|
+
# Set speaker selection attributes
|
596
|
+
span.set_attribute(
|
597
|
+
SemanticConvention.GEN_AI_GROUPCHAT_SPEAKER_SELECTION, selected_speaker
|
598
|
+
)
|
599
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_SENDER, last_speaker)
|
600
|
+
|
601
|
+
if selector:
|
602
|
+
span.set_attribute(SemanticConvention.GEN_AI_AGENT_ROLE, "selector")
|
603
|
+
|
604
|
+
# Set agent count
|
605
|
+
if agents:
|
606
|
+
span.set_attribute(SemanticConvention.GEN_AI_WORKFLOW_AGENT_COUNT, len(agents))
|
607
|
+
|
608
|
+
# Use agent operation type for speaker selection
|
609
|
+
common_agent_logic(
|
610
|
+
scope,
|
611
|
+
pricing_info,
|
612
|
+
environment,
|
613
|
+
application_name,
|
614
|
+
metrics,
|
615
|
+
capture_message_content,
|
616
|
+
disable_metrics,
|
617
|
+
version,
|
618
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
|
619
|
+
)
|
openlit/semcov/__init__.py
CHANGED
@@ -498,3 +498,13 @@ class SemanticConvention:
|
|
498
498
|
# Standard Task Attributes (framework-agnostic)
|
499
499
|
GEN_AI_TASK_DESCRIPTION = "gen_ai.task.description"
|
500
500
|
GEN_AI_TASK_EXPECTED_OUTPUT = "gen_ai.task.expected_output"
|
501
|
+
|
502
|
+
GEN_AI_GROUPCHAT_PARTICIPANTS = "gen_ai.groupchat.participants"
|
503
|
+
GEN_AI_GROUPCHAT_SPEAKER_SELECTION = "gen_ai.groupchat.speaker_selection"
|
504
|
+
GEN_AI_GROUPCHAT_MESSAGE_COUNT = "gen_ai.groupchat.message_count"
|
505
|
+
GEN_AI_GROUPCHAT_TURN_COUNT = "gen_ai.groupchat.turn_count"
|
506
|
+
|
507
|
+
GEN_AI_AGENT_RECIPIENT = "gen_ai.agent.recipient"
|
508
|
+
GEN_AI_AGENT_SENDER = "gen_ai.agent.sender"
|
509
|
+
GEN_AI_AGENT_MESSAGE_TYPE = "gen_ai.agent.message_type"
|
510
|
+
GEN_AI_AGENT_REPLY_MODE = "gen_ai.agent.reply_mode"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.34.
|
3
|
+
Version: 1.34.32
|
4
4
|
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
|
@@ -1,5 +1,5 @@
|
|
1
1
|
openlit/__helpers.py,sha256=KovxaOSxiDeVW63IDZ1CtryKE65ij2kjuYTSvCLCypI,20988
|
2
|
-
openlit/__init__.py,sha256=
|
2
|
+
openlit/__init__.py,sha256=0opC1ShHgX7U27JHZC5XEbo2JPwO2jFlUPyAjSLb4Vo,18672
|
3
3
|
openlit/_instrumentors.py,sha256=jqGvYkvMc5WdZdhhHn6BjzEJsZnCxkHkgMpQ7mbRDXE,5746
|
4
4
|
openlit/evals/__init__.py,sha256=nJe99nuLo1b5rf7pt9U9BCdSDedzbVi2Fj96cgl7msM,380
|
5
5
|
openlit/evals/all.py,sha256=X1RXC6A-TVlKvUX-4ZSafiu1B4C_40zzXGqvcb0a0kU,7310
|
@@ -13,10 +13,10 @@ openlit/guard/prompt_injection.py,sha256=MlX4nWqBRfRUCkoIsfv_OMazJnFyKDZJYzMTM1R
|
|
13
13
|
openlit/guard/restrict_topic.py,sha256=ElQ-vJVeGyS2qqsIsWM72nmtRmodVO1BJimXv3vwfU0,6756
|
14
14
|
openlit/guard/sensitive_topic.py,sha256=aaaeEAj6_tcV9wMmGpsFPypDHTbbXrRof7NtWGazuSs,5676
|
15
15
|
openlit/guard/utils.py,sha256=K7A5LIDHM3ctsLYfo-jHuoByMuCPKK1llJDjZBpM8L4,8108
|
16
|
-
openlit/instrumentation/ag2/__init__.py,sha256=
|
17
|
-
openlit/instrumentation/ag2/ag2.py,sha256=
|
18
|
-
openlit/instrumentation/ag2/async_ag2.py,sha256=
|
19
|
-
openlit/instrumentation/ag2/utils.py,sha256=
|
16
|
+
openlit/instrumentation/ag2/__init__.py,sha256=SxxQ3CIpCiVA1G2_nRvd5F7gqCnN5ButIKzrbSUFA30,4617
|
17
|
+
openlit/instrumentation/ag2/ag2.py,sha256=ehRRyVpz7IbMTO1jQqP6rEf5YHLSDbo0lq0r_BhvL0w,17816
|
18
|
+
openlit/instrumentation/ag2/async_ag2.py,sha256=FXnnt38LyNQjv0ha-QbgXSOAjZYN0UKuiYVe8B2Mjfo,18064
|
19
|
+
openlit/instrumentation/ag2/utils.py,sha256=qmbgt0g3_YwcL9pjTrtSc-G3KOobyUMAr30SQ0o2Kd0,17086
|
20
20
|
openlit/instrumentation/ai21/__init__.py,sha256=RyJdKcjcfEkRjECi02M7lApGmEu-OhbIfZwP8XI4oT8,3008
|
21
21
|
openlit/instrumentation/ai21/ai21.py,sha256=prcC0bV6hlET72qQ00uswTGixKVfu-b8B9_EpLhpk_g,6685
|
22
22
|
openlit/instrumentation/ai21/async_ai21.py,sha256=nr_Gaw6BLqredXzq_kcQpxDntYTCYFEnIXouBA3bZGo,6811
|
@@ -159,8 +159,8 @@ openlit/instrumentation/vllm/vllm.py,sha256=zdzKUkQYmpFlOQ8rObzRiVZEyHOaJFxUagwC
|
|
159
159
|
openlit/otel/events.py,sha256=iOyKIYHA-QYq5bnHVTV_JKeGC5Tsi1icc5nOa3Km_fA,3825
|
160
160
|
openlit/otel/metrics.py,sha256=ipH2NB65yOG7yGB32vqmMQ5HjWSeKAk3q4hzGRXRBOs,7238
|
161
161
|
openlit/otel/tracing.py,sha256=6KZc-Yubq-S7wEPshUiMNFkw8XN5WvrqIovWaq3gsKw,3301
|
162
|
-
openlit/semcov/__init__.py,sha256=
|
163
|
-
openlit-1.34.
|
164
|
-
openlit-1.34.
|
165
|
-
openlit-1.34.
|
166
|
-
openlit-1.34.
|
162
|
+
openlit/semcov/__init__.py,sha256=d3XrCplVR-Bry4sx8AEjkvSvJIPtRds5StZhcCRr02s,23018
|
163
|
+
openlit-1.34.32.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
164
|
+
openlit-1.34.32.dist-info/METADATA,sha256=dsRHoblJ0gDndZbgGKm6lBmU0BOpLJt6X-edRYWQzE4,23552
|
165
|
+
openlit-1.34.32.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
166
|
+
openlit-1.34.32.dist-info/RECORD,,
|
File without changes
|
File without changes
|