Skip to main content
Set or clear additional context information for LLM interactions. The LLM context allows you to provide additional background information or available options that can be tracked alongside model invocations. This context will be added to telemetry spans as ‘gen_ai.llm.context’ and can be used for debugging or analysis in Fiddler’s platform. The context persists until explicitly changed by calling this function again with a new value, or cleared by passing None. Clearing is useful in multi-step agent workflows where context set after a RAG step should not leak into later non-RAG LLM calls. Works automatically in both synchronous and asynchronous contexts.

Parameters

Model
required
The Model instance to attach context to
str | None
default:"None"
Context string providing additional information about available options, constraints, or background for the LLM interaction. Pass None to clear any previously set context.

Example