mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: apply feedback
This commit is contained in:
parent
06b4c1a810
commit
2a08218b53
@ -30,7 +30,7 @@ export class ContextVarService extends BaseService<
|
||||
* Retrieves a mapping of context variable names to their corresponding `ContextVar` objects for a given block.
|
||||
*
|
||||
* @param {Block | BlockFull} block - The block containing the capture variables to retrieve context variables for.
|
||||
* @returns {Promise<Record<string, ContextVar>>} A promise that resolves to a record mapping context variable names to `ContextVar` objects.
|
||||
* @returns {Promise<Record<string, ContextVar | undefined>>} A promise that resolves to a record mapping context variable names to `ContextVar` objects.
|
||||
*/
|
||||
async getContextVarsByBlock(
|
||||
block: Block | BlockFull,
|
||||
|
@ -116,9 +116,17 @@ export class ConversationService extends BaseService<
|
||||
|
||||
const context_var = contextVars[capture.context_var];
|
||||
const { permanent, pattern = '' } = context_var || {};
|
||||
const isValidContextValue = new RegExp(pattern.slice(1, -1)).test(
|
||||
`${contextValue}`,
|
||||
);
|
||||
const isValidContextValue = (() => {
|
||||
try {
|
||||
return new RegExp(pattern.slice(1, -1)).test(`${contextValue}`);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`Invalid regex pattern for ContextVar[${capture.context_var}]: ${pattern}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
if (isValidContextValue) {
|
||||
if (profile.context?.vars && permanent) {
|
||||
this.logger.debug(
|
||||
|
Loading…
Reference in New Issue
Block a user