Production 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/', 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:
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:
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}},
}
Project details
Release history Release notifications | RSS feed
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.2.3.tar.gz
(19.9 kB
view details)
Built Distribution
File details
Details for the file longtrainer-0.2.3.tar.gz
.
File metadata
- Download URL: longtrainer-0.2.3.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91d1df713f7e813db2f6730c2a2b82f24af6ce2ef8b96cb61e6d74d21ae7da3 |
|
MD5 | 10dcd44094458214666437835a92f47b |
|
BLAKE2b-256 | 37af8bf19ba0c37fe2f814cbb6bb20ba1fdfdf0ebf3aec2e2172574de372ef62 |
File details
Details for the file longtrainer-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: longtrainer-0.2.3-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 820dead23a8ccd41fd8386bd0d53ad8bc25a1bd41956c53523b3b9a4d6606f9e |
|
MD5 | a197065c8defd1f4f50c58e5423404df |
|
BLAKE2b-256 | fde9b5b1fafd1ab1e2b8e20261aa5430b604561e7ea966ca708eed7ead43abea |