You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user of LlamaIndex in a production setting, I may want to tag or add metadata to a queryEngine or invocation.
E.x. I have a queryEngine that serves a specific topic, I want to add user metadata to the query such as country of origin.
This metadata and or tags would then be made available to the callback system such that tracing solutions (such as arize-phoenix, LangFuse, Traceloop) can properly annotate the spans with these attributes for audits and cohort analysis.
LangChain reference
LangChain supports this capability natively in their chain abstractions.
Thank you for your feature request. I understand that you would like to add metadata to a queryEngine or invocation in LlamaIndex, similar to the capability in LangChain. This metadata would then be made available to the callback system for better observability in production, troubleshooting, and automatic labeling.
Currently, LlamaIndex does support adding metadata to the queryEngine and invocations. This is evident from the metadata_mode parameter in the CitationQueryEngine class's __init__ method and from_args class method. The metadata_mode parameter is an instance of the MetadataMode class, which controls how metadata is included in the citation prompt. You can find the relevant code in the CitationQueryEngine class.
However, to make this metadata available to the callback system, you would need to create new event types for them in the CBEventType enumeration. Then, you can use the on_event_start and on_event_end methods to handle these events, passing the metadata as the payload argument. Here is an example of how you can add metadata to a queryEngine event:
fromllama_index.callbacks.schemaimportCBEventType# Define your metadataquery_engine_metadata= {
'engine_id': 'engine_1',
'engine_type': 'type_1',
# Add more metadata as needed
}
# Start the queryEngine eventevent_id=callback_manager.on_event_start(
CBEventType.QUERY_ENGINE, # Assuming QUERY_ENGINE is a new event type you addedpayload=query_engine_metadata
)
# ... Perform the queryEngine operations ...# End the queryEngine eventcallback_manager.on_event_end(
CBEventType.QUERY_ENGINE,
payload=query_engine_metadata,
event_id=event_id
)
This will make the metadata available to the callback system, which can be used for better observability in production, troubleshooting, and automatic labeling. You can find more about this in the CallbackManager class.
Please note that this is a high-level suggestion and the actual implementation may vary based on your specific use case and the current structure of your code. If you need further assistance, feel free to ask.
Feature Description
As a user of LlamaIndex in a production setting, I may want to tag or add metadata to a queryEngine or invocation.
E.x. I have a queryEngine that serves a specific topic, I want to add user metadata to the query such as country of origin.
This metadata and or tags would then be made available to the callback system such that tracing solutions (such as arize-phoenix, LangFuse, Traceloop) can properly annotate the spans with these attributes for audits and cohort analysis.
LangChain reference
LangChain supports this capability natively in their chain abstractions.
example
Related community asks:
Reason
For production observability and monitoring of cohorts, filtering of traces and inferences by user and application-defined annotations
Value of Feature
Observability in production, troubleshooting, automatic labeling to be piped into evals, etc.
The text was updated successfully, but these errors were encountered: