Add your description here
Project description
🚀 Huggingface-TogetherAI LangChain Wrapper
A LangChain integration for DeepSeek-R1 and Meta Llama-3.3-70B-Instruct-Turbo models via Hugging Face's Inference API, enabling seamless interaction with state-of-the-art language models.
✨ Features
- 🚀 Custom LangChain Chat Model – Optimized for Hugging Face + Together AI.
- ⚡ Sync & Async Support – Run queries in synchronous or asynchronous mode.
- 🌊 Streaming Capabilities – Supports token streaming for real-time responses.
- 🛠️ Tool Calling & Structured Output – Enables function calling and JSON outputs.
- 🔧 Configurable Model Parameters – Fine-tune temperature, max tokens, etc.
📦 Installation
pip install huggingface-togetherai
🚀 Quick Start
from huggingface_togetherai import ChatHuggingFaceTogetherAI
hf_token = "your_huggingface_token"
hf_llm = ChatHuggingFaceTogetherAI(
model="deepseek-ai/DeepSeek-R1",
hf_token=hf_token
)
response = hf_llm.invoke("Hi!")
print(response)
🤔 Why Use Huggingface-TogetherAI?
In LangChain, the HuggingFaceEndpoint class is typically used for Hugging Face models:
from langchain_huggingface import HuggingFaceEndpoint
from langchain_huggingface.chat_models import ChatHuggingFace
hf_endpoint = HuggingFaceEndpoint(
repo_id="deepseek-ai/DeepSeek-R1",
task="text-generation",
huggingfacehub_api_token=hf_token
)
langchain_llm = ChatHuggingFace(llm=hf_endpoint)
langchain_llm.invoke("Hello")
However, this results in an error:
The model deepseek-ai/DeepSeek-R1 is too large to be loaded automatically (688GB > 10GB).
✅ The Better Alternative: Huggingface-TogetherAI
With Huggingface-TogetherAI, you can seamlessly use large models without running into memory issues:
from huggingface_togetherai import ChatHuggingFaceTogetherAI
hf_llm = ChatHuggingFaceTogetherAI(
model="deepseek-ai/DeepSeek-R1",
hf_token=hf_token,
other_params...
)
response = hf_llm.invoke("Hello")
print(response) # Output: '<think>\n\n</think>\n\nHello! How can I assist you today? 😊'
🎉 Good News!
✅ You can leverage all Langchain functionalities for standard LLMs with this package.
📜 License
This project is licensed under the MIT License. See the LICENSE file for more details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huggingface_togetherai-1.1.1.tar.gz.
File metadata
- Download URL: huggingface_togetherai-1.1.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a284e041e04fb075a466c46c64520332027290ebe375f11d72385231bcce96ca
|
|
| MD5 |
3398b22e6e24f0897cb41680ec90648e
|
|
| BLAKE2b-256 |
6e44b5229b5e6c8e1e6e1ca92141b7bd32e88b4ade4258c3dd403855fa992488
|
File details
Details for the file huggingface_togetherai-1.1.1-py3-none-any.whl.
File metadata
- Download URL: huggingface_togetherai-1.1.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e17565cdd78269152410d71771ed213393bd5fee4b5a717b7aec63c04714b22d
|
|
| MD5 |
10c9159479f800cd8da89bd778431a30
|
|
| BLAKE2b-256 |
e5d4884e69ef843294c3a9b56ddfe972d64b063f6d41d1e3aaf1dc1f4c33d3c0
|