monocle-apptrace 0.3.0b7__py3-none-any.whl → 0.3.1b1__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.
Potentially problematic release.
This version of monocle-apptrace might be problematic. Click here for more details.
- monocle_apptrace/instrumentation/common/constants.py +3 -0
- monocle_apptrace/instrumentation/common/wrapper_method.py +3 -1
- monocle_apptrace/instrumentation/metamodel/anthropic/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/anthropic/_helper.py +64 -0
- monocle_apptrace/instrumentation/metamodel/anthropic/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/anthropic/entities/inference.py +72 -0
- monocle_apptrace/instrumentation/metamodel/anthropic/methods.py +22 -0
- monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py +2 -2
- monocle_apptrace/instrumentation/metamodel/botocore/handlers/botocore_span_handler.py +1 -1
- monocle_apptrace/instrumentation/metamodel/openai/_helper.py +9 -4
- monocle_apptrace/instrumentation/metamodel/openai/methods.py +16 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/_helper.py +58 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/actionplanner_output_processor.py +80 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/teamsai_output_processor.py +70 -0
- monocle_apptrace/instrumentation/metamodel/teamsai/methods.py +26 -0
- {monocle_apptrace-0.3.0b7.dist-info → monocle_apptrace-0.3.1b1.dist-info}/METADATA +2 -1
- {monocle_apptrace-0.3.0b7.dist-info → monocle_apptrace-0.3.1b1.dist-info}/RECORD +23 -11
- {monocle_apptrace-0.3.0b7.dist-info → monocle_apptrace-0.3.1b1.dist-info}/WHEEL +0 -0
- {monocle_apptrace-0.3.0b7.dist-info → monocle_apptrace-0.3.1b1.dist-info}/licenses/LICENSE +0 -0
- {monocle_apptrace-0.3.0b7.dist-info → monocle_apptrace-0.3.1b1.dist-info}/licenses/NOTICE +0 -0
|
@@ -13,6 +13,7 @@ GITHUB_CODESPACE_IDENTIFIER_ENV_NAME = "GITHUB_REPOSITORY"
|
|
|
13
13
|
|
|
14
14
|
# Azure naming reference can be found here
|
|
15
15
|
# https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations
|
|
16
|
+
# https://docs.aws.amazon.com/resource-explorer/latest/userguide/supported-resource-types.html#services-lookoutmetrics
|
|
16
17
|
AZURE_FUNCTION_NAME = "azure.func"
|
|
17
18
|
AZURE_APP_SERVICE_NAME = "azure.asp"
|
|
18
19
|
AZURE_ML_SERVICE_NAME = "azure.mlw"
|
|
@@ -48,6 +49,8 @@ llm_type_map = {
|
|
|
48
49
|
"sagemakerllm": "aws_sagemaker",
|
|
49
50
|
"chatbedrock": "aws_bedrock",
|
|
50
51
|
"openaigenerator": "openai",
|
|
52
|
+
"bedrockruntime":"aws_bedrock",
|
|
53
|
+
"sagemakerruntime":"aws_sagemaker",
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
MONOCLE_INSTRUMENTOR = "monocle_apptrace"
|
|
@@ -15,6 +15,8 @@ from monocle_apptrace.instrumentation.metamodel.flask.methods import (FLASK_METH
|
|
|
15
15
|
from monocle_apptrace.instrumentation.metamodel.flask._helper import FlaskSpanHandler
|
|
16
16
|
from monocle_apptrace.instrumentation.metamodel.requests.methods import (REQUESTS_METHODS, )
|
|
17
17
|
from monocle_apptrace.instrumentation.metamodel.requests._helper import RequestSpanHandler
|
|
18
|
+
from monocle_apptrace.instrumentation.metamodel.teamsai.methods import (TEAMAI_METHODS, )
|
|
19
|
+
from monocle_apptrace.instrumentation.metamodel.anthropic.methods import (ANTHROPIC_METHODS, )
|
|
18
20
|
|
|
19
21
|
class WrapperMethod:
|
|
20
22
|
def __init__(
|
|
@@ -61,7 +63,7 @@ class WrapperMethod:
|
|
|
61
63
|
def get_span_handler(self) -> SpanHandler:
|
|
62
64
|
return self.span_handler()
|
|
63
65
|
|
|
64
|
-
DEFAULT_METHODS_LIST = LANGCHAIN_METHODS + LLAMAINDEX_METHODS + HAYSTACK_METHODS + BOTOCORE_METHODS + FLASK_METHODS + REQUESTS_METHODS + LANGGRAPH_METHODS + OPENAI_METHODS
|
|
66
|
+
DEFAULT_METHODS_LIST = LANGCHAIN_METHODS + LLAMAINDEX_METHODS + HAYSTACK_METHODS + BOTOCORE_METHODS + FLASK_METHODS + REQUESTS_METHODS + LANGGRAPH_METHODS + OPENAI_METHODS + TEAMAI_METHODS + ANTHROPIC_METHODS
|
|
65
67
|
|
|
66
68
|
MONOCLE_SPAN_HANDLERS: Dict[str, SpanHandler] = {
|
|
67
69
|
"default": SpanHandler(),
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides utility functions for extracting system, user,
|
|
3
|
+
and assistant messages from various input formats.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import logging
|
|
7
|
+
from monocle_apptrace.instrumentation.common.utils import (
|
|
8
|
+
Option,
|
|
9
|
+
get_keys_as_tuple,
|
|
10
|
+
get_nested_value,
|
|
11
|
+
try_option,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
def extract_provider_name(instance):
|
|
18
|
+
provider_url: Option[str] = try_option(getattr, instance._client.base_url, 'host')
|
|
19
|
+
return provider_url.unwrap_or(None)
|
|
20
|
+
|
|
21
|
+
def extract_inference_endpoint(instance):
|
|
22
|
+
inference_endpoint: Option[str] = try_option(getattr, instance._client, 'base_url').map(str)
|
|
23
|
+
if inference_endpoint.is_none() and "meta" in instance.client.__dict__:
|
|
24
|
+
inference_endpoint = try_option(getattr, instance.client.meta, 'endpoint_url').map(str)
|
|
25
|
+
|
|
26
|
+
return inference_endpoint.unwrap_or(extract_provider_name(instance))
|
|
27
|
+
|
|
28
|
+
def extract_messages(kwargs):
|
|
29
|
+
"""Extract system and user messages"""
|
|
30
|
+
try:
|
|
31
|
+
messages = []
|
|
32
|
+
if 'messages' in kwargs and len(kwargs['messages']) >0:
|
|
33
|
+
for msg in kwargs['messages']:
|
|
34
|
+
if msg.get('content') and msg.get('role'):
|
|
35
|
+
messages.append({msg['role']: msg['content']})
|
|
36
|
+
|
|
37
|
+
return [str(message) for message in messages]
|
|
38
|
+
except Exception as e:
|
|
39
|
+
logger.warning("Warning: Error occurred in extract_messages: %s", str(e))
|
|
40
|
+
return []
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def extract_assistant_message(response):
|
|
44
|
+
try:
|
|
45
|
+
if response is not None and hasattr(response,"content") and len(response.content) >0:
|
|
46
|
+
if hasattr(response.content[0],"text"):
|
|
47
|
+
return response.content[0].text
|
|
48
|
+
except (IndexError, AttributeError) as e:
|
|
49
|
+
logger.warning("Warning: Error occurred in extract_assistant_message: %s", str(e))
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
def update_span_from_llm_response(response):
|
|
53
|
+
meta_dict = {}
|
|
54
|
+
if response is not None and hasattr(response, "usage"):
|
|
55
|
+
if hasattr(response, "usage") and response.usage is not None:
|
|
56
|
+
token_usage = response.usage
|
|
57
|
+
else:
|
|
58
|
+
response_metadata = response.response_metadata
|
|
59
|
+
token_usage = response_metadata.get("token_usage")
|
|
60
|
+
if token_usage is not None:
|
|
61
|
+
meta_dict.update({"completion_tokens": getattr(response.usage, "output_tokens", 0)})
|
|
62
|
+
meta_dict.update({"prompt_tokens": getattr(response.usage, "input_tokens", 0)})
|
|
63
|
+
meta_dict.update({"total_tokens": getattr(response.usage, "input_tokens", 0)+getattr(response.usage, "output_tokens", 0)})
|
|
64
|
+
return meta_dict
|
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.metamodel.anthropic import (
|
|
2
|
+
_helper,
|
|
3
|
+
)
|
|
4
|
+
from monocle_apptrace.instrumentation.common.utils import resolve_from_alias, get_llm_type
|
|
5
|
+
|
|
6
|
+
INFERENCE = {
|
|
7
|
+
"type": "inference",
|
|
8
|
+
"attributes": [
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
"_comment": "provider type ,name , deployment , inference_endpoint",
|
|
12
|
+
"attribute": "type",
|
|
13
|
+
"accessor": lambda arguments: 'inference.' + (get_llm_type(arguments['instance']) or 'generic')
|
|
14
|
+
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"attribute": "provider_name",
|
|
18
|
+
"accessor": lambda arguments: _helper.extract_provider_name(arguments['instance'])
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"attribute": "deployment",
|
|
22
|
+
"accessor": lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"attribute": "inference_endpoint",
|
|
26
|
+
"accessor": lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['azure_endpoint', 'api_base', 'endpoint']) or _helper.extract_inference_endpoint(arguments['instance'])
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
{
|
|
31
|
+
"_comment": "LLM Model",
|
|
32
|
+
"attribute": "name",
|
|
33
|
+
"accessor": lambda arguments: resolve_from_alias(arguments['kwargs'], ['model', 'model_name', 'endpoint_name', 'deployment_name'])
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"attribute": "type",
|
|
37
|
+
"accessor": lambda arguments: 'model.llm.' + resolve_from_alias(arguments['kwargs'], ['model', 'model_name', 'endpoint_name', 'deployment_name'])
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
],
|
|
41
|
+
"events": [
|
|
42
|
+
{"name": "data.input",
|
|
43
|
+
"attributes": [
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
"_comment": "this is instruction and user query to LLM",
|
|
47
|
+
"attribute": "input",
|
|
48
|
+
"accessor": lambda arguments: _helper.extract_messages(arguments['kwargs'])
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "data.output",
|
|
54
|
+
"attributes": [
|
|
55
|
+
{
|
|
56
|
+
"_comment": "this is result from LLM",
|
|
57
|
+
"attribute": "response",
|
|
58
|
+
"accessor": lambda arguments: _helper.extract_assistant_message(arguments['result'])
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "metadata",
|
|
64
|
+
"attributes": [
|
|
65
|
+
{
|
|
66
|
+
"_comment": "this is metadata usage from LLM",
|
|
67
|
+
"accessor": lambda arguments: _helper.update_span_from_llm_response(arguments['result'])
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.common.wrapper import atask_wrapper, task_wrapper
|
|
2
|
+
from monocle_apptrace.instrumentation.metamodel.anthropic.entities.inference import (
|
|
3
|
+
INFERENCE,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
ANTHROPIC_METHODS = [
|
|
7
|
+
{
|
|
8
|
+
"package": "anthropic.resources.messages.messages",
|
|
9
|
+
"object": "Messages",
|
|
10
|
+
"method": "create",
|
|
11
|
+
"wrapper_method": task_wrapper,
|
|
12
|
+
"output_processor": INFERENCE
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"package": "anthropic.resources.messages.messages",
|
|
16
|
+
"object": "AsyncMessages",
|
|
17
|
+
"method": "create",
|
|
18
|
+
"wrapper_method": atask_wrapper,
|
|
19
|
+
"output_processor": INFERENCE
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from monocle_apptrace.instrumentation.metamodel.botocore import (
|
|
2
2
|
_helper,
|
|
3
3
|
)
|
|
4
|
-
|
|
4
|
+
from monocle_apptrace.instrumentation.common.utils import get_llm_type
|
|
5
5
|
INFERENCE = {
|
|
6
6
|
"type": "inference",
|
|
7
7
|
"attributes": [
|
|
@@ -9,7 +9,7 @@ INFERENCE = {
|
|
|
9
9
|
{
|
|
10
10
|
"_comment": "provider type , inference_endpoint",
|
|
11
11
|
"attribute": "type",
|
|
12
|
-
"accessor": lambda arguments: 'inference.
|
|
12
|
+
"accessor": lambda arguments: 'inference.'+(get_llm_type(arguments['instance']) or 'generic')
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"attribute": "inference_endpoint",
|
|
@@ -23,4 +23,4 @@ class BotoCoreSpanHandler(SpanHandler):
|
|
|
23
23
|
def post_tracing(self, to_wrap, wrapped, instance, args, kwargs, return_value):
|
|
24
24
|
self._botocore_processor(to_wrap=to_wrap, wrapped=wrapped, instance=instance, return_value=return_value, args=args,
|
|
25
25
|
kwargs=kwargs)
|
|
26
|
-
return super().
|
|
26
|
+
return super().post_tracing(to_wrap, wrapped, instance, args, kwargs,return_value)
|
|
@@ -19,6 +19,10 @@ def extract_messages(kwargs):
|
|
|
19
19
|
"""Extract system and user messages"""
|
|
20
20
|
try:
|
|
21
21
|
messages = []
|
|
22
|
+
if 'instructions' in kwargs:
|
|
23
|
+
messages.append({'instructions': kwargs.get('instructions', {})})
|
|
24
|
+
if 'input' in kwargs:
|
|
25
|
+
messages.append({'input': kwargs.get('input', {})})
|
|
22
26
|
if 'messages' in kwargs and len(kwargs['messages']) >0:
|
|
23
27
|
for msg in kwargs['messages']:
|
|
24
28
|
if msg.get('content') and msg.get('role'):
|
|
@@ -32,6 +36,8 @@ def extract_messages(kwargs):
|
|
|
32
36
|
|
|
33
37
|
def extract_assistant_message(response):
|
|
34
38
|
try:
|
|
39
|
+
if hasattr(response,"output_text") and len(response.output_text):
|
|
40
|
+
return response.output_text
|
|
35
41
|
if response is not None and hasattr(response,"choices") and len(response.choices) >0:
|
|
36
42
|
if hasattr(response.choices[0],"message"):
|
|
37
43
|
return response.choices[0].message.content
|
|
@@ -85,10 +91,9 @@ def update_span_from_llm_response(response):
|
|
|
85
91
|
response_metadata = response.response_metadata
|
|
86
92
|
token_usage = response_metadata.get("token_usage")
|
|
87
93
|
if token_usage is not None:
|
|
88
|
-
meta_dict.update(
|
|
89
|
-
|
|
90
|
-
meta_dict.update({"
|
|
91
|
-
meta_dict.update({"total_tokens": getattr(response.usage, "total_tokens", None)})
|
|
94
|
+
meta_dict.update({"completion_tokens": getattr(token_usage,"completion_tokens",None) or getattr(token_usage,"output_tokens",None)})
|
|
95
|
+
meta_dict.update({"prompt_tokens": getattr(token_usage, "prompt_tokens", None) or getattr(token_usage, "input_tokens", None)})
|
|
96
|
+
meta_dict.update({"total_tokens": getattr(token_usage,"total_tokens")})
|
|
92
97
|
return meta_dict
|
|
93
98
|
|
|
94
99
|
def extract_vector_input(vector_input: dict):
|
|
@@ -40,6 +40,22 @@ OPENAI_METHODS = [
|
|
|
40
40
|
"span_name": "openai_embeddings",
|
|
41
41
|
"span_handler": "non_framework_handler",
|
|
42
42
|
"output_processor": RETRIEVAL
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"package": "openai.resources.responses",
|
|
46
|
+
"object": "Responses",
|
|
47
|
+
"method": "create",
|
|
48
|
+
"wrapper_method": task_wrapper,
|
|
49
|
+
"span_handler": "non_framework_handler",
|
|
50
|
+
"output_processor": INFERENCE
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"package": "openai.resources.responses",
|
|
54
|
+
"object": "AsyncResponses",
|
|
55
|
+
"method": "create",
|
|
56
|
+
"wrapper_method": atask_wrapper,
|
|
57
|
+
"span_handler": "non_framework_handler",
|
|
58
|
+
"output_processor": INFERENCE
|
|
43
59
|
}
|
|
44
60
|
|
|
45
61
|
]
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.common.utils import MonocleSpanException
|
|
2
|
+
def capture_input(arguments):
|
|
3
|
+
"""
|
|
4
|
+
Captures the input from Teams AI state.
|
|
5
|
+
Args:
|
|
6
|
+
arguments (dict): Arguments containing state and context information
|
|
7
|
+
Returns:
|
|
8
|
+
str: The input message or error message
|
|
9
|
+
"""
|
|
10
|
+
try:
|
|
11
|
+
# Get the memory object from kwargs
|
|
12
|
+
kwargs = arguments.get("kwargs", {})
|
|
13
|
+
|
|
14
|
+
# If memory exists, try to get the input from temp
|
|
15
|
+
if "memory" in kwargs:
|
|
16
|
+
memory = kwargs["memory"]
|
|
17
|
+
# Check if it's a TurnState object
|
|
18
|
+
if hasattr(memory, "get"):
|
|
19
|
+
# Use proper TurnState.get() method
|
|
20
|
+
temp = memory.get("temp")
|
|
21
|
+
if temp and hasattr(temp, "get"):
|
|
22
|
+
input_value = temp.get("input")
|
|
23
|
+
if input_value:
|
|
24
|
+
return str(input_value)
|
|
25
|
+
|
|
26
|
+
# Try alternative path through context if memory path fails
|
|
27
|
+
context = kwargs.get("context")
|
|
28
|
+
if hasattr(context, "activity") and hasattr(context.activity, "text"):
|
|
29
|
+
return str(context.activity.text)
|
|
30
|
+
|
|
31
|
+
return "No input found in memory or context"
|
|
32
|
+
except Exception as e:
|
|
33
|
+
print(f"Debug - Arguments structure: {str(arguments)}")
|
|
34
|
+
print(f"Debug - kwargs: {str(kwargs)}")
|
|
35
|
+
if "memory" in kwargs:
|
|
36
|
+
print(f"Debug - memory type: {type(kwargs['memory'])}")
|
|
37
|
+
return f"Error capturing input: {str(e)}"
|
|
38
|
+
|
|
39
|
+
def capture_prompt_info(arguments):
|
|
40
|
+
"""Captures prompt information from ActionPlanner state"""
|
|
41
|
+
try:
|
|
42
|
+
kwargs = arguments.get("kwargs", {})
|
|
43
|
+
prompt = kwargs.get("prompt")
|
|
44
|
+
|
|
45
|
+
if isinstance(prompt, str):
|
|
46
|
+
return prompt
|
|
47
|
+
elif hasattr(prompt, "name"):
|
|
48
|
+
return prompt.name
|
|
49
|
+
|
|
50
|
+
return "No prompt information found"
|
|
51
|
+
except Exception as e:
|
|
52
|
+
return f"Error capturing prompt: {str(e)}"
|
|
53
|
+
|
|
54
|
+
def status_check(arguments):
|
|
55
|
+
if hasattr(arguments["result"], "error") and arguments["result"].error is not None:
|
|
56
|
+
error_msg:str = arguments["result"].error
|
|
57
|
+
error_code:str = arguments["result"].status if hasattr(arguments["result"], "status") else "unknown"
|
|
58
|
+
raise MonocleSpanException(f"Error: {error_code} - {error_msg}")
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.metamodel.teamsai import (
|
|
2
|
+
_helper,
|
|
3
|
+
)
|
|
4
|
+
ACTIONPLANNER_OUTPUT_PROCESSOR = {
|
|
5
|
+
"type": "inference",
|
|
6
|
+
"attributes": [
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
"_comment": "planner type and configuration",
|
|
10
|
+
"attribute": "type",
|
|
11
|
+
"accessor": lambda arguments: "teams.planner"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"attribute": "planner_type",
|
|
15
|
+
"accessor": lambda arguments: "ActionPlanner"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"attribute": "max_repair_attempts",
|
|
19
|
+
"accessor": lambda arguments: arguments["instance"]._options.max_repair_attempts if hasattr(arguments["instance"], "_options") else 3
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
"_comment": "model configuration",
|
|
25
|
+
"attribute": "model",
|
|
26
|
+
"accessor": lambda arguments: arguments["instance"]._options.model.__class__.__name__ if hasattr(arguments["instance"], "_options") else "unknown"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"attribute": "tokenizer",
|
|
30
|
+
"accessor": lambda arguments: arguments["instance"]._options.tokenizer.__class__.__name__ if hasattr(arguments["instance"], "_options") else "GPTTokenizer"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
],
|
|
34
|
+
"events": [
|
|
35
|
+
{
|
|
36
|
+
"name": "data.input",
|
|
37
|
+
"_comment": "input configuration to ActionPlanner",
|
|
38
|
+
"attributes": [
|
|
39
|
+
{
|
|
40
|
+
"attribute": "prompt_name",
|
|
41
|
+
"accessor": _helper.capture_prompt_info
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"attribute": "validator",
|
|
45
|
+
"accessor": lambda arguments: arguments["kwargs"].get("validator").__class__.__name__ if arguments.get("kwargs", {}).get("validator") else "DefaultResponseValidator"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"attribute": "memory_type",
|
|
49
|
+
"accessor": lambda arguments: arguments["kwargs"].get("memory").__class__.__name__ if arguments.get("kwargs", {}).get("memory") else "unknown"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "data.output",
|
|
55
|
+
"_comment": "output from ActionPlanner",
|
|
56
|
+
"attributes": [
|
|
57
|
+
{
|
|
58
|
+
"attribute": "status",
|
|
59
|
+
"accessor": lambda arguments: _helper.status_check(arguments)
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"attribute": "response",
|
|
63
|
+
"accessor": lambda arguments: arguments["result"].message.content if hasattr(arguments["result"], "message") else str(arguments["result"])
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "metadata",
|
|
69
|
+
"attributes": [
|
|
70
|
+
{
|
|
71
|
+
"_comment": "execution metadata",
|
|
72
|
+
"accessor": lambda arguments: {
|
|
73
|
+
"latency_ms": arguments.get("latency_ms"),
|
|
74
|
+
"feedback_enabled": arguments["instance"]._enable_feedback_loop if hasattr(arguments["instance"], "_enable_feedback_loop") else False
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/teamsai_output_processor.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.metamodel.teamsai import (
|
|
2
|
+
_helper,
|
|
3
|
+
)
|
|
4
|
+
TEAMAI_OUTPUT_PROCESSOR = {
|
|
5
|
+
"type": "inference",
|
|
6
|
+
"attributes": [
|
|
7
|
+
[
|
|
8
|
+
{
|
|
9
|
+
"_comment": "provider type, name, deployment",
|
|
10
|
+
"attribute": "type",
|
|
11
|
+
"accessor": lambda arguments: "teams.openai"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"attribute": "provider_name",
|
|
15
|
+
"accessor": lambda arguments: "Microsoft Teams AI"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"attribute": "deployment",
|
|
19
|
+
"accessor": lambda arguments: arguments["instance"]._options.default_model if hasattr(arguments["instance"], "_options") else "unknown"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
"_comment": "LLM Model",
|
|
25
|
+
"attribute": "name",
|
|
26
|
+
"accessor": lambda arguments: arguments["instance"]._options.default_model if hasattr(arguments["instance"], "_options") else "unknown"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"attribute": "is_streaming",
|
|
30
|
+
"accessor": lambda arguments: arguments["instance"]._options.stream if hasattr(arguments["instance"], "_options") else False
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
],
|
|
34
|
+
"events": [
|
|
35
|
+
{
|
|
36
|
+
"name": "data.input",
|
|
37
|
+
"_comment": "input to Teams AI",
|
|
38
|
+
"attributes": [
|
|
39
|
+
{
|
|
40
|
+
"attribute": "input",
|
|
41
|
+
"accessor": _helper.capture_input
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "data.output",
|
|
47
|
+
"_comment": "output from Teams AI",
|
|
48
|
+
"attributes": [
|
|
49
|
+
{
|
|
50
|
+
"attribute": "response",
|
|
51
|
+
"accessor": lambda arguments: arguments["result"].message.content if hasattr(arguments["result"], "message") else str(arguments["result"])
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "metadata",
|
|
57
|
+
"attributes": [
|
|
58
|
+
{
|
|
59
|
+
"_comment": "metadata from Teams AI response",
|
|
60
|
+
"accessor": lambda arguments: {
|
|
61
|
+
"prompt_tokens": arguments["result"].get("usage", {}).get("prompt_tokens", 0),
|
|
62
|
+
"completion_tokens": arguments["result"].get("usage", {}).get("completion_tokens", 0),
|
|
63
|
+
"total_tokens": arguments["result"].get("usage", {}).get("total_tokens", 0),
|
|
64
|
+
"latency_ms": arguments.get("latency_ms")
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from monocle_apptrace.instrumentation.common.wrapper import atask_wrapper, task_wrapper
|
|
2
|
+
from monocle_apptrace.instrumentation.metamodel.teamsai.entities.inference.teamsai_output_processor import (
|
|
3
|
+
TEAMAI_OUTPUT_PROCESSOR,
|
|
4
|
+
)
|
|
5
|
+
from monocle_apptrace.instrumentation.metamodel.teamsai.entities.inference.actionplanner_output_processor import (
|
|
6
|
+
ACTIONPLANNER_OUTPUT_PROCESSOR,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
TEAMAI_METHODS =[
|
|
10
|
+
{
|
|
11
|
+
"package": "teams.ai.models.openai_model",
|
|
12
|
+
"object": "OpenAIModel",
|
|
13
|
+
"method": "complete_prompt",
|
|
14
|
+
"span_name": "teamsai.workflow",
|
|
15
|
+
"wrapper_method": atask_wrapper,
|
|
16
|
+
"output_processor": TEAMAI_OUTPUT_PROCESSOR
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"package": "teams.ai.planners.action_planner",
|
|
20
|
+
"object": "ActionPlanner",
|
|
21
|
+
"method": "complete_prompt",
|
|
22
|
+
"span_name": "teamsai.workflow",
|
|
23
|
+
"wrapper_method": atask_wrapper,
|
|
24
|
+
"output_processor": ACTIONPLANNER_OUTPUT_PROCESSOR
|
|
25
|
+
}
|
|
26
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: monocle_apptrace
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1b1
|
|
4
4
|
Summary: package with monocle genAI tracing
|
|
5
5
|
Project-URL: Homepage, https://github.com/monocle2ai/monocle
|
|
6
6
|
Project-URL: Issues, https://github.com/monocle2ai/monocle/issues
|
|
@@ -20,6 +20,7 @@ Requires-Dist: boto3==1.35.19; extra == 'aws'
|
|
|
20
20
|
Provides-Extra: azure
|
|
21
21
|
Requires-Dist: azure-storage-blob==12.22.0; extra == 'azure'
|
|
22
22
|
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: anthropic==0.49.0; extra == 'dev'
|
|
23
24
|
Requires-Dist: azure-storage-blob==12.22.0; extra == 'dev'
|
|
24
25
|
Requires-Dist: boto3==1.34.131; extra == 'dev'
|
|
25
26
|
Requires-Dist: chromadb==0.4.22; extra == 'dev'
|
|
@@ -12,19 +12,24 @@ monocle_apptrace/exporters/azure/blob_exporter_opendal.py,sha256=wQUtciyFMD28tpW
|
|
|
12
12
|
monocle_apptrace/exporters/okahu/okahu_exporter.py,sha256=qj7paDHbWbYudH18xanUuxmhOHHlYEVj1kpzK7f2OTY,4601
|
|
13
13
|
monocle_apptrace/instrumentation/__init__.py,sha256=oa412OuokRm9Vf3XlCJLqpZjz9ZcuxAKxnEBvOK7u2M,21
|
|
14
14
|
monocle_apptrace/instrumentation/common/__init__.py,sha256=_YD94HPvDvHcrkt9Ll11BaHNzJ4W56GUJ7GPjp_diyA,223
|
|
15
|
-
monocle_apptrace/instrumentation/common/constants.py,sha256=
|
|
15
|
+
monocle_apptrace/instrumentation/common/constants.py,sha256=UsxkhlmLLq5OtkLdnGLWFJ06IkuM3xM1qaUeqeRgSq8,2871
|
|
16
16
|
monocle_apptrace/instrumentation/common/instrumentor.py,sha256=v-ZriWJdHlSOWkwprlwDaxm6kOVKyqehZ3m_kbECm0k,15087
|
|
17
17
|
monocle_apptrace/instrumentation/common/span_handler.py,sha256=WHvLc3TSqsrv62qJ_qclC57QT0bFoTCJ4hc-qe3SOYg,10229
|
|
18
18
|
monocle_apptrace/instrumentation/common/utils.py,sha256=iGxvC8V-2uLbrhFG9u9NKOyHkbd1moIkg6ukujDT88Y,12023
|
|
19
19
|
monocle_apptrace/instrumentation/common/wrapper.py,sha256=FNam-sz5gbTxa0Ym6-xyVhCA5HVAEObKDdQFubasIpU,4474
|
|
20
|
-
monocle_apptrace/instrumentation/common/wrapper_method.py,sha256=
|
|
20
|
+
monocle_apptrace/instrumentation/common/wrapper_method.py,sha256=YFXgFH1R02XmKeHBbHcal7vHGd4r-EY_Jrx7gtHAkI8,3410
|
|
21
21
|
monocle_apptrace/instrumentation/metamodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
monocle_apptrace/instrumentation/metamodel/anthropic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
monocle_apptrace/instrumentation/metamodel/anthropic/_helper.py,sha256=gnKlf3AlG-yEwX7w3TcWDoRcqKPTa1tiJpWSWu-eirU,2543
|
|
24
|
+
monocle_apptrace/instrumentation/metamodel/anthropic/methods.py,sha256=urXucmR1ZXeEsc-e0XvRQOwCAvfEr38p5QktGvtVPA4,641
|
|
25
|
+
monocle_apptrace/instrumentation/metamodel/anthropic/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
monocle_apptrace/instrumentation/metamodel/anthropic/entities/inference.py,sha256=MeHaJWYUKJ9EpvmUvoZ04tOuS57M4LRDHNZq_Ee1OQ8,2721
|
|
22
27
|
monocle_apptrace/instrumentation/metamodel/botocore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
28
|
monocle_apptrace/instrumentation/metamodel/botocore/_helper.py,sha256=JIYtaN57OXKO9zPuxMZzDycJbgHgAQaQUkwuCI_SzF8,3744
|
|
24
29
|
monocle_apptrace/instrumentation/metamodel/botocore/methods.py,sha256=LzmjbZjDWy7Uozc0chNjWG6PZhLngh_KJe5L6rw5rqI,452
|
|
25
30
|
monocle_apptrace/instrumentation/metamodel/botocore/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py,sha256=
|
|
27
|
-
monocle_apptrace/instrumentation/metamodel/botocore/handlers/botocore_span_handler.py,sha256=
|
|
31
|
+
monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py,sha256=rAsvhRIR9XYGd8NHTFDJQuiQSTzFoZ4oKeA6kEhK0QQ,2363
|
|
32
|
+
monocle_apptrace/instrumentation/metamodel/botocore/handlers/botocore_span_handler.py,sha256=8FSdoQSS6DuowF7KHhCRj5kpxYF-bBNR47W1tB-gVh0,1433
|
|
28
33
|
monocle_apptrace/instrumentation/metamodel/flask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
34
|
monocle_apptrace/instrumentation/metamodel/flask/_helper.py,sha256=AcQ5F6_IDmu9PXaeKKeiGIyq2I2YzA7wu1cvLzR-uyU,1175
|
|
30
35
|
monocle_apptrace/instrumentation/metamodel/flask/methods.py,sha256=QkWHX4wKQf_GiJBHmiS9_JD2CiKMTCWMcig2dxAiKgU,340
|
|
@@ -53,16 +58,23 @@ monocle_apptrace/instrumentation/metamodel/llamaindex/entities/agent.py,sha256=g
|
|
|
53
58
|
monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py,sha256=Hich1AoEHnCUvh0MIISNOjbH9t71eex_IsY_4j3JN5U,2727
|
|
54
59
|
monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py,sha256=QBF1nrqog5KHh925jiY2V-kejL6iVLKUowZmqUDoiJ4,1870
|
|
55
60
|
monocle_apptrace/instrumentation/metamodel/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
-
monocle_apptrace/instrumentation/metamodel/openai/_helper.py,sha256=
|
|
57
|
-
monocle_apptrace/instrumentation/metamodel/openai/methods.py,sha256=
|
|
61
|
+
monocle_apptrace/instrumentation/metamodel/openai/_helper.py,sha256=G_2-FafJGjTY0lU5OXQFNGCP2Z7OmgUMbTgNa37AVec,4256
|
|
62
|
+
monocle_apptrace/instrumentation/metamodel/openai/methods.py,sha256=J3aKsf74w-ix2zxaIhP5uHSj1WB939wDi3pGlGdATBU,1922
|
|
58
63
|
monocle_apptrace/instrumentation/metamodel/openai/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
64
|
monocle_apptrace/instrumentation/metamodel/openai/entities/inference.py,sha256=Egpx7ROZvwH6E3hqDWXa1gCXiNijnH3LD0HqQWhfspg,2716
|
|
60
65
|
monocle_apptrace/instrumentation/metamodel/openai/entities/retrieval.py,sha256=LU7aec302ZqPrs9MzFWU-JTnhK8OpYfgQKMmktlD6-8,1457
|
|
61
66
|
monocle_apptrace/instrumentation/metamodel/requests/__init__.py,sha256=mg04UgoPzzcH-cPOahYUqN9T-TolZyOZipnBwDg5TP8,250
|
|
62
67
|
monocle_apptrace/instrumentation/metamodel/requests/_helper.py,sha256=lKU7py-M0eweHA_LWatwdyWbSGSlQNhScGZ43Xko7us,1115
|
|
63
68
|
monocle_apptrace/instrumentation/metamodel/requests/methods.py,sha256=OJtosy_07xy01o5Qv-53--aCLQLkr82NZtyi2t6ZDEM,326
|
|
64
|
-
monocle_apptrace
|
|
65
|
-
monocle_apptrace
|
|
66
|
-
monocle_apptrace
|
|
67
|
-
monocle_apptrace
|
|
68
|
-
monocle_apptrace-0
|
|
69
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/_helper.py,sha256=ZkYLD4TqdhALq_0mYAmTR-cYuvHfKdXQz8_h2FK22ZI,2283
|
|
71
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/methods.py,sha256=PUi7bLwP1_WztTCGGGgxbJLjNjviqD3JLWRB2_-MQP8,949
|
|
72
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/actionplanner_output_processor.py,sha256=Y_aFDLgPVu9DA8J2z4DBpo4YpR5q-9FRHUtQOgunYM8,3168
|
|
75
|
+
monocle_apptrace/instrumentation/metamodel/teamsai/entities/inference/teamsai_output_processor.py,sha256=G7qdMuHRVv1AQVhE5yceonwcYAlfAc_4iOKmzD3IZt4,2564
|
|
76
|
+
monocle_apptrace-0.3.1b1.dist-info/METADATA,sha256=OI4wbYlf0MLfXXGDWZbbqRQZqbfSrcWstn62iSqijz8,6363
|
|
77
|
+
monocle_apptrace-0.3.1b1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
78
|
+
monocle_apptrace-0.3.1b1.dist-info/licenses/LICENSE,sha256=ay9trLiP5I7ZsFXo6AqtkLYdRqe5S9r-DrPOvsNlZrg,9136
|
|
79
|
+
monocle_apptrace-0.3.1b1.dist-info/licenses/NOTICE,sha256=9jn4xtwM_uUetJMx5WqGnhrR7MIhpoRlpokjSTlyt8c,112
|
|
80
|
+
monocle_apptrace-0.3.1b1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|