diff --git a/typescript/src/agents/amazonBedrockAgent.ts b/typescript/src/agents/amazonBedrockAgent.ts index 6c13a39..99a4422 100644 --- a/typescript/src/agents/amazonBedrockAgent.ts +++ b/typescript/src/agents/amazonBedrockAgent.ts @@ -8,6 +8,7 @@ import { Logger } from "../utils/logger"; * Extends base AgentOptions with specific parameters required for Amazon Bedrock. */ export interface AmazonBedrockAgentOptions extends AgentOptions { + region?: string; agentId: string; // The ID of the Amazon Bedrock agent. agentAliasId: string; // The alias ID of the Amazon Bedrock agent. client?: BedrockAgentRuntimeClient; // Client for interacting with the Bedrock agent runtime. diff --git a/typescript/src/agents/bedrockFlowsAgent.ts b/typescript/src/agents/bedrockFlowsAgent.ts index e567685..618e9ae 100644 --- a/typescript/src/agents/bedrockFlowsAgent.ts +++ b/typescript/src/agents/bedrockFlowsAgent.ts @@ -6,6 +6,7 @@ import { } from "../types"; export interface BedrockFlowsAgentOptions extends AgentOptions { + region?: string; flowIdentifier: string; flowAliasIdentifier: string; bedrockAgentClient?: BedrockAgentRuntimeClient; diff --git a/typescript/src/agents/bedrockTranslatorAgent.ts b/typescript/src/agents/bedrockTranslatorAgent.ts index 5c94cf0..56d6d50 100644 --- a/typescript/src/agents/bedrockTranslatorAgent.ts +++ b/typescript/src/agents/bedrockTranslatorAgent.ts @@ -4,6 +4,7 @@ import { BedrockRuntimeClient, ConverseCommand, ContentBlock } from "@aws-sdk/cl import { Logger } from "../utils/logger"; interface BedrockTranslatorAgentOptions extends AgentOptions { + region?: string; sourceLanguage?: string; targetLanguage?: string; modelId?: string; diff --git a/typescript/src/agents/comprehendFilterAgent.ts b/typescript/src/agents/comprehendFilterAgent.ts index ae776cf..9d15598 100644 --- a/typescript/src/agents/comprehendFilterAgent.ts +++ b/typescript/src/agents/comprehendFilterAgent.ts @@ -1,10 +1,10 @@ import { Agent, AgentOptions } from "./agent"; import { ConversationMessage, ParticipantRole } from "../types"; import { Logger } from "../utils/logger"; -import { - ComprehendClient, - DetectSentimentCommand, - DetectPiiEntitiesCommand, +import { + ComprehendClient, + DetectSentimentCommand, + DetectPiiEntitiesCommand, DetectToxicContentCommand, DetectSentimentCommandOutput, DetectPiiEntitiesCommandOutput, @@ -29,6 +29,7 @@ type CheckFunction = (input: string) => Promise; // Extended options for ComprehendContentFilterAgent export interface ComprehendFilterAgentOptions extends AgentOptions { + region?: string; enableSentimentCheck?: boolean; enablePiiCheck?: boolean; enableToxicityCheck?: boolean; @@ -40,7 +41,7 @@ export interface ComprehendFilterAgentOptions extends AgentOptions { /** * ComprehendContentFilterAgent class - * + * * This agent uses Amazon Comprehend to analyze and filter content based on * sentiment, PII, and toxicity. It can be configured to enable/disable specific * checks and allows for the addition of custom checks. @@ -78,8 +79,8 @@ export class ComprehendFilterAgent extends Agent { this.languageCode = this.validateLanguageCode(options.languageCode) ?? 'en'; // Ensure at least one check is enabled - if (!this.enableSentimentCheck && - !this.enablePiiCheck && + if (!this.enableSentimentCheck && + !this.enablePiiCheck && !this.enableToxicityCheck) { this.enableToxicityCheck = true; } @@ -165,7 +166,7 @@ export class ComprehendFilterAgent extends Agent { * @returns A string describing the issue if sentiment is negative, null otherwise */ private checkSentiment(result: DetectSentimentCommandOutput): string | null { - if (result.Sentiment === 'NEGATIVE' && + if (result.Sentiment === 'NEGATIVE' && result.SentimentScore?.Negative > this.sentimentThreshold) { return `Negative sentiment detected (${result.SentimentScore.Negative.toFixed(2)})`; } @@ -276,11 +277,11 @@ export class ComprehendFilterAgent extends Agent { */ private validateLanguageCode(languageCode: LanguageCode | undefined): LanguageCode | undefined { if (!languageCode) return undefined; - + const validLanguageCodes: LanguageCode[] = [ 'en', 'es', 'fr', 'de', 'it', 'pt', 'ar', 'hi', 'ja', 'ko', 'zh', 'zh-TW' ]; - + return validLanguageCodes.includes(languageCode) ? languageCode : undefined; } } \ No newline at end of file diff --git a/typescript/src/agents/lexBotAgent.ts b/typescript/src/agents/lexBotAgent.ts index 6b9ac1b..246a6c9 100644 --- a/typescript/src/agents/lexBotAgent.ts +++ b/typescript/src/agents/lexBotAgent.ts @@ -12,6 +12,7 @@ import { Logger } from "../utils/logger"; * Extends base AgentOptions with specific parameters required for Amazon Lex. */ export interface LexBotAgentOptions extends AgentOptions { + region?: string; botId: string; // The ID of the Lex Bot botAliasId: string; // The alias ID of the Lex Bot localeId: string; // The locale of the bot (e.g., en_US)