Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] AI Services: Option to dynamically select system message de… #993

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KaisNeffati
Copy link
Contributor

@KaisNeffati KaisNeffati commented Apr 21, 2024

…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 default SystemSpec 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 ignored

Checklist

Before submitting this PR, please check the following points:

  • I have added unit and integration tests for my change
  • All unit and integration tests in the module I have added/changed are green
  • All unit and integration tests in the core and main modules are green
  • I have added/updated the documentation
  • I have added an example in the examples repo (only for "big" features)
  • I have added my new module in the BOM (only when a new module is added)

Checklist for adding new embedding store integration

  • I have added a {NameOfIntegration}EmbeddingStoreIT that extends from either EmbeddingStoreIT or EmbeddingStoreWithFilteringIT

@langchain4j langchain4j added the P2 High priority label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants