reasonchain


Namereasonchain JSON
Version 0.2.16 PyPI version JSON
download
home_pagehttps://github.com/sunnybedi990/reasonchain
SummaryA modular AI reasoning library for building intelligent agents.
upload_time2025-01-04 20:34:20
maintainerNone
docs_urlNone
authorBaljindersingh Bedi
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements numpy scipy scikit-learn torch tqdm faiss-cpu pymilvus pinecone qdrant-client weaviate-client transformers ollama groq openai matplotlib tabula-py camelot-py pymupdf sentence-transformers tensorflow_hub gensim layoutparser pdf2image pytesseract pdfplumber fastapi jpype1 llama-index-core llama-parse llama-index-readers-file python-dotenv opencv-python datasets python-pptx moviepy SpeechRecognition ebooklib bs4 python-docx whisper
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **ReasonChain**

**ReasonChain** is a modular and extensible AI reasoning library for creating intelligent agents capable of executing advanced reasoning processes. It supports **Chain of Thought (CoT)** reasoning, **Tree of Thought (ToT)** reasoning, **Parallel Chains**, and integrates with **Retrieval-Augmented Generation (RAG)** for enhanced knowledge management.

---

### **Features**

1. **Customizable Reasoning Pipelines**:
   - Seamless integration of **Chain of Thought (CoT)**, **Tree of Thought (ToT)**, Parallel Chains, and Hybrid Pipelines.
   - Facilitates task decomposition, execution, and validation.

2. **RAG Integration**:
   - Retrieve and augment responses using long-term memory stored in vector databases like FAISS.

3. **Short-term and Long-term Memory**:
   - Session-based short-term memory for reasoning chains.
   - Persistent long-term memory powered by FAISS.

4. **LLM Compatibility**:
   - Supports OpenAI GPT, Llama, and other models for robust reasoning and summarization.

5. **Utility Tools**:
   - Adaptive complexity evaluation for reasoning tasks.
   - Centralized model management for handling LLM interactions.

6. **Supported File Types**:
   - Extract text, tables, and figures from a wide range of file formats, including:
     - **Documents**: PDF, Word, RTF, Markdown, HTML, LaTeX.
     - **Spreadsheets**: Excel, CSV.
     - **Multimedia**: Images, Videos, Audio.
     - **E-books**: EPUB, MOBI.
   - Provides modular extractors tailored for each file type, ensuring efficient data retrieval.

7. **Domain Templates**:
   - Pre-built reasoning templates tailored for specific industries and applications:
     - **Customer Support**: Automates handling of customer inquiries and escalations.
     - **Healthcare**: Assists in diagnosis recommendations and treatment plans.
     - **Finance**: Analyzes trends, generates financial reports, and forecasts.
     - **Retail**: Provides insights on inventory optimization and customer behavior.
     - **Real Estate**: Summarizes market data and assists in property evaluations.
   - Fully customizable to meet domain-specific requirements.
   - Simplifies the setup of agents for new use cases.

---

## **Installation**

### 1. Install via pip
You can install **ReasonChain** directly from PyPI:
```bash
pip install reasonchain
```

### 2. Clone the Repository (for development)
Alternatively, clone the repository to access examples and editable source code:
```bash
git clone https://github.com/sunnybedi990/reasonchain.git
cd reasonchain
```

### 3. Install Dependencies
```bash
pip install -r requirements.txt
```

### 4. Install as an Editable Package
```bash
pip install -e .
```

### 5. Configure API Keys
Create a `.env` file with your API keys:
```env
# Authentication Keys
LLAMA_CLOUD_API_KEY=          # API key for LLama Parser
OPENAI_API_KEY=               # API key for OpenAI
GROQ_API_KEY=                 # API key for Groq

# Vector Database Configuration
VECTOR_DB_PATH=vector_dbs/    # Path to store vector databases
USE_GPU=true                  # Set to "true" for GPU usage or "false" for CPU

# Pinecone Configuration
PINECONE_API_KEY=             # API key for Pinecone

# Weaviate Configuration
WEAVIATE_API_KEY=             # API key for Weaviate
WEAVIATE_CLUSTER_URL=         # Cluster URL for Weaviate

# Qdrant Configuration
QDRANT_API_KEY=               # API key for Qdrant (optional)
QDRANT_ADMIN_API_KEY=         # Admin API key for Qdrant (optional)
QDRANT_CLUSTER_URL=           # Cluster URL for Qdrant (optional)
```

---

## **Usage**

### 1. Initialize an Agent
```python
from reasonchain import Agent

agent = Agent(name="ResearchBot", model_name="gpt-4", api="openai")
```

### 2. Build a CoT Reasoning Pipeline
```python
from reasonchain.cot_pipeline import CoTPipeline

pipeline = CoTPipeline(agent)
pipeline.add_step("Understand the user's query.")
pipeline.add_step("Retrieve data from the knowledge base.")
pipeline.add_step("Generate a detailed response.")
```

### 3. Execute the Pipeline
```python
response = pipeline.execute(agent.model_manager)
print(response)
```

### 1. Build and Integrate Agents with RAG
ReasonChain makes it easy to create multi-agent systems and integrate them with RAG for context-enhanced reasoning.

```python
from reasonchain.agent import Agent, MultiAgentSystem
from reasonchain.rag.vector.add_to_vector_db import add_pdf_to_vector_db
from reasonchain.rag.rag_main import query_vector_db
from reasonchain.utils import (
    store_in_shared_memory,
    retrieve_from_shared_memory,
    collaborate_on_task,
    assign_and_execute_task
)

# Initialize the Multi-Agent System
multi_agent_system = MultiAgentSystem()

# Create and register agents
agent1 = Agent(name="AgentAlpha", role="extractor", model_name="gpt-4o", api="openai")
agent2 = Agent(name="AgentBeta", role="analyst", model_name="llama3.1:latest", api="ollama")
agent3 = Agent(name="AgentGamma", role="summarizer", model_name="llama-3.1-8b-instant", api="groq")

multi_agent_system.register_agent(agent1)
multi_agent_system.register_agent(agent2)
multi_agent_system.register_agent(agent3)

# Add a document to the vector database
add_pdf_to_vector_db(
    pdf_path="path/to/tesla-report.pdf",
    db_path="vector_db.index",
    db_type="faiss",
    embedding_provider="sentence_transformers",
    embedding_model="all-mpnet-base-v2",
    use_gpu=True
)

# Query the vector database
query = "Extract financial highlights from the Tesla Q-10 report."
response = query_vector_db(
    db_path="vector_db.index",
    db_type="faiss",
    query=query,
    embedding_provider="sentence_transformers",
    embedding_model="all-mpnet-base-v2"
)

# Store and retrieve data in shared memory
store_in_shared_memory(agent1.shared_memory, "financial_highlights", response)
highlights = retrieve_from_shared_memory(agent2.shared_memory, "financial_highlights")

# Assign tasks and collaborate
task_description = "Analyze trends and summarize Tesla's financial highlights."
collaborators = ["AgentBeta", "AgentGamma"]
successful_agents = collaborate_on_task(multi_agent_system, collaborators, task_description)

print(f"Successful Agents: {successful_agents}")
```

---

## **Examples**

Explore more scripts in the `examples/` directory:
- **`rag_pipeline_example.py`**: Example of using RAG for context-enhanced reasoning.
- **`multi-agent_collaboration.py`**: Multi-agent collaboration example.
- **`tree_of_thought_example.py`**: Demonstrates Tree of Thought reasoning.
- **`hybrid_reasoning_example.py`**: Combines multiple reasoning methods.

---

## **Supported File Types**

ReasonChain supports extracting text, tables, and figures from the following file types. It uses specialized extractors for each type to ensure accurate and comprehensive data retrieval.

### **Supported Extensions and Extractors**
| File Type               | Extensions             | Extractor Library/Tools                                   | Extracted Data           |
|-------------------------|------------------------|----------------------------------------------------------|--------------------------|
| **PDF Documents**       | `.pdf`                | PyMuPDF, Camelot, PDFPlumber, LlamaParse                 | Text, Tables, Figures    |
| **Word Documents**      | `.doc`, `.docx`       | python-docx                                              | Text, Tables, Figures    |
| **Excel Files**         | `.xls`, `.xlsx`       | pandas                                                   | Tables                   |
| **CSV Files**           | `.csv`                | pandas                                                   | Tables                   |
| **HTML Files**          | `.html`, `.htm`       | BeautifulSoup, pandas                                    | Text, Tables, Figures    |
| **Markdown Files**      | `.md`                 | re, pandas                                               | Text, Tables, Figures    |
| **Rich Text Files**     | `.rtf`                | pyrtf                                                    | Text                    |
| **E-Books**             | `.epub`, `.mobi`      | ebooklib, BeautifulSoup                                  | Text                    |
| **Images**              | `.png`, `.jpg`, `.jpeg`, `.tiff` | pytesseract (OCR)                                  | Text                    |
| **Presentation Files**  | `.ppt`, `.pptx`       | python-pptx                                              | Text, Figures            |
| **Audio Files**         | `.mp3`, `.wav`        | SpeechRecognition, Whisper                               | Text                    |
| **Video Files**         | `.mp4`, `.avi`, `.mov`| moviepy, pytesseract (OCR)                               | Text, Figures            |
| **LaTeX Files**         | `.tex`                | regex, plain text processing                             | Text                    |

---

### **Feature Highlights for Extractors**

1. **PDF Extraction**:
   - Handles structured text, tables, and embedded images.
   - LlamaParse integration for multimodal capabilities.

2. **Word and Presentation Files**:
   - Extracts text from paragraphs, tables, and embedded images.
   - Saves embedded figures locally for further processing.

3. **E-books and Markdown**:
   - Processes text and embedded images or hyperlinks.
   - Parses tables represented as plain text in Markdown.

4. **Images and Videos**:
   - Extracts frames from videos and applies OCR for textual content.
   - Processes scanned documents and infographics using pytesseract.

5. **Audio Extraction**:
   - Converts audio to text using SpeechRecognition or Whisper.

6. **Rich Text and LaTeX**:
   - Converts RTF files into plain text.
   - Removes LaTeX commands to provide clean text content.

---

### Domain Templates

ReasonChain provides **pre-built reasoning templates** tailored for specific industries and applications. These templates simplify the process of creating intelligent agents by embedding domain-specific logic and workflows. They can be used as-is or customized to meet unique requirements.

#### Available Domain Templates

| **Domain**              | **Description**                                                                 |
|--------------------------|---------------------------------------------------------------------------------|
| **Customer Support**     | Automates resolution workflows, ticket prioritization, and customer query handling. |
| **E-commerce**           | Assists in product recommendations, inventory optimization, and user behavior analysis. |
| **Education**            | Supports personalized learning plans, content recommendations, and assessments. |
| **Energy**               | Optimizes energy consumption, monitors grid performance, and supports sustainability planning. |
| **Finance**              | Analyzes financial trends, generates reports, and forecasts revenue and expenses. |
| **Gaming & Entertainment** | Provides real-time analytics for player engagement and content recommendations. |
| **Healthcare**           | Assists in diagnosis, treatment recommendations, and patient care management. |
| **HR & Recruitment**     | Streamlines candidate screening, skill assessments, and onboarding workflows. |
| **Legal**                | Summarizes legal documents, case analysis, and compliance checks. |
| **Marketing**            | Automates campaign analysis, audience targeting, and content generation. |
| **Real Estate**          | Evaluates property data, summarizes market trends, and supports investment decisions. |
| **Retail**               | Enhances customer experience, tracks sales data, and suggests optimization strategies. |
| **Supply Chain**         | Monitors logistics, optimizes inventory, and forecasts demand. |
| **Transportation**       | Provides route optimization, fleet management, and traffic pattern analysis. |
| **Travel & Hospitality** | Personalizes travel recommendations, optimizes bookings, and improves guest experiences. |

#### Example: Using the Customer Support Template

```python
from reasonchain.domain_templates.customer_support import CustomerSupportTemplate

# Initialize a Customer Support reasoning pipeline
pipeline = CustomerSupportTemplate()
pipeline.add_step("Analyze the customer's query.")
pipeline.add_step("Retrieve similar case resolutions.")
pipeline.add_step("Provide a detailed response to resolve the issue.")

response = pipeline.execute()
print(response)
```

#### Customizing Templates
Each template is fully customizable. You can modify the reasoning steps, add additional logic, or integrate with external APIs to extend the capabilities.

For example, to add a step in the Finance template:
```python
from reasonchain.domain_templates.finance import FinanceTemplate

pipeline = FinanceTemplate()
pipeline.add_step("Analyze the quarterly revenue data.")
pipeline.add_step("Provide insights into expenditure trends.")
pipeline.add_step("Forecast revenue for the next quarter.")

response = pipeline.execute()
print(response)
```

#### Extendability
- Easily create new templates for other domains by extending the base template classes.
- Integrate templates with Retrieval-Augmented Generation (RAG) for enhanced reasoning and data retrieval.

---

## Project Structure

The ReasonChain library is organized into the following core components:

- **Core Library (`reasonchain/`)**:
  - Contains the main modules for reasoning pipelines, RAG integration, domain templates, and utilities.
- **Examples (`examples/`)**:
  - Demonstrates the use of RAG pipelines, multi-agent systems, domain-specific templates, and hybrid reasoning.
- **Unit Tests (`tests/`)**:
  - Validates the functionality of various components.
- **Pre-trained Models and Outputs**:
  - Includes directories like `fine_tuned_model/`, `markdown_images/`, and `parsed_chunks/` for storing models and processed outputs.

For a detailed breakdown of the project structure, see the [CONTRIBUTING.md](CONTRIBUTING.md) or the `docs/` folder.

---

## **Key Features**

1. **Dynamic Pipelines**:
   - Choose from CoT, ToT, Parallel Chains, or Hybrid Pipelines.

2. **Knowledge Integration**:
   - Augment reasoning with RAG for external data retrieval.

3. **Scalable Memory**:
   - Manage short-term and long-term memory effectively.

4. **LLM Compatibility**:
   - Seamlessly work with OpenAI GPT, Llama, and similar models.

---

## **Future Enhancements**

1. **Domain-Specific Templates**:
   - Add pre-trained reasoning templates for specialized applications.

2. **Agent Collaboration**:
   - Enable seamless teamwork between agents.

3. **Extended RAG Support**:
   - Integrate with Pinecone, Milvus, and more vector databases.

4. **Fine-Tuning Support**:
   - Incorporate custom fine-tuned models for advanced reasoning.

---

## **Contributing**

Contributions are welcome! Follow these steps:
1. Fork the repository.
2. Create a new branch:
   ```bash
   git checkout -b feature/your-feature
   ```
3. Commit your changes:
   ```bash
   git commit -m "Add your feature"
   ```
4. Push to your fork:
   ```bash
   git push origin feature/your-feature
   ```
5. Open a pull request.

---

## **License**

This project is licensed under the MIT License. See the `LICENSE` file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sunnybedi990/reasonchain",
    "name": "reasonchain",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Baljindersingh Bedi",
    "author_email": "baljindersinghbedi409@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/08/f4/a77dd2d1c896147968be8096c70d3697cc36d8ec6d63c6542daa00845f37/reasonchain-0.2.16.tar.gz",
    "platform": null,
    "description": "# **ReasonChain**\n\n**ReasonChain** is a modular and extensible AI reasoning library for creating intelligent agents capable of executing advanced reasoning processes. It supports **Chain of Thought (CoT)** reasoning, **Tree of Thought (ToT)** reasoning, **Parallel Chains**, and integrates with **Retrieval-Augmented Generation (RAG)** for enhanced knowledge management.\n\n---\n\n### **Features**\n\n1. **Customizable Reasoning Pipelines**:\n   - Seamless integration of **Chain of Thought (CoT)**, **Tree of Thought (ToT)**, Parallel Chains, and Hybrid Pipelines.\n   - Facilitates task decomposition, execution, and validation.\n\n2. **RAG Integration**:\n   - Retrieve and augment responses using long-term memory stored in vector databases like FAISS.\n\n3. **Short-term and Long-term Memory**:\n   - Session-based short-term memory for reasoning chains.\n   - Persistent long-term memory powered by FAISS.\n\n4. **LLM Compatibility**:\n   - Supports OpenAI GPT, Llama, and other models for robust reasoning and summarization.\n\n5. **Utility Tools**:\n   - Adaptive complexity evaluation for reasoning tasks.\n   - Centralized model management for handling LLM interactions.\n\n6. **Supported File Types**:\n   - Extract text, tables, and figures from a wide range of file formats, including:\n     - **Documents**: PDF, Word, RTF, Markdown, HTML, LaTeX.\n     - **Spreadsheets**: Excel, CSV.\n     - **Multimedia**: Images, Videos, Audio.\n     - **E-books**: EPUB, MOBI.\n   - Provides modular extractors tailored for each file type, ensuring efficient data retrieval.\n\n7. **Domain Templates**:\n   - Pre-built reasoning templates tailored for specific industries and applications:\n     - **Customer Support**: Automates handling of customer inquiries and escalations.\n     - **Healthcare**: Assists in diagnosis recommendations and treatment plans.\n     - **Finance**: Analyzes trends, generates financial reports, and forecasts.\n     - **Retail**: Provides insights on inventory optimization and customer behavior.\n     - **Real Estate**: Summarizes market data and assists in property evaluations.\n   - Fully customizable to meet domain-specific requirements.\n   - Simplifies the setup of agents for new use cases.\n\n---\n\n## **Installation**\n\n### 1. Install via pip\nYou can install **ReasonChain** directly from PyPI:\n```bash\npip install reasonchain\n```\n\n### 2. Clone the Repository (for development)\nAlternatively, clone the repository to access examples and editable source code:\n```bash\ngit clone https://github.com/sunnybedi990/reasonchain.git\ncd reasonchain\n```\n\n### 3. Install Dependencies\n```bash\npip install -r requirements.txt\n```\n\n### 4. Install as an Editable Package\n```bash\npip install -e .\n```\n\n### 5. Configure API Keys\nCreate a `.env` file with your API keys:\n```env\n# Authentication Keys\nLLAMA_CLOUD_API_KEY=          # API key for LLama Parser\nOPENAI_API_KEY=               # API key for OpenAI\nGROQ_API_KEY=                 # API key for Groq\n\n# Vector Database Configuration\nVECTOR_DB_PATH=vector_dbs/    # Path to store vector databases\nUSE_GPU=true                  # Set to \"true\" for GPU usage or \"false\" for CPU\n\n# Pinecone Configuration\nPINECONE_API_KEY=             # API key for Pinecone\n\n# Weaviate Configuration\nWEAVIATE_API_KEY=             # API key for Weaviate\nWEAVIATE_CLUSTER_URL=         # Cluster URL for Weaviate\n\n# Qdrant Configuration\nQDRANT_API_KEY=               # API key for Qdrant (optional)\nQDRANT_ADMIN_API_KEY=         # Admin API key for Qdrant (optional)\nQDRANT_CLUSTER_URL=           # Cluster URL for Qdrant (optional)\n```\n\n---\n\n## **Usage**\n\n### 1. Initialize an Agent\n```python\nfrom reasonchain import Agent\n\nagent = Agent(name=\"ResearchBot\", model_name=\"gpt-4\", api=\"openai\")\n```\n\n### 2. Build a CoT Reasoning Pipeline\n```python\nfrom reasonchain.cot_pipeline import CoTPipeline\n\npipeline = CoTPipeline(agent)\npipeline.add_step(\"Understand the user's query.\")\npipeline.add_step(\"Retrieve data from the knowledge base.\")\npipeline.add_step(\"Generate a detailed response.\")\n```\n\n### 3. Execute the Pipeline\n```python\nresponse = pipeline.execute(agent.model_manager)\nprint(response)\n```\n\n### 1. Build and Integrate Agents with RAG\nReasonChain makes it easy to create multi-agent systems and integrate them with RAG for context-enhanced reasoning.\n\n```python\nfrom reasonchain.agent import Agent, MultiAgentSystem\nfrom reasonchain.rag.vector.add_to_vector_db import add_pdf_to_vector_db\nfrom reasonchain.rag.rag_main import query_vector_db\nfrom reasonchain.utils import (\n    store_in_shared_memory,\n    retrieve_from_shared_memory,\n    collaborate_on_task,\n    assign_and_execute_task\n)\n\n# Initialize the Multi-Agent System\nmulti_agent_system = MultiAgentSystem()\n\n# Create and register agents\nagent1 = Agent(name=\"AgentAlpha\", role=\"extractor\", model_name=\"gpt-4o\", api=\"openai\")\nagent2 = Agent(name=\"AgentBeta\", role=\"analyst\", model_name=\"llama3.1:latest\", api=\"ollama\")\nagent3 = Agent(name=\"AgentGamma\", role=\"summarizer\", model_name=\"llama-3.1-8b-instant\", api=\"groq\")\n\nmulti_agent_system.register_agent(agent1)\nmulti_agent_system.register_agent(agent2)\nmulti_agent_system.register_agent(agent3)\n\n# Add a document to the vector database\nadd_pdf_to_vector_db(\n    pdf_path=\"path/to/tesla-report.pdf\",\n    db_path=\"vector_db.index\",\n    db_type=\"faiss\",\n    embedding_provider=\"sentence_transformers\",\n    embedding_model=\"all-mpnet-base-v2\",\n    use_gpu=True\n)\n\n# Query the vector database\nquery = \"Extract financial highlights from the Tesla Q-10 report.\"\nresponse = query_vector_db(\n    db_path=\"vector_db.index\",\n    db_type=\"faiss\",\n    query=query,\n    embedding_provider=\"sentence_transformers\",\n    embedding_model=\"all-mpnet-base-v2\"\n)\n\n# Store and retrieve data in shared memory\nstore_in_shared_memory(agent1.shared_memory, \"financial_highlights\", response)\nhighlights = retrieve_from_shared_memory(agent2.shared_memory, \"financial_highlights\")\n\n# Assign tasks and collaborate\ntask_description = \"Analyze trends and summarize Tesla's financial highlights.\"\ncollaborators = [\"AgentBeta\", \"AgentGamma\"]\nsuccessful_agents = collaborate_on_task(multi_agent_system, collaborators, task_description)\n\nprint(f\"Successful Agents: {successful_agents}\")\n```\n\n---\n\n## **Examples**\n\nExplore more scripts in the `examples/` directory:\n- **`rag_pipeline_example.py`**: Example of using RAG for context-enhanced reasoning.\n- **`multi-agent_collaboration.py`**: Multi-agent collaboration example.\n- **`tree_of_thought_example.py`**: Demonstrates Tree of Thought reasoning.\n- **`hybrid_reasoning_example.py`**: Combines multiple reasoning methods.\n\n---\n\n## **Supported File Types**\n\nReasonChain supports extracting text, tables, and figures from the following file types. It uses specialized extractors for each type to ensure accurate and comprehensive data retrieval.\n\n### **Supported Extensions and Extractors**\n| File Type               | Extensions             | Extractor Library/Tools                                   | Extracted Data           |\n|-------------------------|------------------------|----------------------------------------------------------|--------------------------|\n| **PDF Documents**       | `.pdf`                | PyMuPDF, Camelot, PDFPlumber, LlamaParse                 | Text, Tables, Figures    |\n| **Word Documents**      | `.doc`, `.docx`       | python-docx                                              | Text, Tables, Figures    |\n| **Excel Files**         | `.xls`, `.xlsx`       | pandas                                                   | Tables                   |\n| **CSV Files**           | `.csv`                | pandas                                                   | Tables                   |\n| **HTML Files**          | `.html`, `.htm`       | BeautifulSoup, pandas                                    | Text, Tables, Figures    |\n| **Markdown Files**      | `.md`                 | re, pandas                                               | Text, Tables, Figures    |\n| **Rich Text Files**     | `.rtf`                | pyrtf                                                    | Text                    |\n| **E-Books**             | `.epub`, `.mobi`      | ebooklib, BeautifulSoup                                  | Text                    |\n| **Images**              | `.png`, `.jpg`, `.jpeg`, `.tiff` | pytesseract (OCR)                                  | Text                    |\n| **Presentation Files**  | `.ppt`, `.pptx`       | python-pptx                                              | Text, Figures            |\n| **Audio Files**         | `.mp3`, `.wav`        | SpeechRecognition, Whisper                               | Text                    |\n| **Video Files**         | `.mp4`, `.avi`, `.mov`| moviepy, pytesseract (OCR)                               | Text, Figures            |\n| **LaTeX Files**         | `.tex`                | regex, plain text processing                             | Text                    |\n\n---\n\n### **Feature Highlights for Extractors**\n\n1. **PDF Extraction**:\n   - Handles structured text, tables, and embedded images.\n   - LlamaParse integration for multimodal capabilities.\n\n2. **Word and Presentation Files**:\n   - Extracts text from paragraphs, tables, and embedded images.\n   - Saves embedded figures locally for further processing.\n\n3. **E-books and Markdown**:\n   - Processes text and embedded images or hyperlinks.\n   - Parses tables represented as plain text in Markdown.\n\n4. **Images and Videos**:\n   - Extracts frames from videos and applies OCR for textual content.\n   - Processes scanned documents and infographics using pytesseract.\n\n5. **Audio Extraction**:\n   - Converts audio to text using SpeechRecognition or Whisper.\n\n6. **Rich Text and LaTeX**:\n   - Converts RTF files into plain text.\n   - Removes LaTeX commands to provide clean text content.\n\n---\n\n### Domain Templates\n\nReasonChain provides **pre-built reasoning templates** tailored for specific industries and applications. These templates simplify the process of creating intelligent agents by embedding domain-specific logic and workflows. They can be used as-is or customized to meet unique requirements.\n\n#### Available Domain Templates\n\n| **Domain**              | **Description**                                                                 |\n|--------------------------|---------------------------------------------------------------------------------|\n| **Customer Support**     | Automates resolution workflows, ticket prioritization, and customer query handling. |\n| **E-commerce**           | Assists in product recommendations, inventory optimization, and user behavior analysis. |\n| **Education**            | Supports personalized learning plans, content recommendations, and assessments. |\n| **Energy**               | Optimizes energy consumption, monitors grid performance, and supports sustainability planning. |\n| **Finance**              | Analyzes financial trends, generates reports, and forecasts revenue and expenses. |\n| **Gaming & Entertainment** | Provides real-time analytics for player engagement and content recommendations. |\n| **Healthcare**           | Assists in diagnosis, treatment recommendations, and patient care management. |\n| **HR & Recruitment**     | Streamlines candidate screening, skill assessments, and onboarding workflows. |\n| **Legal**                | Summarizes legal documents, case analysis, and compliance checks. |\n| **Marketing**            | Automates campaign analysis, audience targeting, and content generation. |\n| **Real Estate**          | Evaluates property data, summarizes market trends, and supports investment decisions. |\n| **Retail**               | Enhances customer experience, tracks sales data, and suggests optimization strategies. |\n| **Supply Chain**         | Monitors logistics, optimizes inventory, and forecasts demand. |\n| **Transportation**       | Provides route optimization, fleet management, and traffic pattern analysis. |\n| **Travel & Hospitality** | Personalizes travel recommendations, optimizes bookings, and improves guest experiences. |\n\n#### Example: Using the Customer Support Template\n\n```python\nfrom reasonchain.domain_templates.customer_support import CustomerSupportTemplate\n\n# Initialize a Customer Support reasoning pipeline\npipeline = CustomerSupportTemplate()\npipeline.add_step(\"Analyze the customer's query.\")\npipeline.add_step(\"Retrieve similar case resolutions.\")\npipeline.add_step(\"Provide a detailed response to resolve the issue.\")\n\nresponse = pipeline.execute()\nprint(response)\n```\n\n#### Customizing Templates\nEach template is fully customizable. You can modify the reasoning steps, add additional logic, or integrate with external APIs to extend the capabilities.\n\nFor example, to add a step in the Finance template:\n```python\nfrom reasonchain.domain_templates.finance import FinanceTemplate\n\npipeline = FinanceTemplate()\npipeline.add_step(\"Analyze the quarterly revenue data.\")\npipeline.add_step(\"Provide insights into expenditure trends.\")\npipeline.add_step(\"Forecast revenue for the next quarter.\")\n\nresponse = pipeline.execute()\nprint(response)\n```\n\n#### Extendability\n- Easily create new templates for other domains by extending the base template classes.\n- Integrate templates with Retrieval-Augmented Generation (RAG) for enhanced reasoning and data retrieval.\n\n---\n\n## Project Structure\n\nThe ReasonChain library is organized into the following core components:\n\n- **Core Library (`reasonchain/`)**:\n  - Contains the main modules for reasoning pipelines, RAG integration, domain templates, and utilities.\n- **Examples (`examples/`)**:\n  - Demonstrates the use of RAG pipelines, multi-agent systems, domain-specific templates, and hybrid reasoning.\n- **Unit Tests (`tests/`)**:\n  - Validates the functionality of various components.\n- **Pre-trained Models and Outputs**:\n  - Includes directories like `fine_tuned_model/`, `markdown_images/`, and `parsed_chunks/` for storing models and processed outputs.\n\nFor a detailed breakdown of the project structure, see the [CONTRIBUTING.md](CONTRIBUTING.md) or the `docs/` folder.\n\n---\n\n## **Key Features**\n\n1. **Dynamic Pipelines**:\n   - Choose from CoT, ToT, Parallel Chains, or Hybrid Pipelines.\n\n2. **Knowledge Integration**:\n   - Augment reasoning with RAG for external data retrieval.\n\n3. **Scalable Memory**:\n   - Manage short-term and long-term memory effectively.\n\n4. **LLM Compatibility**:\n   - Seamlessly work with OpenAI GPT, Llama, and similar models.\n\n---\n\n## **Future Enhancements**\n\n1. **Domain-Specific Templates**:\n   - Add pre-trained reasoning templates for specialized applications.\n\n2. **Agent Collaboration**:\n   - Enable seamless teamwork between agents.\n\n3. **Extended RAG Support**:\n   - Integrate with Pinecone, Milvus, and more vector databases.\n\n4. **Fine-Tuning Support**:\n   - Incorporate custom fine-tuned models for advanced reasoning.\n\n---\n\n## **Contributing**\n\nContributions are welcome! Follow these steps:\n1. Fork the repository.\n2. Create a new branch:\n   ```bash\n   git checkout -b feature/your-feature\n   ```\n3. Commit your changes:\n   ```bash\n   git commit -m \"Add your feature\"\n   ```\n4. Push to your fork:\n   ```bash\n   git push origin feature/your-feature\n   ```\n5. Open a pull request.\n\n---\n\n## **License**\n\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A modular AI reasoning library for building intelligent agents.",
    "version": "0.2.16",
    "project_urls": {
        "Homepage": "https://github.com/sunnybedi990/reasonchain"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eb84eab9b02bea11317525142262d92574d8655fd2956a833f852fc2feb7454",
                "md5": "ce8f386cdbb6f2d4f6549244ceb1abda",
                "sha256": "8c6d2f59721064d51622695fb4e3d0061e69198355c3e518c28c631eef510189"
            },
            "downloads": -1,
            "filename": "reasonchain-0.2.16-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce8f386cdbb6f2d4f6549244ceb1abda",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7026471,
            "upload_time": "2025-01-04T20:34:16",
            "upload_time_iso_8601": "2025-01-04T20:34:16.971084Z",
            "url": "https://files.pythonhosted.org/packages/5e/b8/4eab9b02bea11317525142262d92574d8655fd2956a833f852fc2feb7454/reasonchain-0.2.16-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08f4a77dd2d1c896147968be8096c70d3697cc36d8ec6d63c6542daa00845f37",
                "md5": "94a6a89d7e2e48d88ea357ce176bccdd",
                "sha256": "9c458bdf8e719ed0898052d4b29c47c5530861b4f864a0dcd20d36dfa00dd14f"
            },
            "downloads": -1,
            "filename": "reasonchain-0.2.16.tar.gz",
            "has_sig": false,
            "md5_digest": "94a6a89d7e2e48d88ea357ce176bccdd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7008138,
            "upload_time": "2025-01-04T20:34:20",
            "upload_time_iso_8601": "2025-01-04T20:34:20.340566Z",
            "url": "https://files.pythonhosted.org/packages/08/f4/a77dd2d1c896147968be8096c70d3697cc36d8ec6d63c6542daa00845f37/reasonchain-0.2.16.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-04 20:34:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sunnybedi990",
    "github_project": "reasonchain",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    "<",
                    "2.0.0"
                ],
                [
                    ">=",
                    "1.21.0"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.8.0"
                ],
                [
                    "<",
                    "1.14.0"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "torch",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        },
        {
            "name": "faiss-cpu",
            "specs": []
        },
        {
            "name": "pymilvus",
            "specs": []
        },
        {
            "name": "pinecone",
            "specs": []
        },
        {
            "name": "qdrant-client",
            "specs": []
        },
        {
            "name": "weaviate-client",
            "specs": []
        },
        {
            "name": "transformers",
            "specs": []
        },
        {
            "name": "ollama",
            "specs": []
        },
        {
            "name": "groq",
            "specs": []
        },
        {
            "name": "openai",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "tabula-py",
            "specs": []
        },
        {
            "name": "camelot-py",
            "specs": []
        },
        {
            "name": "pymupdf",
            "specs": []
        },
        {
            "name": "sentence-transformers",
            "specs": []
        },
        {
            "name": "tensorflow_hub",
            "specs": []
        },
        {
            "name": "gensim",
            "specs": []
        },
        {
            "name": "layoutparser",
            "specs": []
        },
        {
            "name": "pdf2image",
            "specs": []
        },
        {
            "name": "pytesseract",
            "specs": []
        },
        {
            "name": "pdfplumber",
            "specs": []
        },
        {
            "name": "fastapi",
            "specs": []
        },
        {
            "name": "jpype1",
            "specs": []
        },
        {
            "name": "llama-index-core",
            "specs": [
                [
                    "==",
                    "0.12.2"
                ]
            ]
        },
        {
            "name": "llama-parse",
            "specs": []
        },
        {
            "name": "llama-index-readers-file",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "opencv-python",
            "specs": []
        },
        {
            "name": "datasets",
            "specs": []
        },
        {
            "name": "python-pptx",
            "specs": []
        },
        {
            "name": "moviepy",
            "specs": []
        },
        {
            "name": "SpeechRecognition",
            "specs": []
        },
        {
            "name": "ebooklib",
            "specs": []
        },
        {
            "name": "bs4",
            "specs": []
        },
        {
            "name": "python-docx",
            "specs": []
        },
        {
            "name": "whisper",
            "specs": []
        }
    ],
    "lcname": "reasonchain"
}
        
Elapsed time: 0.44962s