metrics
Agent Chat Metrics Plugin
Classes
MetricsPlugin
Bases: BaseAIPlugin
Plugin for capturing metrics during AI request processing.
Functions
after_new_context_created
after_new_context_created(
request: ChatCompletionRequest,
sa_session: SASession,
neo4j_session: NJSession,
context: EleanorAIRequestContext,
) -> None
Triggered when a new AI request context is created
Parameters:
-
request
(ChatCompletionRequest
) –The chat completion request.
-
session
(SASession
) –The SQLAlchemy session object.
-
context
(EleanorAIRequestContext
) –The request context.
Returns:
-
None
–None
after_response_generation
after_response_generation(
request: ChatCompletionRequest,
sa_session: SASession,
neo4j_session: NJSession,
context: EleanorAIRequestContext,
response_txt_n: List[str],
) -> None
Executes after all LLM respones have been generated
Parameters:
-
request
(ChatCompletionRequest
) –The chat completion request.
-
session
(SASession
) –The SQLAlchemy session object.
-
context
(EleanorAIRequestContext
) –The AI request context.
-
response_txt_n
(List[str]
) –The list of generated response texts.
Returns:
-
None
–None
before_prompt_rendered
before_prompt_rendered(
request: ChatCompletionRequest,
sa_session: SASession,
neo4j_session: NJSession,
context: EleanorAIRequestContext,
chat: CanonicalChat,
) -> CanonicalChat
Triggered before the CananicalChat object is rendered into the LLM-specific prompt string.
Parameters:
-
request
(ChatCompletionRequest
) –The completion request object.
-
session
(SASession
) –The SQLAlchemy session object.
-
context
(EleanorAIRequestContext
) –The AI request context.
-
chat
(CanonicalChat
) –The chat object.
Returns:
-
CanonicalChat
(CanonicalChat
) –The updated chat object.