Skip to content

Commit

Permalink
updated metamodel entity
Browse files Browse the repository at this point in the history
Signed-off-by: sachintendulkar576123 <[email protected]>
  • Loading branch information
sachintendulkar576123 committed Oct 16, 2024
1 parent 501452f commit 59eb190
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 543 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"type": "inference",
"attributes": [
[
{
"_comment": "provider type ,name , deployment , inference_endpoint",
"attribute": "type",
"accessor": "lambda instance,args:'inference.azure_oai'"
},
{
"attribute": "provider_name",
"accessor": "lambda instance,args:args['provider_name']"
},
{
"attribute": "deployment",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])"
},
{
"attribute": "inference_endpoint",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['azure_endpoint', 'api_base'])"
}
],
[
{
"_comment": "LLM Model",
"attribute": "name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'model.llm'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
}
]
"type": "inference",
"attributes": [
[
{
"_comment": "provider type ,name , deployment , inference_endpoint",
"attribute": "type",
"accessor": "lambda instance,args:'inference.azure_oai'"
},
{
"attribute": "provider_name",
"accessor": "lambda instance,args:args['provider_name']"
},
{
"attribute": "deployment",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])"
},
{
"attribute": "inference_endpoint",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['azure_endpoint', 'api_base'])"
}
],
[
{
"_comment": "LLM Model",
"attribute": "name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'model.llm'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
}
]
]
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"type": "inference",
"attributes": [
[
{
"_comment": "provider type ,name , deployment , inference_endpoint",
"attribute": "type",
"accessor": "lambda instance,args:'inference.azure_oai'"
},
{
"attribute": "provider_name",
"accessor": "lambda instance,args:args['provider_name']"
},
{
"attribute": "deployment",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])"
},
{
"attribute": "inference_endpoint",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['azure_endpoint', 'api_base'])"
}
],
[
{
"_comment": "LLM Model",
"attribute": "name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'model.llm'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
}
]
"type": "inference",
"attributes": [
[
{
"_comment": "provider type ,name , deployment , inference_endpoint",
"attribute": "type",
"accessor": "lambda instance,args:'inference.azure_oai'"
},
{
"attribute": "provider_name",
"accessor": "lambda instance,args:args['provider_name']"
},
{
"attribute": "deployment",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['engine', 'azure_deployment', 'deployment_name', 'deployment_id', 'deployment'])"
},
{
"attribute": "inference_endpoint",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['azure_endpoint', 'api_base'])"
}
],
[
{
"_comment": "LLM Model",
"attribute": "name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'model.llm'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: resolve_from_alias(instance.__dict__, ['model', 'model_name'])"
}
]
]
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"type": "retrieval",
"attributes": [
[
{
"_comment": "vector store name and type",
"attribute": "name",
"accessor": "lambda instance,args: type(instance.vectorstore).__name__"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'vectorstore.'+type(instance.vectorstore).__name__"
},
{
"attribute": "embedding_model_name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
}
],
[
{
"_comment": "embedding model name and type",
"attribute": "name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
},
{
"attribute": "type",
"accessor": "lambda instance ,args: 'model.embedding'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
}
"type": "retrieval",
"attributes": [
[
{
"_comment": "vector store name and type",
"attribute": "name",
"accessor": "lambda instance,args: type(instance.vectorstore).__name__"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'vectorstore.'+type(instance.vectorstore).__name__"
},
{
"attribute": "embedding_model_name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
}
],
[
{
"_comment": "embedding model name and type",
"attribute": "name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
},
{
"attribute": "type",
"accessor": "lambda instance ,args: 'model.embedding'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: instance.vectorstore.embeddings.model"
}
]
]
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"type": "retrieval",
"attributes": [
[
{
"_comment": "vector store name and type",
"attribute": "name",
"accessor": "lambda instance,args: type(instance._vector_store).__name__"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'vectorstore.'+type(instance._vector_store).__name__"
},
{
"attribute": "embedding_model_name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
}
],
[
{
"_comment": "embedding model name and type",
"attribute": "name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
},
{
"attribute": "type",
"accessor": "lambda instance ,args: 'model.embedding'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
}
"type": "retrieval",
"attributes": [
[
{
"_comment": "vector store name and type",
"attribute": "name",
"accessor": "lambda instance,args: type(instance._vector_store).__name__"
},
{
"attribute": "type",
"accessor": "lambda instance,args: 'vectorstore.'+type(instance._vector_store).__name__"
},
{
"attribute": "embedding_model_name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
}
],
[
{
"_comment": "embedding model name and type",
"attribute": "name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
},
{
"attribute": "type",
"accessor": "lambda instance ,args: 'model.embedding'"
},
{
"attribute": "model_name",
"accessor": "lambda instance,args: instance._embed_model.model_name"
}
]
]
}
8 changes: 6 additions & 2 deletions src/monocle_apptrace/wrap_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def update_span_with_context_input(to_wrap, wrapped_args, span: Span):
input_arg_text += wrapped_args[0].query_str
if "haystack.components.retrievers.in_memory" in package_name:
input_arg_text += get_attribute(DATA_INPUT_KEY)
span.add_event(DATA_INPUT_KEY, {QUERY: input_arg_text})
if input_arg_text:
span.add_event(DATA_INPUT_KEY, {QUERY: input_arg_text})

def update_span_with_context_output(to_wrap, return_value, span: Span):
package_name: str = to_wrap.get('package')
Expand All @@ -352,7 +353,8 @@ def update_span_with_context_output(to_wrap, return_value, span: Span):
output_arg_text += " ".join([doc.content for doc in return_value['documents']])
if len(output_arg_text) > 100:
output_arg_text = output_arg_text[:100] + "..."
span.add_event(DATA_OUTPUT_KEY, {RESPONSE: output_arg_text})
if output_arg_text:
span.add_event(DATA_OUTPUT_KEY, {RESPONSE: output_arg_text})

def update_span_with_prompt_input(to_wrap, wrapped_args, span: Span):
input_arg_text = wrapped_args[0]
Expand All @@ -366,6 +368,8 @@ def update_span_with_prompt_output(to_wrap, wrapped_args, span: Span):
package_name: str = to_wrap.get('package')
if isinstance(wrapped_args, str):
span.add_event(PROMPT_OUTPUT_KEY, {RESPONSE: wrapped_args})
if isinstance(wrapped_args, dict):
span.add_event(PROMPT_OUTPUT_KEY, wrapped_args)
if "llama_index.core.base.base_query_engine" in package_name:
span.add_event(PROMPT_OUTPUT_KEY, {RESPONSE:wrapped_args.response})

Loading

0 comments on commit 59eb190

Please sign in to comment.