[DRAFT] Enhance No. Series Copilot with semantic search capabilities #3578
+1,137
−41
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.
This pull request introduces semantic search capabilities to the No. Series Copilot, significantly improving its ability to understand user requests and identify relevant number series configurations.
Key Enhancements:
No. Series Cop. Semantic Impl.
(NoSeriesCopilot/src/Copilot/Search/Semantic/NoSeriesCopSemanticImpl.Codeunit.al
), dedicated to handling semantic comparisons using vector embeddings. This includes functions likeIsRelevant
,CalculateSemanticNearness
, andGetVectorFromText
.No. Series Semantic Vocabulary
table (NoSeriesCopilot/src/Copilot/Search/Semantic/NoSeriesSemanticVocabulary.Table.al
) as a temporary solution to store text payloads and their corresponding vector embeddings (InsertRecord
,SaveVectorText
,LoadVectorText
). This table serves three main purposes:RemoveTextPart(TableMetadata.Name, '& ') + ' ' + Field.FieldName
).GetEmbeddingsFromVocabulary
) to avoid redundant calls to the Azure OpenAI embedding endpoint (GetAzureOpenAIEmbeddings
) if an embedding for a given text already exists. New embeddings are temporarily stored and then persisted viaUpdateSemanticVocabulary
.No. Series Cop. Add Intent
,No. Series Cop. Change Intent
) and the core tools implementation (No. Series Cop. Tools Impl.
) to utilize semantic search. TheToolsImpl.IsRelevant
function now orchestrates both classic text matching (No. Series Text Match Impl.
) and semantic comparison (No. Series Cop. Semantic Impl.
) when filtering setup tables and fields based on extracted user entities (seeListOnlyRelevantNoSeriesFields
andListOnlyRelevantNoSeriesFieldsWithExistingNumberSeries
).Semantic Search Flow:
The semantic search process enhances the copilot's ability to match user intent with specific number series fields:
Comparison: Before vs. After Semantic Search
This section demonstrates the improved understanding and relevance achieved with semantic search compared to the previous implementation relying solely on classic text matching.
Example Request:
create number series for products
Without Semantic Search (Classic Text Match Only):
With Semantic Search:
Additional Improvements:
NoSeriesCopilotImpl.Codeunit.al
where the intent check (if Intent = AddNoSeriesIntent.GetName() then
) was not functioning correctly. This prevented theCheckIfExpectedNoSeriesCount
validation from running, which compares the number of requested number series against the number actually generated by the LLM. This fix ensures more reliable validation and helps prevent incomplete suggestions.ExcludeExistingNoSeriesIfNewWhereGenerated
to refine the final suggestions presented to the user. Semantic search can identify more existing, already-configured number series relevant to a query. To avoid confusion, if any new number series are generated based on the user's request, only these new suggestions will be displayed. Existing number series will only be shown if no new series were generated.Summary:
This commit significantly enhances the No. Series Copilot by adding a semantic understanding layer. It lays the groundwork for more intuitive interactions and accurate results, focusing on semantic capabilities and future extensibility while providing a temporary mechanism for vector storage and retrieval. Temporary methods and storage solutions include clear TODOs for future refactoring once platform support is available.
Work Item(s)
Fixes #2107
Fixes AB#571185