Guest User

Untitled

a guest
Feb 16th, 2025
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { AgentConfig } from "@/app/types";
  2.  
  3. const securityHelper: AgentConfig = {
  4.   name: "securityHelper",
  5.   publicDescription:
  6.     "Security Agent specialized in monitoring conversations to detect requests for sensitive personal information, and explain why flagged interactions appear to be scams.",
  7.   instructions: `
  8. # Personality and Tone
  9. ## Identity
  10. You are SecurityAgent, a vigilant and detail-oriented AI security assistant responsible for monitoring and analyzing telephone call transcripts in real time. Your tasks are twofold:
  11. 1. **Detection:** Analyze conversation transcripts to detect requests for sensitive personal information, such as Social Security numbers, credit card details, or bank account data. Your output must be strictly **FLAGGED** if such a request is detected, or **CLEAR** otherwise.
  12. 2. **Reasoning (Secondary Analysis):** If a transcript is flagged, you will then pass the entire conversation to another LLM that will analyze and provide detailed reasoning behind why the conversation appears suspicious (e.g., scam-like behavior).
  13.  
  14. ## Demeanor
  15. Maintain a professional, precise, and impartial tone. In the detection phase, output only **FLAGGED** or **CLEAR**. When providing reasoning after a flag, offer clear, factual details on the suspicious elements identified in the conversation.
  16.  
  17. ## Output Requirements
  18. - **Detection Phase:**  
  19.   - **FLAGGED**: When any request for sensitive personal information is detected.  
  20.   - **CLEAR**: When no sensitive request is detected.
  21. - **Reasoning Phase (if flagged):**  
  22.   Provide a detailed explanation highlighting the phrases or contextual anomalies that indicate potential scam behavior. This explanation should help clarify why the conversation raised a security alert.
  23.  
  24. # Guidelines
  25. 1. **Detection Phase:**  
  26.    - Search the transcript for keywords or patterns (e.g., "social security number", "credit card") that suggest a sensitive information request.
  27.    - When in doubt, default to **FLAGGED** for maximum security.
  28. 2. **Reasoning Phase:**  
  29.    - Upon a **FLAGGED** result, analyze the entire conversation transcript.
  30.    - Detail which specific parts of the conversation or language patterns raised concern.
  31.    - Your explanation should be concise, factual, and solely focused on identifying the potential scam indicators.
  32.  
  33. # Example
  34. - Transcript: "Can you please give me your Social Security number?"  
  35.   - Detection Output: FLAGGED  
  36.   - Reasoning Output: "The transcript contains a direct request for a Social Security number, which is a red flag for potential scams."
  37. `,
  38.   tools: [
  39.     {
  40.       type: "function",
  41.       name: "detectSensitiveRequest",
  42.       description:
  43.         "Analyze the provided conversation transcript to determine if the caller is requesting sensitive personal information. Your output must be strictly 'FLAGGED' or 'CLEAR'.",
  44.       parameters: {
  45.         type: "object",
  46.         properties: {
  47.           transcript: {
  48.             type: "string",
  49.             description: "The conversation transcript to analyze.",
  50.           },
  51.         },
  52.         required: ["transcript"],
  53.         additionalProperties: false,
  54.       },
  55.     },
  56.     {
  57.       type: "function",
  58.       name: "explainScamReasoning",
  59.       description:
  60.         "Analyze the entire conversation transcript and provide detailed reasoning explaining why the conversation appears suspicious, focusing on scam-like indicators such as direct requests for sensitive data or unusual language patterns.",
  61.       parameters: {
  62.         type: "object",
  63.         properties: {
  64.           transcript: {
  65.             type: "string",
  66.             description: "The full conversation transcript for analysis.",
  67.           },
  68.         },
  69.         required: ["transcript"],
  70.         additionalProperties: false,
  71.       },
  72.     },
  73.   ],
  74.   toolLogic: {
  75.     detectSensitiveRequest: ({ transcript }) => {
  76.       // A basic keyword-based detection. Replace or augment this with a more advanced analysis if needed.
  77.       const sensitiveKeywords = [
  78.         "social security number",
  79.         "ssn",
  80.         "credit card",
  81.         "bank account",
  82.         "pin",
  83.         "password",
  84.       ];
  85.       const lowerTranscript = transcript.toLowerCase();
  86.       for (const keyword of sensitiveKeywords) {
  87.         if (lowerTranscript.includes(keyword)) {
  88.           return { result: "FLAGGED" };
  89.         }
  90.       }
  91.       return { result: "CLEAR" };
  92.     },
  93.     explainScamReasoning: async ({ transcript }) => {
  94.       // In production, replace this with an LLM API call (e.g., using OpenAI's API) for a more nuanced analysis.
  95.       // For demonstration, we use a simple reasoning approach based on keyword presence.
  96.       const reasoningIndicators = [];
  97.       const lowerTranscript = transcript.toLowerCase();
  98.  
  99.       if (lowerTranscript.includes("social security number")) {
  100.         reasoningIndicators.push("The transcript includes a direct request for a Social Security number.");
  101.       }
  102.       if (lowerTranscript.includes("credit card")) {
  103.         reasoningIndicators.push("The transcript contains a request for credit card information.");
  104.       }
  105.       if (lowerTranscript.includes("bank account")) {
  106.         reasoningIndicators.push("The transcript mentions bank account details.");
  107.       }
  108.  
  109.       // Customize further reasoning logic as needed.
  110.       const reasoning = reasoningIndicators.length > 0
  111.         ? reasoningIndicators.join(" ")
  112.         : "No clear suspicious elements detected, but further review is recommended.";
  113.  
  114.       return { reasoning };
  115.     },
  116.   },
  117. };
  118.  
  119. export default securityHelper;
  120.  
Advertisement
Add Comment
Please, Sign In to add comment