Add the vector policy source embedding controls

This commit is contained in:
Sung-Hyun Kang
2026-06-16 11:11:50 -05:00
committed by Archie Agarwal
parent fcef3ae9a9
commit d0d69e2ce6
6 changed files with 6 additions and 39 deletions
@@ -60,9 +60,6 @@ export const VectorEmbeddingSourceComponent: FunctionComponent<IVectorEmbeddingS
discardChanges,
onChange,
}): JSX.Element => {
// The integrated-embedding capability gate lives at the parent's call site
// (VectorEmbeddingPoliciesComponent). Don't add a gate here — gating before the
// hooks below would violate the Rules of Hooks.
const suffix = index + 1;
const [sourcePathsRaw, setSourcePathsRaw] = useState<string>(initialEmbeddingSource?.sourcePaths?.join(", ") || "");
@@ -90,10 +87,7 @@ export const VectorEmbeddingSourceComponent: FunctionComponent<IVectorEmbeddingS
const isValid = !hasAnyValue || (!sourcePathsError && !deploymentNameError && !modelNameError && !endpointError);
// Memoize the synthesized source so that equal field values yield the same object reference.
// Without this, every render would mint a new object literal, defeating the parent's
// reference-equality guard in onEmbeddingSourceChange and producing an infinite render loop
// once all five fields become valid.
// Memoize to avoid infinite render loops from parent's reference-equality check.
const source = React.useMemo<VectorEmbeddingSource | undefined>(() => {
if (!hasAnyValue || !isValid) {
return undefined;
@@ -120,12 +114,6 @@ export const VectorEmbeddingSourceComponent: FunctionComponent<IVectorEmbeddingS
React.useEffect(() => {
onChange(source, isValid);
// `onChange` is intentionally omitted from the dependency array. The parent recreates
// its inline arrow on every render, and including it here would re-fire this effect
// on every parent render — feeding back into the parent's setState and producing an
// infinite loop. The effect's behavior depends only on `source` / `isValid`, which are
// memoized from local state, so capturing a stale `onChange` reference is safe: the
// underlying state mutation (setVectorEmbeddingPolicyData) is identity-stable.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [source, isValid]);
@@ -19,8 +19,6 @@ export const getQuantizerTypeOptions = (): IDropdownOption[] => [
export const supportsQuantization = (indexType: VectorIndex["type"] | "none" | undefined): boolean =>
indexType === "quantizedFlat" || indexType === "diskANN";
// Parses a comma-separated path list, trims whitespace, drops blanks, and
// prefixes a leading "/" on each entry if it isn't there already.
export const parseSourcePaths = (raw: string): string[] => {
if (!raw) {
return [];
+2 -4
View File
@@ -35,10 +35,8 @@ export const isFullTextSearchPreviewFeaturesEnabled = (targetAccountOverride?: A
);
};
// `enableEmbeddingGenerator` is a top-level boolean on the database account
// (e.g. properties.enableEmbeddingGenerator), not an entry in
// properties.capabilities[]. It's the Foundry integrated embedding generator
// flag that gates the `embeddingSource` block inside a Container Vector Policy.
// Gates the `embeddingSource` block inside a Container Vector Policy.
// Uses the top-level `enableEmbeddingGenerator` boolean (not capabilities[]).
export const isIntegratedEmbeddingEnabled = (targetAccountOverride?: AccountOverride): boolean => {
const { databaseAccount } = userContext;
const enableEmbeddingGenerator =
+1 -11
View File
@@ -1413,25 +1413,15 @@ export interface VectorEmbedding {
/* The number of dimensions in the vector. */
dimensions: number;
/* Optional configuration for Cosmos DB integrated embeddings (server-side
embedding generation via Microsoft Foundry). When set, Cosmos DB
auto-populates the vector field from the listed source paths.
TODO: This field was added manually pending an upstream Swagger update;
re-applying `npm run generateARMClients` will overwrite it. */
/* Added manually pending upstream Swagger update; `npm run generateARMClients` will overwrite. */
embeddingSource?: VectorEmbeddingSource;
}
/* Configuration for Cosmos DB integrated embeddings. */
export interface VectorEmbeddingSource {
/* Source field paths used as input for embedding generation. */
sourcePaths: string[];
/* The Foundry deployment name. */
deploymentName: string;
/* The Foundry model name. */
modelName: string;
/* The Foundry endpoint URL. */
endpoint: string;
/* Authentication type used by Cosmos DB to call Foundry. */
authType: "Entra";
}