init.py

Overview

This init.py file serves as a centralized module for defining various enumerations and constants used throughout the InfiniFlow application. It primarily defines strongly-typed enumerations (using Python's Enum, IntEnum, and StrEnum) that represent fixed sets of categorical values related to system statuses, user roles, file types, task statuses, parsing types, and other domain-specific classifications.

By collecting these enums and constants in one module, the file promotes consistency and maintainability across the codebase when dealing with these fixed categories. This file does not contain executable logic or functions but provides essential building blocks used by other components of the system.


Detailed Explanations

Imported Modules


Classes (Enumerations)


StatusEnum (Enum)

Represents a generic validation status with two possible states.

Member

Value

Description

VALID

"1"

Indicates a valid state

INVALID

"0"

Indicates an invalid state

Usage example:

if status == StatusEnum.VALID:
    print("Status is valid.")

UserTenantRole (StrEnum)

Defines the role of a user within a tenant or organization.

Member

Value

Description

OWNER

'owner'

User with owner privileges

ADMIN

'admin'

Administrator user

NORMAL

'normal'

Regular user

INVITE

'invite'

Invited user (pending status)


TenantPermission (StrEnum)

Represents permission scopes for tenants.

Member

Value

Description

ME

'me'

Permission for self

TEAM

'team'

Permission for team


SerializedType (IntEnum)

Specifies serialization formats supported by the system.

Member

Value

Description

PICKLE

1

Python pickle format

JSON

2

JSON format


FileType (StrEnum)

Enumerates supported file types within the system.

Member

Value

Description

PDF

'pdf'

PDF documents

DOC

'doc'

Document files (e.g., Word)

VISUAL

'visual'

Visual media files (images, diagrams)

AURAL

'aural'

Audio files

VIRTUAL

'virtual'

Virtual files (system-specific)

FOLDER

'folder'

Folder type (container)

OTHER

'other'

Other/unspecified file types

Constant:


LLMType (StrEnum)

Specifies different Large Language Model (LLM) task types or interfaces.

Member

Value

Description

CHAT

'chat'

Chat-based LLM interaction

EMBEDDING

'embedding'

Embedding generation

SPEECH2TEXT

'speech2text'

Speech to text transcription

IMAGE2TEXT

'image2text'

Image to text conversion

RERANK

'rerank'

Ranking or reranking tasks

TTS

'tts'

Text to speech synthesis


ChatStyle (StrEnum)

Defines stylistic modes for chat interactions.

Member

Value

Description

CREATIVE

'Creative'

Creative style responses

PRECISE

'Precise'

Precise and concise answers

EVENLY

'Evenly'

Balanced style

CUSTOM

'Custom'

Custom user-defined style


TaskStatus (StrEnum)

Represents the lifecycle states of an asynchronous or background task.

Member

Value

Description

UNSTART

"0"

Task not started

RUNNING

"1"

Task currently running

CANCEL

"2"

Task was cancelled

DONE

"3"

Task completed successfully

FAIL

"4"

Task failed

Constant:


ParserType (StrEnum)

Defines types of document or content parsers supported.

Member

Value

Description

PRESENTATION

"presentation"

Presentation documents

LAWS

"laws"

Legal documents

MANUAL

"manual"

Manuals and guides

PAPER

"paper"

Academic papers

RESUME

"resume"

Resume documents

BOOK

"book"

Books

QA

"qa"

Question-Answer pairs

TABLE

"table"

Tabular data

NAIVE

"naive"

Naive/simple parsing

PICTURE

"picture"

Image-based parsing

ONE

"one"

Single-page parsing

AUDIO

"audio"

Audio transcription parsing

EMAIL

"email"

Email content

KG

"knowledge_graph"

Knowledge graph parsing

TAG

"tag"

Tagging content


FileSource (StrEnum)

Indicates the origin or storage location of files.

Member

Value

Description

LOCAL

"" (empty)

Local file system

KNOWLEDGEBASE

"knowledgebase"

Files stored in KB

S3

"s3"

Amazon S3 cloud storage


CanvasType (StrEnum)

Specifies the type of canvas or UI component used in the system.

Member

Value

Description

ChatBot

"chatbot"

Interactive chat interface

DocBot

"docbot"

Document processing interface


CanvasCategory (StrEnum)

Categorizes canvas types by their functional domain.

Member

Value

Description

Agent

"agent_canvas"

Canvas for agent-related tasks

DataFlow

"dataflow_canvas"

Canvas for dataflow visualization

Constant:


MCPServerType (StrEnum)

Defines types of server protocols used for message connection protocols (MCP).

Member

Value

Description

SSE

"sse"

Server-Sent Events protocol

STREAMABLE_HTTP

"streamable-http"

HTTP streaming protocol

Constant:


Constants


Important Implementation Details


Interactions with Other System Components

This file acts as a foundational enumeration module that other parts of the InfiniFlow application import to maintain consistency in handling fixed categories and states.


Usage Examples

from __init__ import UserTenantRole, TaskStatus, FileType

# Check user role
def is_admin(user_role):
    return user_role == UserTenantRole.ADMIN

# Validate file type
def is_valid_file_type(file_type):
    return file_type in VALID_FILE_TYPES

# Track task progress
def update_task_status(task, status):
    if status in VALID_TASK_STATUS:
        task.status = status

Mermaid Class Diagram

classDiagram
    class StatusEnum {
        <<Enum>>
        +VALID: str
        +INVALID: str
    }
    class UserTenantRole {
        <<StrEnum>>
        +OWNER: str
        +ADMIN: str
        +NORMAL: str
        +INVITE: str
    }
    class TenantPermission {
        <<StrEnum>>
        +ME: str
        +TEAM: str
    }
    class SerializedType {
        <<IntEnum>>
        +PICKLE: int
        +JSON: int
    }
    class FileType {
        <<StrEnum>>
        +PDF: str
        +DOC: str
        +VISUAL: str
        +AURAL: str
        +VIRTUAL: str
        +FOLDER: str
        +OTHER: str
    }
    class LLMType {
        <<StrEnum>>
        +CHAT: str
        +EMBEDDING: str
        +SPEECH2TEXT: str
        +IMAGE2TEXT: str
        +RERANK: str
        +TTS: str
    }
    class ChatStyle {
        <<StrEnum>>
        +CREATIVE: str
        +PRECISE: str
        +EVENLY: str
        +CUSTOM: str
    }
    class TaskStatus {
        <<StrEnum>>
        +UNSTART: str
        +RUNNING: str
        +CANCEL: str
        +DONE: str
        +FAIL: str
    }
    class ParserType {
        <<StrEnum>>
        +PRESENTATION: str
        +LAWS: str
        +MANUAL: str
        +PAPER: str
        +RESUME: str
        +BOOK: str
        +QA: str
        +TABLE: str
        +NAIVE: str
        +PICTURE: str
        +ONE: str
        +AUDIO: str
        +EMAIL: str
        +KG: str
        +TAG: str
    }
    class FileSource {
        <<StrEnum>>
        +LOCAL: str
        +KNOWLEDGEBASE: str
        +S3: str
    }
    class CanvasType {
        <<StrEnum>>
        +ChatBot: str
        +DocBot: str
    }
    class CanvasCategory {
        <<StrEnum>>
        +Agent: str
        +DataFlow: str
    }
    class MCPServerType {
        <<StrEnum>>
        +SSE: str
        +STREAMABLE_HTTP: str
    }

Summary

The init.py module is a foundational configuration file defining all the key enumerations and constants that represent core categorical data used throughout the InfiniFlow project. It ensures data consistency, reduces errors, and improves code clarity by leveraging typed enumerations for roles, file types, statuses, and more, thereby supporting multiple system components ranging from authentication and file management to AI integrations and UI canvas management.