Skip to content

Commit

Permalink
fix missing field
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelcroi committed Jan 10, 2025
1 parent 237cd47 commit 2086ac5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions typescript/src/agents/amazonBedrockAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions typescript/src/agents/bedrockFlowsAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "../types";

export interface BedrockFlowsAgentOptions extends AgentOptions {
region?: string;
flowIdentifier: string;
flowAliasIdentifier: string;
bedrockAgentClient?: BedrockAgentRuntimeClient;
Expand Down
1 change: 1 addition & 0 deletions typescript/src/agents/bedrockTranslatorAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 11 additions & 10 deletions typescript/src/agents/comprehendFilterAgent.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -29,6 +29,7 @@ type CheckFunction = (input: string) => Promise<string | null>;

// Extended options for ComprehendContentFilterAgent
export interface ComprehendFilterAgentOptions extends AgentOptions {
region?: string;
enableSentimentCheck?: boolean;
enablePiiCheck?: boolean;
enableToxicityCheck?: boolean;
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)})`;
}
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions typescript/src/agents/lexBotAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2086ac5

Please sign in to comment.