Context Injection
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.
Injecting 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:
- temporary: Context that is only applied in the preceding assistant response.
- persistent: Context that is applied to all subsequent messages in the Chat.
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:
Temporary
Persistent
This context helps EVI respond appropriately to the most recent user action but does not persist beyond the next interaction.
Clearing injected context
Context you have injected can be cleared by sending a Session Settings message with a context field of null
:
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.