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
- ✅ 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
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.1.6.tar.gz
(11.6 kB
view hashes)
Built Distribution
Close
Hashes for longtrainer-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f9a6ab76d677604e16c8f3716820e78c0233014eae891691fb006a2ceb5193e |
|
MD5 | 8f4b3ab7a34dbbd4c1d92d79d8b334e7 |
|
BLAKE2b-256 | 23691f601f01da81c22c9253a43aca9b1737429f340ba9b630a24484ad84b9bd |