mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: refine nlp pattern type check
This commit is contained in:
parent
89c46e9948
commit
a8666ceb57
@ -65,15 +65,13 @@ export type NlpPatternMatchResult = {
|
|||||||
matchedPattern: NlpPattern[];
|
matchedPattern: NlpPattern[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isNlpPattern(
|
export function isNlpPattern(pattern: NlpPattern) {
|
||||||
pattern: unknown,
|
|
||||||
): pattern is { entity: string; match: 'entity' | 'value' } {
|
|
||||||
return (
|
return (
|
||||||
(typeof pattern === 'object' &&
|
(typeof pattern === 'object' &&
|
||||||
pattern !== null &&
|
pattern !== null &&
|
||||||
'entity' in pattern &&
|
'entity' in pattern &&
|
||||||
'match' in pattern &&
|
'match' in pattern &&
|
||||||
(pattern as any).match === 'entity') ||
|
pattern.match === 'entity') ||
|
||||||
(pattern as any).match === 'value'
|
pattern.match === 'value'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user