04/13/2024

Fluent created Fluent details

fluent_blog_post_test_a2_processed
//! # Fluent Command Line Interface (CLI) Application.
//!
//! This crate is the entry point for the Fluent CLI, enabling interaction with Flowise AI workflows
//! via the command line. The application handles all facets of user interaction, including parsing command-line
//! arguments, managing configurations, initializing logging features, and executing the core application logic.
//!
//! # Workflow
//!
//! The execution flow of the main function in `main.rs` is as follows:
//!
//! 1. **Command-line Parsing**: Utilizes the `CliOpts` struct from the `cli` module to parse the command-line
//!    arguments provided by the user.
//! 2. **Configuration Reading**: Reads the configuration file using `read_config` function from the `config` module.
//! 3. **Verbosity Calculation**: Determines the appropriate level of verbosity for logging by examining
//!    the `--quiet` and `--verbose` command-line options.
//! 4. **Logging Initialization**: Sets up logging based on the verbosity level using the `stderrlog` crate,
//!    and considers the `--timestamp` option if provided.
//! 5. **Shell Completions Generation**: If the `--generate-completions` flag is supplied, the application
//!    will generate completion scripts for the shell specified and then exit.
//! 6. **Application Execution**: Executes the core application logic by invoking the `run` function from the
//!    `app` module, with the parsed `CliOpts` passed as an argument.
//!
//! Errors encountered during these steps are handled using the `anyhow` crate which provides a convenient
//! way to return errors with context. Any errors will cause the application to terminate with a non-zero status code.
//!
//! # Modules
//!
//! This application is composed of multiple modules, each responsible for a distinct aspect of the functionality:
//!
//! - `app`: The nucleus of the application logic; includes functions related to configuration parsing, HTTP request
//!   formation, command-line option handling, and interpreting responses from AI workflows.
//! - `cli`: Houses the definitions for parsing command-line arguments, including the `CliOpts` struct.
//! - `config`: Focuses on accessing and parsing the application's configuration file.
//! - `http`: Defines abstractions for performing HTTP requests to the AI workflow services.
//! - `utils`: A collection of auxiliary functions for file manipulation, path operations, string processing, and more.
//! - `helpers`: Provides supplementary functions and constants essential throughout the application, including template
//!   helpers for the CLI interface.
//!
//! # Logging
//!
//! The logging is facilitated by the `stderrlog` crate which provides a simple logger configured via environment variables
//! and command-line options. It is set up to log to `stderr` with varying verbosity levels controlled by the user at runtime.
//!
//! # Panics
//!
//! Panics are a Rust mechanism for handling unexpected situations. This application is designed to avoid situations
//! that might cause panics and does not intentionally contain any code that would cause unwinding (panic! functionality).
//! The `panic = 'abort'` directive could potentially be enabled for release builds to reduce binary size at the cost of
//! panicking cleanup capabilities; the directive is currently commented out.
//!
//! # Error Handling
//!
//! Error handling is critically managed via the `anyhow` crate, which provides idiomatic ways of propagating errors.
//! If errors occur during the startup or running phases of the application, they will be returned and cause the binary to
//! exit with an error status code.
//!
//! # Safety
//!
//! This application takes Rust's safety guarantees seriously. As such, the use of `unsafe` code blocks is explicitly forbidden
//! through the `#![forbid(unsafe_code)]` attribute.
//!
//! # Compiler Directives
//!
//! The application uses several compiler directives (attributes) to maintain code quality and safety:
//!
//! - `warn(warnings, rust_2018_idioms)`: Enables certain compiler warnings to encourage idiomatic Rust code.
//! - `warn(clippy::all, clippy::pedantic, clippy::restriction)`: Enables various levels of Clippy lints which are checks
//!   for common mistakes and improvements for Rust code.
//! - `allow(clippy::float_arithmetic, clippy::implicit_return, clippy::needless_return)`: Disables specific Clippy lints
//!   that are overly pedantic for this project's scope.
//! - `forbid(unsafe_code)`: Prohibits the use of unsafe Rust code blocks within the application.
//!
//! # Features
//!
//! The `Cargo.toml` file specifies the application's metadata, dependencies, development dependencies, and build profiles.
//! Notable dependencies include `structopt`, `anyhow`, `tokio`, `clap`, among others, to handle asynchronous runtime, command-line
//! parsing, error handling, and HTTP requests. The `[profile.release]` section contains configuration to optimize the release
//! builds for size and performance.
//!
//! # Usage
//!
//! To run the Fluent CLI, you must first compile the application with Cargo, then you may use the following command to interact
//! with the application:
//!
//! ```
//! fluent [FLAGS] [OPTIONS]
//! ```
//!
//! Flags and options can be determined by running `fluent --help`.
//!
//! Please consult the specific module documentation for deeper insight into each module's responsibilities and usage.

II. Installation

A. Prerequisites

  1. Supported Operating Systems:
    • Linux (Ubuntu, Debian, CentOS, and others)
    • macOS
    • Windows 10 and later
  2. Dependency Requirements:
    • Rust (latest stable version)
    • Cargo (included with Rust)
    • OpenSSL (for Linux and macOS)
    • pkg-config (for Linux)
    • libssl-dev (for Debian/Ubuntu)

B. Installation Process

  1. Downloading FluentCLI:

    • Clone the repository from GitHub:

      git clone https://github.com/your/fluentcli.git
  2. Installation Steps for Different OS:

    • Linux/macOS: Navigate to the cloned directory and run:

      cargo build --release

      The executable will be located in ./target/release/.

    • Windows: Ensure Rust is installed using rustup and run the same command in PowerShell or CMD:

      cargo build --release

      The executable will be located in .\target\release\.

C. Verifying Installation

  1. Running FluentCLI Version Command:
    • After installation, you can verify FluentCLI by running:

      ./fluent --version

      or on Windows:

      .\fluent.exe --version
  2. Troubleshooting Common Installation Issues:
    • If you encounter any issues related to missing dependencies, ensure all prerequisite software is installed and up to date.

    • For OpenSSL issues on macOS, you may need to link OpenSSL if it’s installed via Homebrew:

      export OPENSSL_ROOT_DIR=$(brew --prefix openssl)
    • On Windows, ensure you have the Visual C++ build tools installed for compiling Rust crates that require a C compiler.

//! Configuration module for the Fluent application.
//!
//! This module provides structures and functions for handling the various
//! configuration options available to the Fluent app. It allows the application
//! to manage different aspects of the configuration such as HTTP requests,
//! paths, regular expressions, defaults, styling, and skin configurations.
//! The configuration can be read from a JSON file whose path is specified via
//! an environment variable, and used to modify the behaviour of the application.

use anyhow::{Result, Context};
use serde::{Deserialize, Serialize};
use std::{fs};

use std::path::Path;

/// Structure representing the configuration for HTTP requests.
#[derive(Debug, Deserialize, Serialize)]
pub struct HttpRequestConfig {
    pub timeout: u64,
}

/// Structure representing different file paths used in the application.
#[derive(Debug, Deserialize, Serialize)]
pub struct PathsConfig {
    pub config_path: String,
}

/// Structure for regex pattern configuration.
#[derive(Debug, Deserialize, Serialize)]
pub struct RegexConfig {
    pub url_regex: String,
}

/// Structure for default configuration values.
#[derive(Debug, Deserialize, Serialize)]
pub struct DefaultsConfig {
    pub verbosity: u64,
}

/// Configuration for styling console output.
#[derive(Debug, Deserialize, Serialize)]
pub struct StylingConfig {
    pub error: String,
    pub success: String,
}

/// Configuration for customizing the appearance ("skin") of console output.
#[derive(Debug, Deserialize, Serialize)]
pub struct SkinConfig {
    pub headers_fg: String,
    pub bold_fg: String,
    pub italic_fg: String, // Added
    pub italic_bg: String, // Added
    pub bullet: String,
    pub bullet_char: char,
    pub quote_mark_fg: String, // Added
    pub code_block_margin: u8,
    pub code_block_align: String,
    pub code_block_bg: String,
    pub italic_attrs: Vec<String>,
    pub bold_attrs: Vec<String>, // Added
    pub bold_bg: String, // Added
    pub list_indent: u8, // Added
    pub list_start: String, // Added
    pub list_spacing: u8, // Added
    pub list_char: String, // Added
    pub list_margin: u8, // Added
    pub list_align: String, // Added
    pub list_bg: String, // Added
    pub list_fg: String, // Added
    pub list_padding: u8, // Added
    pub italic_fg_bg: Vec<String>,
    pub quote_mark: String,
}

/// Main configuration object that encapsulates all the settings.
#[derive(Debug, Deserialize, Serialize)]
pub struct Config {
    pub flows: Vec<Flow>,
    http_request: HttpRequestConfig,
    pub(crate) combined_input_format: String,
    pub(crate) processing_message: String,
    pub paths: PathsConfig,
    regex: RegexConfig,
    defaults: DefaultsConfig,
    styling: StylingConfig,
    pub(crate) skin_config: SkinConfig,
}

/// Represents the flow of operations, which includes HTTP requests and configuration overrides.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Flow {
    pub name: String,
    pub url: String,
    pub method: String,
    pub headers: serde_json::Value,
    #[serde(rename = "overrideConfig")]
    pub override_config: Option<serde_json::Value>,
}

/// Reads the configuration from a JSON file whose path is specified by the `FLUENT_CONFIG_PATH` environment variable.
///
/// # Errors
///
/// Returns an `Err` variant of `anyhow::Result` if:
/// - `FLUENT_CONFIG_PATH` environment variable is not set.
/// - The configuration file does not exist at the specified path.
/// - There is a failure reading the configuration file.
/// - There is an error parsing the JSON content into the `Config` structure.
///
/// # Examples
///
/// ```
/// let config = read_config().expect("Failed to read the configuration.");
/// ```
pub fn read_config() -> anyhow::Result<Config> {
    let config_path = std::env::var("FLUENT_CONFIG_PATH").expect("FLUENT_CONFIG_PATH environment variable is not set.");
    if !Path::new(&config_path).exists() {
        return Err(anyhow::anyhow!("Configuration file does not exist at {}", config_path));
    }

    let config_content = fs::read_to_string(&config_path)
        .with_context(|| format!("Failed to read config file at {}", config_path))?;

    match serde_json::from_str::<Config>(&config_content) {
        Ok(config) => {
            // Add a debug print or log here to inspect the loaded config
            //println!("Loaded config: {:?}", config);
            Ok(config)
        },
        Err(e) => {
            eprintln!("Failed to parse the configuration file: {}", e);
            // Directly print line and column information
            eprintln!("Error on line: {}, column: {}", e.line(), e.column());
            Err(e.into()) // Explicitly convert serde_json::Error into anyhow::Error
        }
    }
}

// Running Workflows
// Syntax for executing workflows
let opts = CliOpts::from_args();
let config = read_config()?;
let workflow = config.flows.iter().find(|f| f.name == opts.name).expect("Workflow not found");

// Passing parameters and inputs
let parameters = serde_json::to_value(opts.parameters)?;
let input = if let Some(input_path) = opts.input_path {
    std::fs::read_to_string(input_path)?
} else {
    String::new()
};

// Viewing and Interpreting Results
// Understanding output formats
let result = call_workflow(&workflow.url, &parameters, &input).await?;
println!("Workflow executed successfully. Result: {}", result);

// Handling errors and exceptions
if let Err(e) = call_workflow(&workflow.url, &parameters, &input).await {
    eprintln!("Error executing workflow: {}", e);
    std::process::exit(1);
}

// Generating shell completions
fn generate_bash_completion_script() -> io::Result<()> {
    // Retrieve the configuration path from the environment variable
    let config_path = env::var("FLUENT_CONFIG_PATH").unwrap_or_else(|_| "config.json".into());

    // Define the path to the bash completion script
    let script_path = PathBuf::from("fluent_cli_completion.sh");

    // Open a file to write the script
    let mut file = File::create(&script_path)?;

    // Start of the script
    writeln!(file, "#!/bin/bash")?;
    writeln!(file, "# Fluent CLI Bash Completion Script")?;
    writeln!(file, "# This script provides command line completion for Fluent CLI")?;
    writeln!(file, "#")?;
    writeln!(file, "# To use this script:")?;
    writeln!(file, "# 1. set the FLUENT_CONFIG_PATH environment variable")?;
    writeln!(file, "# 2. Make the script executable with 'chmod +x fluent_cli_completion.sh'")?;
    writeln!(file, "# 3. Source the script in your shell profile (e.g., .bashrc, .zshrc)")?;
    writeln!(file, "#    by adding the line: source /path/to/fluent_cli_completion.sh")?;
    writeln!(file, "#")?;
    writeln!(file, "# Autocompletion function")?;
    writeln!(file, "_fluent_cli_autocomplete() {{")?;
    writeln!(file, "    if [ \"$COMP_CWORD\" -eq 1 ]; then")?;
    // Use jq to extract flow names from the configuration file
    writeln!(file, "        FLOWS=$(jq -r '.flows[].name' \"{}\")", config_path)?;
    // Generate completion suggestions based on the flow names
    writeln!(file, "        COMPREPLY=($(compgen -W \"$FLOWS\" -- \"${{COMP_WORDS[COMP_CWORD]}}\"))")?;
    writeln!(file, "    fi")?;
    writeln!(file, "}}")?;
    writeln!(file, "")?;
    // Register the autocompletion function for the fluent-cli command
    writeln!(file, "complete -F _fluent_cli_autocomplete fluent-cli")?;

    println!("Bash completion script generated at: {:?}", script_path);
    println!("--------------------------------------------------------");
    println!("- Set the FLUENT_CONFIG_PATH environment variable, export FLUENT_CONFIG_PATH=location of your path to config.json");
    println!("- Make the script executable with 'chmod +x {:?}'", script_path);
    println!("- Then, source it in your shell profile (e.g., .bashrc, .zshrc) by adding:");
    println!("- source {:?}", script_path);
    println!("- Reload the shell (e.g., .bashrc, .zshrc) or restart your terminal");
    println!("- Type fluent and hit tab to see available the configured available flowiseAI worflows");

    Ok(())
}

async fn download_images_from_markdown(content: &str, destination_folder: &PathBuf) -> Result<()> {
    // Updated regex to match various image file extensions
    let image_url_regex = Regex::new(r"!\[[^\]]*\]\((https?://[^)]+\.(?:png|jpe?g|gif|svg|bmp|webp))\)").unwrap();

    for caps in image_url_regex.captures_iter(content) {
        let sanitized_name = sanitize_filename(content, 40);
        debug!("Sanitized name: {}", sanitized_name);
        if let Some(image_url) = caps.get(1).map(|m| m.as_str()) {
            debug!("Image URL: {}", image_url);
            let file_name = image_url.split('/').last().unwrap_or("image");
            debug!("File name: {}", file_name);
            let destination_path = destination_folder.join(format!("{}_{}", sanitized_name, file_name));
            debug!("downloading image from {} to {}", image_url, destination_path.display());

            // Download the image to the specified path
            if let Err(e) = download_image(image_url, &destination_path, &sanitized_name).await {
                debug!("Failed to download image from {}: {}", image_url, e);
            }
        }
    }

    Ok(())
}

fn parse_structured_response(json_response: Value) -> Result<String> {
    // Directly extract the "text" field which contains the Markdown content
    let extracted_text = json_response["text"].as_str().ok_or_else(|| anyhow!("No 'text' field found in JSON response"))?;

    // Extract the "text" field which contains the Markdown content
    // Step 2: Adjust the regex pattern to match code blocks of any language
    // The pattern now looks for ``` followed by any optional language identifier
    let code_block_pattern = Regex::new(r"(?s)```[a-zA-Z]*\s*\n(.*?)(?:\n```|$)")?;
    let mut extracted_code_blocks = Vec::new();

    // Iterate over all captures and collect the code blocks
    for cap in code_block_pattern.captures_iter(extracted_text) {
        if let Some(matched) = cap.get(1) {
            extracted_code_blocks.push(matched.as_str().trim().to_string());
        }
    }
    debug!("extracted code blocks: {:?}", extracted_code_blocks);
    if extracted_code_blocks.is_empty() {
        return Err(anyhow!("No code blocks found in Markdown content"));
    }

    // Step 3: Handle the Extracted Code Blocks
    // Join the extracted code blocks with two newlines as separator
    let concatenated_code_blocks = extracted_code_blocks.join("\n\n");
    Ok(concatenated_code_blocks)
}

VII. Troubleshooting and Support

A. Common Issues and Solutions

1. Configuration problems

If you encounter errors related to loading the configuration, ensure that the FLUENT_CONFIG_PATH environment variable is correctly set to the path of your configuration JSON file. Verify that the JSON structure matches the expected schema, including all required fields such as flows, http_request, and skin_config.

Common configuration issues include:

  • Missing or incorrect FLUENT_CONFIG_PATH environment variable.
  • JSON syntax errors in the configuration file.
  • Missing required configuration fields.
  • Incorrectly formatted values (e.g., non-string values for headers).

Solutions:

  • Double-check the FLUENT_CONFIG_PATH environment variable.
  • Validate the JSON syntax of your configuration file.
  • Refer to the documentation for required configuration fields and their formats.

2. Network and connectivity issues

If you experience network-related errors when calling Flowise AI workflows, consider the following troubleshooting steps:

  • Verify your internet connection.
  • Ensure that the workflow URLs in the configuration file are correct and accessible.
  • Check for any firewall or proxy settings that might block the HTTP requests.

Solutions:

  • Test your internet connection with other services to rule out connectivity problems.
  • Use tools like curl or postman to manually test the workflow URLs.
  • Adjust firewall or proxy settings to allow outgoing HTTP requests from the Fluent application.

B. Getting Help

1. Using the documentation

The Fluent CLI tool’s documentation provides comprehensive information on setup, configuration, and usage. It’s the first place to look for answers to common questions and guidance on how to use various features.

  • Review the README file included with the Fluent source code for an overview and setup instructions.
  • Check the inline comments and docstrings in the source code for detailed explanations of functions and modules.

2. Community and support channels

If you need further assistance, consider reaching out through community and support channels:

  • GitHub Issues: For bug reports, feature requests, or questions about the Fluent CLI, open an issue on the GitHub repository.
  • Community Forums: Look for forums or discussion boards related to Flowise AI or Rust programming for advice from the community.
  • Stack Overflow: Use the flowise-ai and rust tags to ask questions or find answers related to Fluent CLI issues.

VIII. Extending FluentCLI

A. Developing Custom Workflows

1. Guidelines for workflow development

  • Understand the Flowise AI API: Before creating a workflow, familiarize yourself with the Flowise AI API documentation to understand the capabilities and limitations.
  • Define Clear Objectives: Each workflow should have a clear purpose and objective. Define what your workflow will accomplish and the steps required to achieve this.
  • Use Configurable Parameters: Make your workflows flexible by allowing users to pass parameters through the CLI. This can include AI model settings, input/output formats, and other workflow-specific options.
  • Error Handling: Implement robust error handling to manage API failures, incorrect user inputs, and other potential issues. Provide clear error messages to help users troubleshoot problems.
  • Optimize for Performance: Consider the performance implications of your workflow. Optimize network requests, data processing, and any heavy computations to ensure a smooth user experience.
  • Documentation: Document your workflow thoroughly. Include information on its purpose, configuration options, required inputs, and example usage.

2. Sharing and distributing workflows

  • GitHub Repository: Share your workflows by creating a GitHub repository. Include a README file with detailed instructions on how to use the workflow, configuration options, and examples.
  • FluentCLI Community: Engage with the FluentCLI community by sharing your repository link in community forums, discussion boards, or social media. Feedback from the community can provide valuable insights and improvements.
  • Versioning: Use semantic versioning for your workflows. This helps users understand the changes and compatibility between different versions.
  • Licensing: Choose an appropriate open-source license for your workflow. This informs users how they can use, modify, and distribute your workflow.

B. Contributing to FluentCLI

1. How to contribute code or documentation

  • Fork the Repository: Start by forking the FluentCLI GitHub repository to your account.
  • Create a Feature Branch: Create a new branch in your fork for your contribution. Use a descriptive name that reflects the contribution, such as feature-add-image-processing-workflow.
  • Develop and Test: Make your changes in the feature branch. Ensure that you test your changes thoroughly and follow the coding standards and practices of the FluentCLI project.
  • Update Documentation: If you’re adding new features or making changes that affect how users interact with FluentCLI, update the documentation accordingly.
  • Submit a Pull Request: Once you’re satisfied with your contribution, submit a pull request to the main FluentCLI repository. Provide a clear description of the changes and any other relevant information.
  • Code Review: Your pull request will be reviewed by the project maintainers. Be open to feedback and be prepared to make further changes based on their suggestions.

2. Reporting bugs and requesting features

  • Use GitHub Issues: Report bugs or request new features through the GitHub Issues section of the FluentCLI repository. Before creating a new issue, search existing issues to avoid duplicates.
  • Provide Detailed Information: When reporting a bug, include detailed information about the issue, steps to reproduce, expected behavior, and actual behavior. If possible, include screenshots or error messages.
  • Feature Requests: For feature requests, describe the feature, its potential benefits, and how it could be implemented within the existing FluentCLI framework.
  • Engage with the Community: Participate in discussions on open issues and pull requests. Your insights and feedback can contribute to the overall improvement of FluentCLI.

//! # Security Considerations
//!
//! When using FluentCLI, it's crucial to ensure that sensitive information is protected and that
//! the tool is securely configured. Here are some best practices:
//!
//! ## Protecting Sensitive Information
//!
//! - Always use secure connections (HTTPS) when calling AI workflows to prevent eavesdropping.
//! - Store sensitive configuration details, such as API keys or tokens, in environment variables
//!   or secure configuration files with restricted access, rather than hardcoding them in scripts.
//! - Use the `--system-prompt-override` and `--system-prompt-override-file` options cautiously,
//!   ensuring that any dynamic content inserted into workflows does not expose sensitive information.
//!
//! ## Securely Configuring FluentCLI
//!
//! - Regularly update FluentCLI to the latest version to incorporate security fixes and improvements.
//! - Limit the permissions of the user running FluentCLI to only what is necessary for its operation.
//! - Review the configuration files and command-line options to ensure no unintended permissions or
//!   data exposures are configured.
//!
//! # Performance Optimization
//!
//! Efficient use of FluentCLI not only improves the performance of your workflows but also minimizes
//! resource usage, which is critical in production environments.
//!
//! ## Efficiently Configuring and Running Workflows
//!
//! - Optimize the configuration of your workflows by removing unnecessary steps or consolidating
//!   multiple operations where possible.
//! - Use the `--include-extra-data` flag judiciously to avoid sending unnecessary data in requests,
//!   which can increase processing time and bandwidth usage.
//!
//! ## Minimizing Resource Usage
//!
//! - When possible, batch process data with FluentCLI to reduce the overhead of initializing and
//!   tearing down workflow executions.
//! - Monitor the resource usage of FluentCLI and the underlying Flowise AI workflows to identify
//!   bottlenecks or areas for optimization, such as memory usage or network bandwidth.
//! - Consider the scalability of your infrastructure to ensure it can handle the load generated by
//!   FluentCLI, especially in high-demand scenarios.
//!
//! Implementing these best practices will help secure your FluentCLI usage and optimize its performance
//! and resource utilization.

Conclusion

A. Recap of FluentCLI Capabilities

FluentCLI offers a comprehensive suite of functionalities designed to enhance the interaction with Flowise AI workflows through the command line. It provides a robust Rust implementation that includes features such as configuration management, HTTP request handling, CLI processing, response parsing, and output formatting. With FluentCLI, users can easily read and parse configurations, generate bash completion scripts, handle shell completions, process command-line inputs and environment variables, construct and send HTTP POST requests, download and rename image files, generate HTML clients for interactive conversations, and format inputs from various sources.

B. Encouraging Community Participation

  1. Contributing to the Project

    We warmly welcome contributions from the community to help improve FluentCLI. Whether you’re interested in fixing bugs, adding new features, or improving documentation, your contributions are highly valued. To get started, please check out our GitHub repository, review the open issues for areas where you can contribute, and submit pull requests with your changes. We encourage contributors to discuss their ideas and proposals with the community to gather feedback and support.

  2. Providing Feedback and Suggestions

    Your feedback and suggestions are crucial to the ongoing development and enhancement of FluentCLI. We encourage users to share their experiences, report issues, and suggest improvements through our GitHub issues page or community forums. Whether it’s a feature request, usability improvement, or any other feedback, your insights help us make FluentCLI better for everyone.

Appendices

A. Reference Materials

1. Command-line options and flags

The fluent CLI tool supports a variety of command-line options and flags to control its behavior. Below is a comprehensive list of these options:

  • --name <NAME>: Required. Specifies the name of the workflow to interact with.
  • --question <QUESTION>: Optional. A question to pass along to the specified workflow.
  • --outline-path <OUTLINE_PATH>: Optional. Specifies the path to an outline file to be included in the workflow input.
  • --context <CONTEXT>: Optional. Provides additional context to the workflow.
  • --generate-completions: Generates a Bash shell autocompletion script based on the configured workflows and exits.
  • --parse-structured: Instructs fluent to parse structured data in the workflow response.
  • --system-prompt-override <TEXT>: Overrides the system prompt with the specified text.
  • --system-prompt-override-file <FILE_PATH>: Specifies a file containing text to override the system prompt.
  • --image-folder-path <FOLDER_PATH>: Designates a folder path where images referenced in the workflow response will be downloaded.
  • --markdown: Enables Markdown rendering for the workflow response.
  • --include-extra: Includes extra data in the HTTP request sent to the workflow.
  • --generate-html-chat-client: Generates an HTML chat client for interactive conversations with the specified Flowise AI chatbot.

2. Configuration file schema

The configuration for fluent is defined in a JSON file. The schema includes the following keys:

  • flows: An array of objects, each representing a workflow configuration. Each object includes:
    • name: The name of the workflow.
    • url: The URL to call the workflow.
    • method: HTTP method to use (e.g., POST).
    • headers: An object containing HTTP headers to include in the request.
    • overrideConfig: An object containing any workflow-specific configuration overrides.
  • http_request: An object containing global HTTP request settings, such as timeout.
  • combined_input_format: A string defining the format for combining various inputs into a single request payload.
  • processing_message: A message displayed while processing the workflow request.
  • paths: An object specifying paths used by fluent, like the configuration file path.
  • regex: Contains regular expressions used by fluent, such as URL validation patterns.
  • defaults: Specifies default values for various settings.
  • styling: Defines styling options for console output.
  • skin_config: Configures the appearance of terminal output, including colors and alignment.

B. Frequently Asked Questions (FAQ)

  1. How do I specify a workflow? Use the --name option followed by the name of the workflow you wish to interact with.

  2. Can I use fluent without a configuration file? No, fluent requires a configuration file to define workflows and other settings.

  3. How do I generate a Bash completion script? Run fluent with the --generate-completions flag. This will output a script that you can source in your shell profile.

  4. What formats can I use for the context and outline-path options? Both options expect file paths pointing to text files containing the respective data.

  5. How do I include images in my Markdown content? Use the --image-folder-path option to specify a directory where images will be downloaded and stored.

C. Glossary of Terms

  • Workflow: A predefined sequence of operations or tasks executed by Flowise AI based on input provided through fluent.
  • Configuration File: A JSON file used by fluent to store settings, including workflow definitions and HTTP request configurations.
  • CLI (Command-Line Interface): A text-based interface used to interact with software programs such as fluent.
  • HTTP Request: A request sent over the Hypertext Transfer Protocol (HTTP) from fluent to a Flowise AI workflow.
  • Markdown: A lightweight markup language with plain-text formatting syntax, supported by fluent for formatting workflow responses.

Back to Fluent Generated Content Examples

Leave a comment