AI Question Node in Pathways: Difference between revisions

From FojiSoft Docs
(AI Questions)
 
 

Latest revision as of 22:44, 5 March 2025

The AI Question node in FojiSoft Pathways allows users to leverage AI for dynamic data extraction, processing, and decision-making within workflows. This updated documentation includes additional configuration options based on the latest enhancements.


Node Properties

1. Name

  • Description: A unique identifier for the AI Question node within the workflow.
  • Usage: Use a clear, descriptive name to indicate the purpose of the AI Question (e.g., "Extract Patient Data" or "Process Insurance Claim").

2. Prompt Expression

  • Type: Handlebar Template or Script
  • Description: Defines the input for the AI model. This can be a dynamic template with variables or a script for advanced logic.
  • Options:
    1. Handlebars Template: Use placeholders (e.g., {{variable_name}}) to insert dynamic values.
    2. Script: Write custom scripts in supported programming languages (e.g., Python or JavaScript) for more advanced logic.
  • Status: Required field (must be filled for the node to function).

Example (Handlebars Template):

Extract the patient's name, insurance ID, and billing amount from the following text: {{document_text}}

Example (Script):

python

CopyEdit

# Script to preprocess and extract specific fields

import json

extracted_data = extract_fields(document_text)

json.dumps(extracted_data)


3. System Prompt Expression

  • Type: Default or Script
  • Description: Allows customization of the AI model's underlying system instructions to tailor the behavior for specific tasks.
  • Options:
    1. Default: Uses pre-configured general-purpose instructions.
    2. Script: Define custom system prompts or logic for specialized tasks (e.g., creating custom data pipelines or fine-tuning results).

Example (Script):

system_instructions = "You are an AI assistant specialized in processing medical claims. Focus on extracting structured data accurately."


4. Response Variable

  • Description: Specifies the variable name where the output from the AI node will be stored.
  • Usage: Use a meaningful variable name to store outputs for downstream nodes (e.g., claim_details or invoice_data).
  • Default Value: Extracted data in structured format (JSON)

5. Response Type

  • Options: Text or JSON
  • Description: Determines the format of the AI’s output.
    1. Text: Produces a plain-text output, suitable for unstructured data or summaries.
    2. JSON: Produces structured data in JSON format, ideal for workflows requiring precise field mapping.
  • Recommendation: Use JSON for structured tasks like data extraction, and Text for general insights.

6. Max Tokens

  • Default Value: 16,384
  • Description: Sets the maximum length of the AI's output. Adjust based on the task's complexity.
  • Recommendation: Use higher tokens for complex, detailed responses and lower tokens for concise outputs.

7. Model

  • Options: Standard or Advanced
  • Description:
    1. Standard: A balanced model for general-purpose tasks.
    2. Advanced: Optimized for complex tasks, offering higher accuracy and better handling of nuanced instructions.
  • Recommendation: Use Advanced for tasks requiring precision and complexity (e.g., medical data extraction).

8. Creativity Level

  • Default Value: 1
  • Description: Controls the creative freedom of the AI. Higher values result in diverse, less deterministic responses; lower values ensure consistency.
  • Recommendation: Keep this at 1 for structured tasks requiring deterministic outputs.

9. Web Access

  • Options: Blocked or Allowed
  • Description:
    1. Blocked: The AI processes only local inputs and pre-trained knowledge.
    2. Allowed: Enables the AI to fetch real-time data from the web to supplement the response.
  • Example Use Case: Fetch current insurance policy updates or check claim submission guidelines dynamically.

How It Works

  1. Input: Provide a text or structured prompt through the Prompt Expression field.
  2. Processing: The AI interprets the input, applies any defined system-level instructions, and generates a response.
  3. Output: The response is stored in the variable defined in the Response Variable field for downstream use.

Example Usage

Scenario: Extracting Data from an Insurance Document

Prompt Expression (Handlebars Template):

Extract the following details: patient's name, insurance ID, claim amount, and service date. Text: {{uploaded_document}}

  1. Response Type: JSON

Expected Output:

{

 "patient_name": "John Doe",

 "insurance_id": "123456789",

 "claim_amount": "$500",

 "service_date": "2025-01-31"

}


Best Practices

  • Dynamic Prompts: Use placeholders in Handlebar templates for flexible input handling.
  • Structured Output: Choose JSON response type for workflows requiring precise field mapping.
  • Advanced Model: Use the Advanced model for complex tasks like medical billing or legal data extraction.
  • Web Access: Enable web access for tasks requiring real-time updates or external data validation.

The AI Question node, now enhanced with script-based prompts, advanced models, and real-time web capabilities, is a cornerstone for creating intelligent and adaptive workflows in Pathways.