longtrainer


Namelongtrainer JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/ENDEVSOLS/Long-Trainer
SummaryProduction Ready LangChain
upload_time2024-12-17 13:18:13
maintainerNone
docs_urlNone
authorEndevsols
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements langchain-core openai faiss-cpu tiktoken wikipedia langchain youtube-transcript-api pytube pypdf docx2txt fastapi uvicorn pydantic pandas pymongo python-docx langchain-openai langchain-community cryptography duckduckgo-search python-magic unstructured unstructured langchain-unstructured
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="https://github.com/ENDEVSOLS/Long-Trainer/blob/master/assets/longtrainer-logo.png?raw=true" alt="LongTrainer Logo">
</p>

<h1 align="center">LongTrainer - Production-Ready LangChain</h1>

<p align="center">
  <a href="https://pypi.org/project/longtrainer/">
    <img src="https://img.shields.io/pypi/v/longtrainer" alt="PyPI Version">
  </a>
  <a href="https://pepy.tech/project/longtrainer">
    <img src="https://static.pepy.tech/badge/longtrainer" alt="Total Downloads">
  </a>
  <a href="https://pepy.tech/project/longtrainer">
    <img src="https://static.pepy.tech/badge/longtrainer/month" alt="Monthly Downloads">
  </a>
  <a href="https://colab.research.google.com/drive/1HE30D5q5onD8sfS50-06XPDXnbdvnjIy?usp=sharing">
    <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab">
  </a>
</p>
<hr />
<p align="center">
  <a href="https://endevsols.com/longtrainer-the-next-evolution-in-production-ready-langchain-frameworks/">
    Visit Blog Post
  </a>
</p>

<p align="center">
  <a class="github-button" href="https://github.com/ENDEVSOLS/Long-Trainer" data-color-scheme="no-preference: light; light: light; dark: dark;" data-size="large" data-show-count="true" aria-label="Star ENDEVSOLS/Long-Trainer on GitHub">Star</a>
  <a class="github-button" href="https://github.com/ENDEVSOLS" data-color-scheme="no-preference: light; light: light; dark: dark;" data-size="large" data-show-count="true" aria-label="Follow @ENDEVSOLS on GitHub">Follow @ENDEVSOLS</a>
</p>


# Official Documentation

Explore the comprehensive [LongTrainer Documentation](https://endevsols.github.io/Long-Trainer/) for detailed
instructions on installation, features, and API usage.

# Installation

Introducing LongTrainer, a sophisticated extension of the LangChain framework designed specifically for managing
multiple bots and providing isolated, context-aware chat sessions. Ideal for developers and businesses looking to
integrate complex conversational AI into their systems, LongTrainer simplifies the deployment and customization of LLMs.

```markdown
pip install longtrainer
```

## Installation Instructions for Required Libraries and Tools

### 1. Linux (Ubuntu/Debian)

To install the required packages on a Linux system (specifically Ubuntu or Debian), you can use the apt package manager.
The following command installs several essential libraries and tools:

```markdown
sudo apt install libmagic-dev poppler-utils tesseract-ocr qpdf libreoffice pandoc
```

### 2. macOS

On macOS, you can install these packages using brew, the Homebrew package manager. If you don't have Homebrew installed,
you can install it from brew.sh.

```markdown
brew install libmagic poppler tesseract qpdf libreoffice pandoc
```

# Features 🌟

- ✅ **Long Memory:** Retains context effectively for extended interactions.
- ✅ **Multi-Bot Management:** Easily configure and manage multiple bots within a single framework, perfect for scaling
  across various use cases
- ✅ **Isolated Chat Sessions:** Each bot operates within its own session, ensuring interactions remain distinct and
  contextually relevant without overlap.
- ✅ **Context-Aware Interactions:**  Utilize enhanced memory capabilities to maintain context over extended dialogues,
  significantly improving user experience
- ✅ **Scalable Architecture:** Designed to scale effortlessly with your needs, whether you're handling hundreds of users
  or just a few.
- ✅ **Enhanced Customization:** Tailor the behavior to fit specific needs.
- ✅ **Memory Management:** Efficient handling of chat histories and contexts.
- ✅ **GPT Vision Support:** Integration Context Aware GPT-powered visual models.
- ✅ **Different Data Formats:** Supports various data input formats.
- ✅ **VectorStore Management:** Advanced management of vector storage for efficient retrieval.

## Diverse Use Cases:

- ✅ **Enterprise Solutions:** Streamline customer interactions, automate responses, and manage multiple departmental
  bots from a single platform.
- ✅ **Educational Platforms:** Enhance learning experiences with AI tutors capable of maintaining context throughout
  sessions.
- ✅ **Healthcare Applications:** Support patient management with bots that provide consistent, context-aware
  interactions.

## Works for All Langchain Supported LLM and Embeddings

- ✅ OpenAI (default)
- ✅ VertexAI
- ✅ HuggingFace
- ✅ AWS Bedrock
- ✅ Groq
- ✅ TogetherAI

# Example

VertexAI LLMs

```python
from longtrainer.trainer import LongTrainer
from langchain_community.llms import VertexAI

llm = VertexAI()

trainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', llm=llm)
```

TogetherAI LLMs

```python
from longtrainer.trainer import LongTrainer
from langchain_community.llms import Together

llm = Together(
    model="togethercomputer/RedPajama-INCITE-7B-Base",
    temperature=0.7,
    max_tokens=128,
    top_k=1,
    # together_api_key="..."
)

trainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', llm=llm)

```

## Usage Example 🚀

Here's a quick start guide on how to use LongTrainer:

```python
from longtrainer.trainer import LongTrainer
import os

# Set your OpenAI API key
os.environ["OPENAI_API_KEY"] = "sk-"

# Initialize LongTrainer
trainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', ensemble=True, encrypt_chats=True)
bot_id = trainer.initialize_bot_id()
print('Bot ID: ', bot_id)

# Add Data
path = 'path/to/your/data'
trainer.add_document_from_path(path, bot_id)

# Initialize Bot
trainer.create_bot(bot_id)

# Start a New Chat
chat_id = trainer.new_chat(bot_id)

# Send a Query and Get a Response
query = 'Your query here'
response = trainer.get_response(query, bot_id, chat_id)
print('Response: ', response)
  ```

Here's a guide on how to use Vision Chat:

```python
chat_id = trainer.new_vision_chat(bot_id)

query = 'Your query here'
image_paths = ['nvidia.jpg']
response = trainer.get_vision_response(query, image_paths, str(bot_id), str(vision_id))
print('Response: ', response)
```

List Chats and Display Chat History:

```python
trainer.list_chats(bot_id)

trainer.get_chat_by_id(chat_id=chat_id)
```

This project is still under active development. Community feedback and contributions are highly appreciated.

## Citation

If you utilize this repository, please consider citing it with:

```
@misc{longtrainer,
  author = {Endevsols},
  title = {LongTrainer: Production-Ready LangChain},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/ENDEVSOLS/Long-Trainer}},
}
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ENDEVSOLS/Long-Trainer",
    "name": "longtrainer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Endevsols",
    "author_email": "technology@endevsols.com",
    "download_url": "https://files.pythonhosted.org/packages/59/e1/65ca0778c96e06c6ae74f8954e8cbb57b5cadcf91e1a35bd8a8021393775/longtrainer-0.3.4.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"https://github.com/ENDEVSOLS/Long-Trainer/blob/master/assets/longtrainer-logo.png?raw=true\" alt=\"LongTrainer Logo\">\n</p>\n\n<h1 align=\"center\">LongTrainer - Production-Ready LangChain</h1>\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/longtrainer/\">\n    <img src=\"https://img.shields.io/pypi/v/longtrainer\" alt=\"PyPI Version\">\n  </a>\n  <a href=\"https://pepy.tech/project/longtrainer\">\n    <img src=\"https://static.pepy.tech/badge/longtrainer\" alt=\"Total Downloads\">\n  </a>\n  <a href=\"https://pepy.tech/project/longtrainer\">\n    <img src=\"https://static.pepy.tech/badge/longtrainer/month\" alt=\"Monthly Downloads\">\n  </a>\n  <a href=\"https://colab.research.google.com/drive/1HE30D5q5onD8sfS50-06XPDXnbdvnjIy?usp=sharing\">\n    <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open in Colab\">\n  </a>\n</p>\n<hr />\n<p align=\"center\">\n  <a href=\"https://endevsols.com/longtrainer-the-next-evolution-in-production-ready-langchain-frameworks/\">\n    Visit Blog Post\n  </a>\n</p>\n\n<p align=\"center\">\n  <a class=\"github-button\" href=\"https://github.com/ENDEVSOLS/Long-Trainer\" data-color-scheme=\"no-preference: light; light: light; dark: dark;\" data-size=\"large\" data-show-count=\"true\" aria-label=\"Star ENDEVSOLS/Long-Trainer on GitHub\">Star</a>\n  <a class=\"github-button\" href=\"https://github.com/ENDEVSOLS\" data-color-scheme=\"no-preference: light; light: light; dark: dark;\" data-size=\"large\" data-show-count=\"true\" aria-label=\"Follow @ENDEVSOLS on GitHub\">Follow @ENDEVSOLS</a>\n</p>\n\n\n# Official Documentation\n\nExplore the comprehensive [LongTrainer Documentation](https://endevsols.github.io/Long-Trainer/) for detailed\ninstructions on installation, features, and API usage.\n\n# Installation\n\nIntroducing LongTrainer, a sophisticated extension of the LangChain framework designed specifically for managing\nmultiple bots and providing isolated, context-aware chat sessions. Ideal for developers and businesses looking to\nintegrate complex conversational AI into their systems, LongTrainer simplifies the deployment and customization of LLMs.\n\n```markdown\npip install longtrainer\n```\n\n## Installation Instructions for Required Libraries and Tools\n\n### 1. Linux (Ubuntu/Debian)\n\nTo install the required packages on a Linux system (specifically Ubuntu or Debian), you can use the apt package manager.\nThe following command installs several essential libraries and tools:\n\n```markdown\nsudo apt install libmagic-dev poppler-utils tesseract-ocr qpdf libreoffice pandoc\n```\n\n### 2. macOS\n\nOn macOS, you can install these packages using brew, the Homebrew package manager. If you don't have Homebrew installed,\nyou can install it from brew.sh.\n\n```markdown\nbrew install libmagic poppler tesseract qpdf libreoffice pandoc\n```\n\n# Features \ud83c\udf1f\n\n- \u2705 **Long Memory:** Retains context effectively for extended interactions.\n- \u2705 **Multi-Bot Management:** Easily configure and manage multiple bots within a single framework, perfect for scaling\n  across various use cases\n- \u2705 **Isolated Chat Sessions:** Each bot operates within its own session, ensuring interactions remain distinct and\n  contextually relevant without overlap.\n- \u2705 **Context-Aware Interactions:**  Utilize enhanced memory capabilities to maintain context over extended dialogues,\n  significantly improving user experience\n- \u2705 **Scalable Architecture:** Designed to scale effortlessly with your needs, whether you're handling hundreds of users\n  or just a few.\n- \u2705 **Enhanced Customization:** Tailor the behavior to fit specific needs.\n- \u2705 **Memory Management:** Efficient handling of chat histories and contexts.\n- \u2705 **GPT Vision Support:** Integration Context Aware GPT-powered visual models.\n- \u2705 **Different Data Formats:** Supports various data input formats.\n- \u2705 **VectorStore Management:** Advanced management of vector storage for efficient retrieval.\n\n## Diverse Use Cases:\n\n- \u2705 **Enterprise Solutions:** Streamline customer interactions, automate responses, and manage multiple departmental\n  bots from a single platform.\n- \u2705 **Educational Platforms:** Enhance learning experiences with AI tutors capable of maintaining context throughout\n  sessions.\n- \u2705 **Healthcare Applications:** Support patient management with bots that provide consistent, context-aware\n  interactions.\n\n## Works for All Langchain Supported LLM and Embeddings\n\n- \u2705 OpenAI (default)\n- \u2705 VertexAI\n- \u2705 HuggingFace\n- \u2705 AWS Bedrock\n- \u2705 Groq\n- \u2705 TogetherAI\n\n# Example\n\nVertexAI LLMs\n\n```python\nfrom longtrainer.trainer import LongTrainer\nfrom langchain_community.llms import VertexAI\n\nllm = VertexAI()\n\ntrainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', llm=llm)\n```\n\nTogetherAI LLMs\n\n```python\nfrom longtrainer.trainer import LongTrainer\nfrom langchain_community.llms import Together\n\nllm = Together(\n    model=\"togethercomputer/RedPajama-INCITE-7B-Base\",\n    temperature=0.7,\n    max_tokens=128,\n    top_k=1,\n    # together_api_key=\"...\"\n)\n\ntrainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', llm=llm)\n\n```\n\n## Usage Example \ud83d\ude80\n\nHere's a quick start guide on how to use LongTrainer:\n\n```python\nfrom longtrainer.trainer import LongTrainer\nimport os\n\n# Set your OpenAI API key\nos.environ[\"OPENAI_API_KEY\"] = \"sk-\"\n\n# Initialize LongTrainer\ntrainer = LongTrainer(mongo_endpoint='mongodb://localhost:27017/', ensemble=True, encrypt_chats=True)\nbot_id = trainer.initialize_bot_id()\nprint('Bot ID: ', bot_id)\n\n# Add Data\npath = 'path/to/your/data'\ntrainer.add_document_from_path(path, bot_id)\n\n# Initialize Bot\ntrainer.create_bot(bot_id)\n\n# Start a New Chat\nchat_id = trainer.new_chat(bot_id)\n\n# Send a Query and Get a Response\nquery = 'Your query here'\nresponse = trainer.get_response(query, bot_id, chat_id)\nprint('Response: ', response)\n  ```\n\nHere's a guide on how to use Vision Chat:\n\n```python\nchat_id = trainer.new_vision_chat(bot_id)\n\nquery = 'Your query here'\nimage_paths = ['nvidia.jpg']\nresponse = trainer.get_vision_response(query, image_paths, str(bot_id), str(vision_id))\nprint('Response: ', response)\n```\n\nList Chats and Display Chat History:\n\n```python\ntrainer.list_chats(bot_id)\n\ntrainer.get_chat_by_id(chat_id=chat_id)\n```\n\nThis project is still under active development. Community feedback and contributions are highly appreciated.\n\n## Citation\n\nIf you utilize this repository, please consider citing it with:\n\n```\n@misc{longtrainer,\n  author = {Endevsols},\n  title = {LongTrainer: Production-Ready LangChain},\n  year = {2023},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/ENDEVSOLS/Long-Trainer}},\n}\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Production Ready LangChain",
    "version": "0.3.4",
    "project_urls": {
        "Homepage": "https://github.com/ENDEVSOLS/Long-Trainer"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98a4ec4384079e9ca1ee19b6abe211b5c6ee92b80f0072a9494a40d0e0081595",
                "md5": "c75889470b2710713e090277ad444388",
                "sha256": "c8f7a773f390f4229423d2d318382111d7e63556d9baa1e5f27cafc0202b6b2f"
            },
            "downloads": -1,
            "filename": "longtrainer-0.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c75889470b2710713e090277ad444388",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22389,
            "upload_time": "2024-12-17T13:18:09",
            "upload_time_iso_8601": "2024-12-17T13:18:09.440671Z",
            "url": "https://files.pythonhosted.org/packages/98/a4/ec4384079e9ca1ee19b6abe211b5c6ee92b80f0072a9494a40d0e0081595/longtrainer-0.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59e165ca0778c96e06c6ae74f8954e8cbb57b5cadcf91e1a35bd8a8021393775",
                "md5": "2331a8bc868503d0be392fc40c75f39a",
                "sha256": "17ee9f7ce24fb7d242f2eea005cad8f369838104ca440d2290cc5efd89a92e25"
            },
            "downloads": -1,
            "filename": "longtrainer-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2331a8bc868503d0be392fc40c75f39a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23138,
            "upload_time": "2024-12-17T13:18:13",
            "upload_time_iso_8601": "2024-12-17T13:18:13.483519Z",
            "url": "https://files.pythonhosted.org/packages/59/e1/65ca0778c96e06c6ae74f8954e8cbb57b5cadcf91e1a35bd8a8021393775/longtrainer-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 13:18:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ENDEVSOLS",
    "github_project": "Long-Trainer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "langchain-core",
            "specs": [
                [
                    "==",
                    "0.3.17"
                ]
            ]
        },
        {
            "name": "openai",
            "specs": [
                [
                    "==",
                    "1.54.4"
                ]
            ]
        },
        {
            "name": "faiss-cpu",
            "specs": [
                [
                    "==",
                    "1.9.0"
                ]
            ]
        },
        {
            "name": "tiktoken",
            "specs": [
                [
                    "==",
                    "0.8.0"
                ]
            ]
        },
        {
            "name": "wikipedia",
            "specs": [
                [
                    "==",
                    "1.4.0"
                ]
            ]
        },
        {
            "name": "langchain",
            "specs": [
                [
                    "==",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "youtube-transcript-api",
            "specs": [
                [
                    "==",
                    "0.6.2"
                ]
            ]
        },
        {
            "name": "pytube",
            "specs": [
                [
                    "==",
                    "15.0.0"
                ]
            ]
        },
        {
            "name": "pypdf",
            "specs": [
                [
                    "==",
                    "5.1.0"
                ]
            ]
        },
        {
            "name": "docx2txt",
            "specs": [
                [
                    "==",
                    "0.8"
                ]
            ]
        },
        {
            "name": "fastapi",
            "specs": [
                [
                    "==",
                    "0.115.5"
                ]
            ]
        },
        {
            "name": "uvicorn",
            "specs": [
                [
                    "==",
                    "0.32.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.9.2"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "pymongo",
            "specs": [
                [
                    "==",
                    "4.10.1"
                ]
            ]
        },
        {
            "name": "python-docx",
            "specs": [
                [
                    "==",
                    "1.1.2"
                ]
            ]
        },
        {
            "name": "langchain-openai",
            "specs": [
                [
                    "==",
                    "0.2.8"
                ]
            ]
        },
        {
            "name": "langchain-community",
            "specs": [
                [
                    "==",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "43.0.3"
                ]
            ]
        },
        {
            "name": "duckduckgo-search",
            "specs": [
                [
                    "==",
                    "6.3.5"
                ]
            ]
        },
        {
            "name": "python-magic",
            "specs": [
                [
                    "==",
                    "0.4.27"
                ]
            ]
        },
        {
            "name": "unstructured",
            "specs": [
                [
                    "==",
                    "0.15.7"
                ]
            ]
        },
        {
            "name": "unstructured",
            "specs": []
        },
        {
            "name": "langchain-unstructured",
            "specs": []
        }
    ],
    "lcname": "longtrainer"
}
        
Elapsed time: 0.57709s