[FEATURE] AI Services: Option to dynamically select system message de… #993
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…pending on the user message #956
Context
#956
Change
There are two annotations,
@RegisterSystemSpecs
and@SystemSpec
, which facilitate dynamic selection of system messages to accompany user inputs when interfacing with a Large Language Model (LLM). This dynamic selection process involves an initial query to the AI model to determine the most relevant system specification. Should no relevant system be found, a defaultSystemSpec
is utilized, ensuring that a response is always generated.This approach mirrors the methodology used in Langchain, which also involves querying the LLM to select the most appropriate system message. The prompt used for this operation is consistent with the one employed by Langchain.
Using a vector search with a TextClassifier for this feature do not seems to fit to this use case because vector search always returns a result, which may not always align with the relevance required for effective system message selection. In contrast, a direct query to the AI allows for a determination of whether a suitable
SystemSpec
exists for the given user message.Several tests have been conducted to ensure robustness
When the
@SystemMessage
annotation or a System Message Provider is used in conjunction with@RegisterSystemSpecs
or a System Spec Provider, the latter are overridden and ignoredChecklist
Before submitting this PR, please check the following points:
Checklist for adding new embedding store integration