Skip to main content

Produciton Ready LangChain

Project description

LongTrainer - Production-Ready LangChain

Features 🌟

  • Long Memory: Retains context effectively for extended interactions.
  • Unique Bots/Chat Management: Sophisticated management of multiple chatbots.
  • 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.

Works for All Langchain Supported LLM and Embeddings

  • ✅ OpenAI (default)
  • ✅ VertexAI
  • ✅ HuggingFace

Example

VertexAI LLMs

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

llm = VertexAI()

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

TogetherAI LLMs

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 🚀

pip install longtrainer

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

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/')
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:

chat_id = trainer.new_vision_chat(bot_id)

query = 'Your query here'
image_paths=['/home/muzammil/PycharmProjects/nvidia.jpg']
response = trainer._get_vision_response(query, image_paths, str(bot_id),str(vision_id))
print('Response: ', response)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

longtrainer-0.1.7.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

longtrainer-0.1.7-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file longtrainer-0.1.7.tar.gz.

File metadata

  • Download URL: longtrainer-0.1.7.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for longtrainer-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a1adfa2f71fb2ede2eb6c53bcbeef988ef55224a595a47066d1895ad462c5882
MD5 365d157c79bcf1f850cf74f876553a4c
BLAKE2b-256 972ce033db8e1a8610d6e074a33eec4a7280985f54f99b86534f454e18a27c2c

See more details on using hashes here.

File details

Details for the file longtrainer-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: longtrainer-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for longtrainer-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 759c650de46a521492e72d7f25e5e202569559ceed6a262ee392a265399a36be
MD5 c221693e6ef58cd1f97f2515f44b5913
BLAKE2b-256 158757bb58e17de3d951cb540c229bcb3c5c48d65565139fa0f2dd94f55cde87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page