prompts.py

Overview

The prompts.py file defines a set of string constants that serve as carefully crafted prompt templates for an AI-driven reasoning and information extraction system within the InfiniFlow project. Its primary purpose is to provide structured instructions and special tokens for guiding an AI agent through multi-step question answering processes that rely on iterative web search and fact extraction.

This file does not contain any executable code such as classes or functions; instead, it supplies essential textual templates used elsewhere in the system to orchestrate complex reasoning workflows. The prompts include:

The design supports a chain-of-thought style interaction with external search tools, enabling multi-hop question answering and precise information retrieval.


Detailed Explanation of Constants and Prompt Templates

Special Tokens and Limits

Constant

Description

BEGIN_SEARCH_QUERY

Token marking the start of a search query issued by the AI.

END_SEARCH_QUERY

Token marking the end of the search query.

BEGIN_SEARCH_RESULT

Token marking the start of the returned search results from the system.

END_SEARCH_RESULT

Token marking the end of the search results.

MAX_SEARCH_LIMIT

Integer limit (6) indicating the maximum number of search queries the AI is allowed to issue.

These tokens are used to clearly delimit search queries and results embedded within prompt-response cycles, helping the system parse and separate actions from observations.


REASON_PROMPT

A multi-line string prompt that instructs the reasoning AI agent on how to approach answering user questions by decomposing them, querying a search system, analyzing results, and synthesizing a final answer.

Key elements:

Usage Example

An AI agent receiving this prompt would:


RELEVANT_EXTRACTION_PROMPT

A prompt template used by an information extraction module that processes search results to extract the single most relevant fact answering a specific query.

Key elements:

Usage Example

Given:

The module should output:

Final Information
Martin Campbell is a New Zealand film and television director.

Important Implementation Details and Algorithms


Interaction with Other Parts of the System

This modular design supports extensibility, allowing the system to plug in different search backends or reasoning engines by consistently using these prompts and tokens.


Mermaid Diagram: File Structure and Prompt Relationships

flowchart TD
    A[User Question Input] --> B[Reasoning Agent]
    B -->|Issues Search Query| C[Search System]
    C -->|Returns Search Results| D[Extraction Module]
    D -->|Extracted Fact| B
    B -->|Final Answer| E[User]

    subgraph prompts.py Content
        direction TB
        REASON_PROMPT["REASON_PROMPT\n- Instructions for multi-hop reasoning\n- Search query/result token usage\n- Examples and rules"]
        EXTRACTION_PROMPT["RELEVANT_EXTRACTION_PROMPT\n- Instructions for fact extraction\n- Output formatting rules"]
        TOKENS["Special Tokens & Limits\n- BEGIN/END_SEARCH_QUERY\n- BEGIN/END_SEARCH_RESULT\n- MAX_SEARCH_LIMIT"]
    end

    B --> REASON_PROMPT
    D --> EXTRACTION_PROMPT
    B --> TOKENS
    C --> TOKENS

Summary

prompts.py is a foundational utility file that defines the core prompt templates and tokens used by the InfiniFlow AI system to orchestrate multi-step reasoning and fact extraction through iterative web search. It contains no executable logic but provides the natural language scaffolding that enables AI components to interact with search tools and extract precise answers effectively. The file enables modular, explainable, and controlled AI workflows critical for advanced question answering applications.