LangChain LLM7 Integration
Official LangChain compatibility layer for LLM7 API services.
Installation
pip install langchain-llm7
Features
- 🚀 Native integration with LangChain's BaseChatModel interface
- ⚡ Support for both streaming and non-streaming responses
- 🔧 Customizable model parameters (temperature, max_tokens, stop sequences)
- 📊 Token usage metadata tracking
- 🛠 Robust error handling and retry mechanisms
Usage
Basic Implementation
from langchain_llm7 import ChatLLM7
from langchain_core.messages import HumanMessage
# Initialize with default parameters
llm = ChatLLM7()
# Basic invocation
response = llm.invoke([HumanMessage(content="Hello!")])
print(response.content)
Streaming Responses
# Enable streaming
llm = ChatLLM7(streaming=True)
for chunk in llm.stream([HumanMessage(content="Tell me about quantum computing")]):
print(chunk.content, end="", flush=True)
Advanced Configuration
# Custom model configuration
llm = ChatLLM7(
model="llama-3.3-70b-instruct-fp8-fast",
temperature=0.7,
max_tokens=500,
stop=["\n", "Observation:"],
timeout=45
)
Parameters
| Parameter | Description | Default |
|---|---|---|
model |
Model version to use | "gpt-4o-mini-2024-07-18" |
base_url |
API endpoint URL | "https://api.llm7.io/v1" |
temperature |
Sampling temperature (0.0-2.0) | 1.0 |
max_tokens |
Maximum number of tokens to generate | None |
timeout |
Request timeout in seconds | 120 |
stop |
Stop sequences for response generation | None |
streaming |
Enable streaming response mode | False |
Error Handling
The library provides detailed error messages for:
- API communication failures
- Invalid message formats
- Unsupported message types
- Response parsing errors
try:
llm.invoke([{"invalid": "message"}])
except ValueError as e:
print(f"Error: {e}")
Testing
To run the test suite:
pip install pytest
pytest tests/
Documentation
For complete documentation see:
Contributing
Contributions are welcome! Please open an issue or submit a PR:
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contact
Eugene Evstafev
Metadata
Release files for langchain-llm7 2025.10.271728
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_llm7-2025.10.271728.tar.gz | 11.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_llm7-2025.10.271728-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.1 kB
Release files / langchain_llm7-2025.10.271728.tar.gz
| Download URL | langchain_llm7-2025.10.271728.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fc5ff82546b8cad098fd0a791f4bf506b53d7d64d91ed6a39cd5870f0f60756
|
|
BLAKE2b-256 checksum How to use checksums |
2a8f8c8b369135e55f25315c1568a5ede4ee59ad9bc3930e9cd0d1d51c52121a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Release files / langchain_llm7-2025.10.271728-py3-none-any.whl
| Download URL | langchain_llm7-2025.10.271728-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
032ee3f13f26b931a9f68b44f6ab63ed7cc956ed7b04e95e7b46ce97e3df8d96
|
|
BLAKE2b-256 checksum How to use checksums |
0cb6e2701842466c3b5cdd5ad7edd16390e237dd2b5540ffd395d3e6c335c938
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|