Context Injection
Guide to injecting context during an EVI Chat session.
Context injection supplies the model with additional information so it can tailor its responses without the user needing to explicitly instruct EVI.
EVI supports context injection via a Session Settings message. The context field in a Session Settings message allows you to silently add information to the conversation, guiding EVI without triggering a response. This context is appended to the end of each user_message, ensuring that it is consistently referenced throughout the session.
Injected context can be used to remind EVI of its role, keep important details active in the conversation, or add relevant updates as needed. This method is ideal for adapting EVI’s tone or focus based on real-time changes, helping it respond more accurately without requiring repetitive input from the user.
Injected context is only active within the current session. If a chat is resumed, any previously injected context will not be carried over and must be re-injected if necessary.
Setting up context
To inject context, send a Session Settings message with a context
object that includes two fields:
- text: The content you want to inject, providing specific guidance for EVI. For example, if the user expresses frustration, you might set the context to encourage an empathetic response.
- type: Defines how long the context remains active. Options include:
- persistent: Appended to all user messages throughout the session, ideal for consistent guidance.
- temporary: Applies only to the next user message, suitable for one-time adjustments.
- editable: Allows updates to the context over time, useful for evolving needs.
If
type
is not specified, it defaults totemporary
.
Example: Supporting travel planning context
To tailor EVI’s responses for a travel planning scenario, you can inject context at different persistence levels based on user actions and session needs:
Persistent
Editable
Temporary
This context provides EVI with a consistent focus on vacation planning, helping it to make relevant suggestions or ask guiding questions throughout the session.
Managing context during a session
- Clearing context: Send a Session Settings message with “context”: null to remove the injected context when it’s no longer needed.
- Updating context dynamically: Use editable context if you need to adjust context over time, allowing for real-time updates without additional messages.