monocle-apptrace 0.3.0b1__py3-none-any.whl → 0.3.0b3__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/exporters/aws/s3_exporter.py +1 -1
- monocle_apptrace/exporters/aws/s3_exporter_opendal.py +126 -0
- monocle_apptrace/exporters/azure/blob_exporter_opendal.py +147 -0
- monocle_apptrace/exporters/monocle_exporters.py +38 -20
- monocle_apptrace/instrumentation/__init__.py +0 -0
- monocle_apptrace/instrumentation/common/__init__.py +0 -0
- monocle_apptrace/{constants.py → instrumentation/common/constants.py} +13 -0
- monocle_apptrace/instrumentation/common/instrumentor.py +208 -0
- monocle_apptrace/instrumentation/common/span_handler.py +154 -0
- monocle_apptrace/instrumentation/common/utils.py +171 -0
- monocle_apptrace/instrumentation/common/wrapper.py +69 -0
- monocle_apptrace/instrumentation/common/wrapper_method.py +45 -0
- monocle_apptrace/instrumentation/metamodel/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/_helper.py +126 -0
- monocle_apptrace/instrumentation/metamodel/botocore/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/botocore/entities/inference.py +65 -0
- monocle_apptrace/instrumentation/metamodel/botocore/methods.py +16 -0
- monocle_apptrace/instrumentation/metamodel/haystack/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/haystack/_helper.py +127 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/inference.py +76 -0
- monocle_apptrace/instrumentation/metamodel/haystack/entities/retrieval.py +61 -0
- monocle_apptrace/instrumentation/metamodel/haystack/methods.py +42 -0
- monocle_apptrace/instrumentation/metamodel/langchain/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langchain/_helper.py +121 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/inference.py +71 -0
- monocle_apptrace/instrumentation/metamodel/langchain/entities/retrieval.py +58 -0
- monocle_apptrace/instrumentation/metamodel/langchain/methods.py +105 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/_helper.py +154 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/__init__.py +0 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/inference.py +71 -0
- monocle_apptrace/instrumentation/metamodel/llamaindex/entities/retrieval.py +57 -0
- monocle_apptrace/{metamodel/maps/llamaindex_methods.json → instrumentation/metamodel/llamaindex/methods.py} +28 -31
- {monocle_apptrace-0.3.0b1.dist-info → monocle_apptrace-0.3.0b3.dist-info}/METADATA +17 -2
- monocle_apptrace-0.3.0b3.dist-info/RECORD +48 -0
- {monocle_apptrace-0.3.0b1.dist-info → monocle_apptrace-0.3.0b3.dist-info}/WHEEL +1 -1
- monocle_apptrace/botocore/__init__.py +0 -9
- monocle_apptrace/haystack/__init__.py +0 -9
- monocle_apptrace/haystack/wrap_pipeline.py +0 -63
- monocle_apptrace/instrumentor.py +0 -121
- monocle_apptrace/langchain/__init__.py +0 -9
- monocle_apptrace/llamaindex/__init__.py +0 -16
- monocle_apptrace/message_processing.py +0 -80
- monocle_apptrace/metamodel/README.md +0 -47
- monocle_apptrace/metamodel/entities/README.md +0 -77
- monocle_apptrace/metamodel/entities/app_hosting_types.json +0 -29
- monocle_apptrace/metamodel/entities/entities.json +0 -49
- monocle_apptrace/metamodel/entities/inference_types.json +0 -33
- monocle_apptrace/metamodel/entities/model_types.json +0 -41
- monocle_apptrace/metamodel/entities/vector_store_types.json +0 -25
- monocle_apptrace/metamodel/entities/workflow_types.json +0 -22
- monocle_apptrace/metamodel/maps/attributes/inference/botocore_entities.json +0 -27
- monocle_apptrace/metamodel/maps/attributes/inference/haystack_entities.json +0 -57
- monocle_apptrace/metamodel/maps/attributes/inference/langchain_entities.json +0 -57
- monocle_apptrace/metamodel/maps/attributes/inference/llamaindex_entities.json +0 -57
- monocle_apptrace/metamodel/maps/attributes/retrieval/haystack_entities.json +0 -31
- monocle_apptrace/metamodel/maps/attributes/retrieval/langchain_entities.json +0 -31
- monocle_apptrace/metamodel/maps/attributes/retrieval/llamaindex_entities.json +0 -31
- monocle_apptrace/metamodel/maps/botocore_methods.json +0 -13
- monocle_apptrace/metamodel/maps/haystack_methods.json +0 -45
- monocle_apptrace/metamodel/maps/langchain_methods.json +0 -129
- monocle_apptrace/metamodel/spans/README.md +0 -121
- monocle_apptrace/metamodel/spans/span_example.json +0 -140
- monocle_apptrace/metamodel/spans/span_format.json +0 -55
- monocle_apptrace/metamodel/spans/span_types.json +0 -16
- monocle_apptrace/utils.py +0 -252
- monocle_apptrace/wrap_common.py +0 -511
- monocle_apptrace/wrapper.py +0 -27
- monocle_apptrace-0.3.0b1.dist-info/RECORD +0 -48
- {monocle_apptrace-0.3.0b1.dist-info → monocle_apptrace-0.3.0b3.dist-info}/licenses/LICENSE +0 -0
- {monocle_apptrace-0.3.0b1.dist-info → monocle_apptrace-0.3.0b3.dist-info}/licenses/NOTICE +0 -0
monocle_apptrace/instrumentor.py
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import logging, os
|
|
2
|
-
from typing import Collection, List
|
|
3
|
-
from wrapt import wrap_function_wrapper
|
|
4
|
-
from opentelemetry.trace import get_tracer
|
|
5
|
-
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
6
|
-
from opentelemetry.instrumentation.utils import unwrap
|
|
7
|
-
from opentelemetry.sdk.trace import TracerProvider, Span
|
|
8
|
-
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanProcessor
|
|
9
|
-
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
|
|
10
|
-
from opentelemetry import trace
|
|
11
|
-
from opentelemetry.context import get_value, attach, set_value
|
|
12
|
-
from monocle_apptrace.utils import process_wrapper_method_config
|
|
13
|
-
from monocle_apptrace.wrap_common import SESSION_PROPERTIES_KEY
|
|
14
|
-
from monocle_apptrace.wrapper import INBUILT_METHODS_LIST, WrapperMethod
|
|
15
|
-
from monocle_apptrace.exporters.monocle_exporters import get_monocle_exporter
|
|
16
|
-
|
|
17
|
-
logger = logging.getLogger(__name__)
|
|
18
|
-
|
|
19
|
-
_instruments = ()
|
|
20
|
-
|
|
21
|
-
class MonocleInstrumentor(BaseInstrumentor):
|
|
22
|
-
workflow_name: str = ""
|
|
23
|
-
user_wrapper_methods: list[WrapperMethod] = []
|
|
24
|
-
instrumented_method_list: list[object] = []
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
user_wrapper_methods: list[WrapperMethod] = None) -> None:
|
|
29
|
-
self.user_wrapper_methods = user_wrapper_methods or []
|
|
30
|
-
super().__init__()
|
|
31
|
-
|
|
32
|
-
def instrumentation_dependencies(self) -> Collection[str]:
|
|
33
|
-
return _instruments
|
|
34
|
-
|
|
35
|
-
def _instrument(self, **kwargs):
|
|
36
|
-
tracer_provider: TracerProvider = kwargs.get("tracer_provider")
|
|
37
|
-
tracer = get_tracer(instrumenting_module_name="monocle_apptrace", tracer_provider=tracer_provider)
|
|
38
|
-
|
|
39
|
-
user_method_list = [
|
|
40
|
-
{
|
|
41
|
-
"package": method.package,
|
|
42
|
-
"object": method.object,
|
|
43
|
-
"method": method.method,
|
|
44
|
-
"span_name": method.span_name,
|
|
45
|
-
"wrapper": method.wrapper,
|
|
46
|
-
"output_processor": method.output_processor
|
|
47
|
-
} for method in self.user_wrapper_methods]
|
|
48
|
-
process_wrapper_method_config(user_method_list)
|
|
49
|
-
final_method_list = user_method_list + INBUILT_METHODS_LIST
|
|
50
|
-
|
|
51
|
-
for wrapped_method in final_method_list:
|
|
52
|
-
try:
|
|
53
|
-
wrap_package = wrapped_method.get("package")
|
|
54
|
-
wrap_object = wrapped_method.get("object")
|
|
55
|
-
wrap_method = wrapped_method.get("method")
|
|
56
|
-
wrapper = wrapped_method.get("wrapper")
|
|
57
|
-
wrap_function_wrapper(
|
|
58
|
-
wrap_package,
|
|
59
|
-
f"{wrap_object}.{wrap_method}" if wrap_object else wrap_method,
|
|
60
|
-
wrapper(tracer, wrapped_method),
|
|
61
|
-
)
|
|
62
|
-
self.instrumented_method_list.append(wrapped_method)
|
|
63
|
-
except Exception as ex:
|
|
64
|
-
if wrapped_method in user_method_list:
|
|
65
|
-
logger.error(f"""_instrument wrap Exception: {str(ex)}
|
|
66
|
-
for package: {wrap_package},
|
|
67
|
-
object:{wrap_object},
|
|
68
|
-
method:{wrap_method}""")
|
|
69
|
-
|
|
70
|
-
def _uninstrument(self, **kwargs):
|
|
71
|
-
for wrapped_method in self.instrumented_method_list:
|
|
72
|
-
try:
|
|
73
|
-
wrap_package = wrapped_method.get("package")
|
|
74
|
-
wrap_object = wrapped_method.get("object")
|
|
75
|
-
wrap_method = wrapped_method.get("method")
|
|
76
|
-
unwrap(
|
|
77
|
-
f"{wrap_package}.{wrap_object}" if wrap_object else wrap_package,
|
|
78
|
-
wrap_method,
|
|
79
|
-
)
|
|
80
|
-
except Exception as ex:
|
|
81
|
-
logger.error(f"""_instrument unwrap Exception: {str(ex)}
|
|
82
|
-
for package: {wrap_package},
|
|
83
|
-
object:{wrap_object},
|
|
84
|
-
method:{wrap_method}""")
|
|
85
|
-
|
|
86
|
-
def setup_monocle_telemetry(
|
|
87
|
-
workflow_name: str,
|
|
88
|
-
span_processors: List[SpanProcessor] = None,
|
|
89
|
-
wrapper_methods: List[WrapperMethod] = None):
|
|
90
|
-
resource = Resource(attributes={
|
|
91
|
-
SERVICE_NAME: workflow_name
|
|
92
|
-
})
|
|
93
|
-
span_processors = span_processors or [BatchSpanProcessor(get_monocle_exporter())]
|
|
94
|
-
trace_provider = TracerProvider(resource=resource)
|
|
95
|
-
attach(set_value("workflow_name", workflow_name))
|
|
96
|
-
tracer_provider_default = trace.get_tracer_provider()
|
|
97
|
-
provider_type = type(tracer_provider_default).__name__
|
|
98
|
-
is_proxy_provider = "Proxy" in provider_type
|
|
99
|
-
for processor in span_processors:
|
|
100
|
-
processor.on_start = on_processor_start
|
|
101
|
-
if not is_proxy_provider:
|
|
102
|
-
tracer_provider_default.add_span_processor(processor)
|
|
103
|
-
else:
|
|
104
|
-
trace_provider.add_span_processor(processor)
|
|
105
|
-
if is_proxy_provider:
|
|
106
|
-
trace.set_tracer_provider(trace_provider)
|
|
107
|
-
instrumentor = MonocleInstrumentor(user_wrapper_methods=wrapper_methods or [])
|
|
108
|
-
# instrumentor.app_name = workflow_name
|
|
109
|
-
if not instrumentor.is_instrumented_by_opentelemetry:
|
|
110
|
-
instrumentor.instrument(trace_provider=trace_provider)
|
|
111
|
-
|
|
112
|
-
def on_processor_start(span: Span, parent_context):
|
|
113
|
-
context_properties = get_value(SESSION_PROPERTIES_KEY)
|
|
114
|
-
if context_properties is not None:
|
|
115
|
-
for key, value in context_properties.items():
|
|
116
|
-
span.set_attribute(
|
|
117
|
-
f"{SESSION_PROPERTIES_KEY}.{key}", value
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
def set_context_properties(properties: dict) -> None:
|
|
121
|
-
attach(set_value(SESSION_PROPERTIES_KEY, properties))
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from monocle_apptrace.utils import get_wrapper_methods_config
|
|
3
|
-
|
|
4
|
-
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
5
|
-
LANGCHAIN_METHODS = get_wrapper_methods_config(
|
|
6
|
-
wrapper_methods_config_path=os.path.join(parent_dir, 'metamodel', 'maps', 'langchain_methods.json'),
|
|
7
|
-
attributes_config_base_path=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
8
|
-
|
|
9
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# pylint: disable=protected-access
|
|
2
|
-
import os
|
|
3
|
-
from monocle_apptrace.utils import get_wrapper_methods_config
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def get_llm_span_name_for_openai(instance):
|
|
7
|
-
if (hasattr(instance, "_is_azure_client")
|
|
8
|
-
and callable(getattr(instance, "_is_azure_client"))
|
|
9
|
-
and instance._is_azure_client()):
|
|
10
|
-
return "llamaindex.azure_openai"
|
|
11
|
-
return "llamaindex.openai"
|
|
12
|
-
|
|
13
|
-
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
14
|
-
LLAMAINDEX_METHODS = get_wrapper_methods_config(
|
|
15
|
-
wrapper_methods_config_path=os.path.join(parent_dir, 'metamodel', 'maps', 'llamaindex_methods.json'),
|
|
16
|
-
attributes_config_base_path=os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
@@ -1,80 +0,0 @@
|
|
|
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.utils import get_attribute
|
|
8
|
-
DATA_INPUT_KEY = "data.input"
|
|
9
|
-
|
|
10
|
-
logger = logging.getLogger(__name__)
|
|
11
|
-
def extract_messages(args):
|
|
12
|
-
"""Extract system and user messages"""
|
|
13
|
-
try:
|
|
14
|
-
messages = []
|
|
15
|
-
args_input = get_attribute(DATA_INPUT_KEY)
|
|
16
|
-
if args_input:
|
|
17
|
-
messages.append(args_input)
|
|
18
|
-
return messages
|
|
19
|
-
if args and isinstance(args, tuple) and len(args) > 0:
|
|
20
|
-
if hasattr(args[0], "messages") and isinstance(args[0].messages, list):
|
|
21
|
-
for msg in args[0].messages:
|
|
22
|
-
if hasattr(msg, 'content') and hasattr(msg, 'type'):
|
|
23
|
-
messages.append({msg.type: msg.content})
|
|
24
|
-
elif isinstance(args[0], list): #llama
|
|
25
|
-
for msg in args[0]:
|
|
26
|
-
if hasattr(msg, 'content') and hasattr(msg, 'role'):
|
|
27
|
-
if hasattr(msg.role, 'value'):
|
|
28
|
-
role = msg.role.value
|
|
29
|
-
else:
|
|
30
|
-
role = msg.role
|
|
31
|
-
if msg.role == "system":
|
|
32
|
-
messages.append({role: msg.content})
|
|
33
|
-
elif msg.role in ["user", "human"]:
|
|
34
|
-
user_message = extract_query_from_content(msg.content)
|
|
35
|
-
messages.append({role: user_message})
|
|
36
|
-
return messages
|
|
37
|
-
except Exception as e:
|
|
38
|
-
logger.warning("Warning: Error occurred in extract_messages: %s", str(e))
|
|
39
|
-
return []
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def extract_assistant_message(response):
|
|
43
|
-
try:
|
|
44
|
-
if isinstance(response, str):
|
|
45
|
-
return [response]
|
|
46
|
-
if hasattr(response, "content"):
|
|
47
|
-
return [response.content]
|
|
48
|
-
if hasattr(response, "message") and hasattr(response.message, "content"):
|
|
49
|
-
return [response.message.content]
|
|
50
|
-
if "replies" in response:
|
|
51
|
-
reply = response["replies"][0]
|
|
52
|
-
if hasattr(reply, 'content'):
|
|
53
|
-
return [reply.content]
|
|
54
|
-
return [reply]
|
|
55
|
-
if isinstance(response, dict):
|
|
56
|
-
return [response]
|
|
57
|
-
return []
|
|
58
|
-
except Exception as e:
|
|
59
|
-
logger.warning("Warning: Error occurred in extract_assistant_message: %s", str(e))
|
|
60
|
-
return []
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def extract_query_from_content(content):
|
|
64
|
-
try:
|
|
65
|
-
query_prefix = "Query:"
|
|
66
|
-
answer_prefix = "Answer:"
|
|
67
|
-
query_start = content.find(query_prefix)
|
|
68
|
-
if query_start == -1:
|
|
69
|
-
return None
|
|
70
|
-
|
|
71
|
-
query_start += len(query_prefix)
|
|
72
|
-
answer_start = content.find(answer_prefix, query_start)
|
|
73
|
-
if answer_start == -1:
|
|
74
|
-
query = content[query_start:].strip()
|
|
75
|
-
else:
|
|
76
|
-
query = content[query_start:answer_start].strip()
|
|
77
|
-
return query
|
|
78
|
-
except Exception as e:
|
|
79
|
-
logger.warning("Warning: Error occurred in extract_query_from_content: %s", str(e))
|
|
80
|
-
return ""
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Monocle metamodel
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Monocle metamodel is the way to manage standardization across all supported GenAI component stack. It includes the list of components that Monocle can identify and extract metadata. This help understanding and analyzing the traces from applications that include multiple components and can evolve over time. This is one of core value that Monocle provides to it's user community.
|
|
5
|
-
|
|
6
|
-
## Meta model
|
|
7
|
-
The Monocle metamodel comprises of three things,
|
|
8
|
-
- Entity types, definitions of technology types and supported vendor implementations.
|
|
9
|
-
- A JSON format that overlays on top of Open Telemetry tracing format that includes the common attributes for each entity type.
|
|
10
|
-
- Map of component menthods to trace with instrumentation methods provided by Monocle.
|
|
11
|
-
|
|
12
|
-
### Entity type
|
|
13
|
-
The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component.
|
|
14
|
-
Each entity types has number of supported technology components that Monocle handles out of the box, eg. LlamaIndex is a supported workflow. Monocle community will continue to expand the breadth of the project by adding more components.
|
|
15
|
-
|
|
16
|
-
### Span types
|
|
17
|
-
The GenAI application have specific [types of spans](./spans/README.md#span-types-and-events) where diffrent entities integrate. Monocle metamodel defines these types and specifies format for tracing data and metadata generated in such spans.
|
|
18
|
-
|
|
19
|
-
### Consistent trace format
|
|
20
|
-
Monocle generates [traces](../../../Monocle_User_Guide.md#traces) which comprises of [spans](../../../Monocle_User_Guide.md#spans). Note that Monocle trace is [OpenTelemetry format](https://opentelemetry.io/docs/concepts/signals/traces/) compatible. Each span is essentially a step in the execution that interacts with one of more GenAI technology components. The please refer to the [full spec of the json format](./span_format.json) and a detailed [example](./span_example.json).
|
|
21
|
-
The ```attribute``` section of the span includes a list of such entities that are used in that span.
|
|
22
|
-
The runtime data and metadata collected during the execution of that span are included in the ```events``` section of the trace (as per the Otel spec). Each entry in the event corrosponds to the entity involved in that trace execution if it has produced any runtime outputs.
|
|
23
|
-
Please see the [span format](./spans/README.md) for details.
|
|
24
|
-
|
|
25
|
-
### Instrumentation method map
|
|
26
|
-
The map dectates what Monocle tracing method is relevant for the a given GenAI tech component method/API. It also specifies the name for that span to set in the trace output.
|
|
27
|
-
```python
|
|
28
|
-
{
|
|
29
|
-
"package": "llama_index.core.base.base_query_engine",
|
|
30
|
-
"object": "BaseQueryEngine",
|
|
31
|
-
"method": "query",
|
|
32
|
-
"span_name": "llamaindex.query",
|
|
33
|
-
"wrapper_package": "wrap_common",
|
|
34
|
-
"wrapper_method": "task_wrapper"
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Extending the meta model
|
|
39
|
-
Monocle is highly extensible. This section describe when one would need to extend the meta model. Please refer to Monocle [User guide](../../../Monocle_User_Guide.md) and [Contributor guide](../../../Monocle_contributor_guide.md) for detailed steps.
|
|
40
|
-
### Trace a new method/API
|
|
41
|
-
If you have overloaded an existing functionality in one of the supported components by creating a new function. Monocle doesn't know that this function should be traced, say because it's calling an LLM. You could define a new mapping so Monocle instrumentation can trace this function the say way it handles other LLM invocation functions.
|
|
42
|
-
|
|
43
|
-
### Adding a new component provider
|
|
44
|
-
Let's say there's a new database that supports vector search capability which is not supported by the Monocle. In this case, first you'll need to add that database under the ``MonocleEntity.VectorDB`` list. Then you'll need to extend the method map and test if the existing Monocle tracing functions has logic to effectively trace the new component. If not, then you might need to implement new method to cover the gap and update the mapping table according.
|
|
45
|
-
|
|
46
|
-
### Support new type of entity
|
|
47
|
-
If there's new component that can't be mapped to any of the existing entity types, then it'll require extending the metamodel and implement new instrumetation to support it. We recommend you initiate a discussion with Monocle community to add the support.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Monocle Entities
|
|
2
|
-
The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component.
|
|
3
|
-
|
|
4
|
-
## Entities
|
|
5
|
-
Following attributes are supported for all entities
|
|
6
|
-
| Name | Description | Required |
|
|
7
|
-
| - | - | - |
|
|
8
|
-
| name | Entity name generated by Monocle | Required |
|
|
9
|
-
| type | entity.category.type | True |
|
|
10
|
-
|
|
11
|
-
### MonocleEntity.Workflow
|
|
12
|
-
Workflow ie the core application code.
|
|
13
|
-
#### Workflow types
|
|
14
|
-
- generic
|
|
15
|
-
- langchain
|
|
16
|
-
- llamaindex
|
|
17
|
-
- haystack
|
|
18
|
-
|
|
19
|
-
### MonocleEntity.Model
|
|
20
|
-
GenAI models. It has following sub categories
|
|
21
|
-
- generic
|
|
22
|
-
- llm
|
|
23
|
-
- embedding
|
|
24
|
-
#### Model types
|
|
25
|
-
- gpt3
|
|
26
|
-
- gpt-3.5
|
|
27
|
-
- gpt-3.5-turbo
|
|
28
|
-
- gpt4
|
|
29
|
-
- gpt4o
|
|
30
|
-
- gpt4o-mini
|
|
31
|
-
- ollama
|
|
32
|
-
|
|
33
|
-
Following attributes are supported for all model type entities
|
|
34
|
-
| Name | Description | Required |
|
|
35
|
-
| - | - | - |
|
|
36
|
-
| parameters | model parameters | false |
|
|
37
|
-
| algorithm | model algorithm | false |
|
|
38
|
-
|
|
39
|
-
### MonocleEntity.AppHosting
|
|
40
|
-
Application host services where the workflow code is run.
|
|
41
|
-
#### AppHosting types
|
|
42
|
-
- generic
|
|
43
|
-
- aws_lambda
|
|
44
|
-
- aws_sagemaker
|
|
45
|
-
- azure_func
|
|
46
|
-
- github_codespace
|
|
47
|
-
- azure_mlw
|
|
48
|
-
|
|
49
|
-
### MonocleEntity.Inference
|
|
50
|
-
The model hosting infrastructure services.
|
|
51
|
-
Following attributes are supported for inference type entities
|
|
52
|
-
| Name | Description | Required |
|
|
53
|
-
| - | - | - |
|
|
54
|
-
| inference_endpoint | connection endpoint for inference service | false |
|
|
55
|
-
#### Inference types
|
|
56
|
-
- generic
|
|
57
|
-
- nvidia_triton
|
|
58
|
-
- openai
|
|
59
|
-
- azure_oai
|
|
60
|
-
- aws_sagemaker
|
|
61
|
-
- aws_bedrock
|
|
62
|
-
- hugging_face
|
|
63
|
-
|
|
64
|
-
Following attributes are supported for inference type entities
|
|
65
|
-
| Name | Description | Inference type | Required |
|
|
66
|
-
| - | - | - | - |
|
|
67
|
-
| deployment | model deployment name | azure_oai | false |
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
### MonocleEntity.VectorStore
|
|
71
|
-
Vector search data stores.
|
|
72
|
-
#### VectorStore types
|
|
73
|
-
- generic
|
|
74
|
-
- chroma
|
|
75
|
-
- aws_es
|
|
76
|
-
- milvus
|
|
77
|
-
- pinecone
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entity" : "app_hosting",
|
|
3
|
-
"types": [
|
|
4
|
-
{
|
|
5
|
-
"name": "aws_lambda",
|
|
6
|
-
"attributes" : []
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "aws_sagemaker",
|
|
10
|
-
"attributes" : []
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "azure_func",
|
|
14
|
-
"attributes" : []
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "azure_mlw",
|
|
18
|
-
"attributes" : []
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "github_codespace",
|
|
22
|
-
"attributes" : []
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "generic",
|
|
26
|
-
"attributes" : []
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "Monocle entities represents kinds GenAI technology components and their implementations supported by Monocle",
|
|
3
|
-
"monocle_entities": [
|
|
4
|
-
{
|
|
5
|
-
"name": "workflow",
|
|
6
|
-
"attributes" : [],
|
|
7
|
-
"categories": []
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"name": "model",
|
|
11
|
-
"attributes" : [
|
|
12
|
-
{
|
|
13
|
-
"attribute_name": "model_name",
|
|
14
|
-
"attribute_description": "Model name",
|
|
15
|
-
"required": true
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"categories": [
|
|
19
|
-
{
|
|
20
|
-
"name": "llm",
|
|
21
|
-
"attributes" : []
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "embedding",
|
|
25
|
-
"attributes" : []
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "generic",
|
|
29
|
-
"attributes" : []
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"name": "vector_store",
|
|
35
|
-
"attributes" : [],
|
|
36
|
-
"categories": []
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "app_hosting",
|
|
40
|
-
"attributes" : [],
|
|
41
|
-
"categories": []
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": "inference",
|
|
45
|
-
"attributes" : [],
|
|
46
|
-
"categories": []
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entity" : "vector_store",
|
|
3
|
-
"types": [
|
|
4
|
-
{
|
|
5
|
-
"name": "aws_sagemaker",
|
|
6
|
-
"attributes" : []
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "aws_bedrock",
|
|
10
|
-
"attributes" : []
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "azure_oai",
|
|
14
|
-
"attributes" : []
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "openai",
|
|
18
|
-
"attributes" : []
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "nvidia_triton",
|
|
22
|
-
"attributes" : []
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "hugging_face",
|
|
26
|
-
"attributes" : []
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"name": "generic",
|
|
30
|
-
"attributes" : []
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entity" : "model",
|
|
3
|
-
"types": [
|
|
4
|
-
{
|
|
5
|
-
"name": "gpt3",
|
|
6
|
-
"attributes" : []
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "gpt-3.5",
|
|
10
|
-
"attributes" : []
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "gpt-3.5-turbo",
|
|
14
|
-
"attributes" : []
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "gpt-3.5",
|
|
18
|
-
"attributes" : []
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "gpt4",
|
|
22
|
-
"attributes" : []
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "gpt4o",
|
|
26
|
-
"attributes" : []
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"name": "gpt4o-mini",
|
|
30
|
-
"attributes" : []
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "ollama",
|
|
34
|
-
"attributes" : []
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "generic",
|
|
38
|
-
"attributes" : []
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entity" : "vector_store",
|
|
3
|
-
"types": [
|
|
4
|
-
{
|
|
5
|
-
"name": "chroma",
|
|
6
|
-
"attributes" : []
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "aws_es",
|
|
10
|
-
"attributes" : []
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "milvus",
|
|
14
|
-
"attributes" : []
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "pinecone",
|
|
18
|
-
"attributes" : []
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"name": "generic",
|
|
22
|
-
"attributes" : []
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"entity" : "workflow",
|
|
3
|
-
"types": [
|
|
4
|
-
{
|
|
5
|
-
"name": "llama_index",
|
|
6
|
-
"attributes" : []
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "langchain",
|
|
10
|
-
"attributes" : []
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "haystack",
|
|
14
|
-
"attributes" : []
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"name": "generic",
|
|
18
|
-
"attributes" : []
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
]
|
|
22
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "inference",
|
|
3
|
-
"attributes": [
|
|
4
|
-
[
|
|
5
|
-
{
|
|
6
|
-
"_comment": "provider type , inference_endpoint",
|
|
7
|
-
"attribute": "type",
|
|
8
|
-
"accessor": "lambda arguments:'inference.aws_sagemaker'"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"attribute": "inference_endpoint",
|
|
12
|
-
"accessor": "lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['azure_endpoint', 'api_base']) or arguments['instance'].meta.endpoint_url"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
"_comment": "LLM Model",
|
|
18
|
-
"attribute": "name",
|
|
19
|
-
"accessor": "lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name']) or arguments['kwargs'].get('EndpointName', '')"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"attribute": "type",
|
|
23
|
-
"accessor": "lambda arguments: 'model.llm.' + (resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name']) or arguments['kwargs'].get('EndpointName', ''))"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
]
|
|
27
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "inference",
|
|
3
|
-
"attributes": [
|
|
4
|
-
[
|
|
5
|
-
{
|
|
6
|
-
"_comment": "provider type ,name , deployment , inference_endpoint",
|
|
7
|
-
"attribute": "type",
|
|
8
|
-
"accessor": "lambda arguments:'inference.azure_oai'"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"attribute": "provider_name",
|
|
12
|
-
"accessor": "lambda arguments:arguments['kwargs']['provider_name']"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"attribute": "deployment",
|
|
16
|
-
"accessor": "lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"attribute": "inference_endpoint",
|
|
20
|
-
"accessor": "lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['azure_endpoint', 'api_base']) or arguments['kwargs']['inference_endpoint']"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
[
|
|
24
|
-
{
|
|
25
|
-
"_comment": "LLM Model",
|
|
26
|
-
"attribute": "name",
|
|
27
|
-
"accessor": "lambda arguments: resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name'])"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"attribute": "type",
|
|
31
|
-
"accessor": "lambda arguments: 'model.llm.'+resolve_from_alias(arguments['instance'].__dict__, ['model', 'model_name'])"
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
],
|
|
35
|
-
"events": [
|
|
36
|
-
{ "name":"data.input",
|
|
37
|
-
"attributes": [
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
"_comment": "this is instruction and user query to LLM",
|
|
41
|
-
"attribute": "input",
|
|
42
|
-
"accessor": "lambda arguments: extract_messages(arguments['args'])"
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"name":"data.output",
|
|
48
|
-
"attributes": [
|
|
49
|
-
{
|
|
50
|
-
"_comment": "this is response from LLM",
|
|
51
|
-
"attribute": "response",
|
|
52
|
-
"accessor": "lambda response: extract_assistant_message(response)"
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|