Skip to main content

Add your description here

Project description

🚀 Huggingface-TogetherAI LangChain Wrapper

License: MIT Python Version

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


Download files

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

Source Distribution

huggingface_togetherai-1.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

huggingface_togetherai-1.1.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file huggingface_togetherai-1.1.2.tar.gz.

File metadata

  • Download URL: huggingface_togetherai-1.1.2.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

Hashes for huggingface_togetherai-1.1.2.tar.gz
Algorithm Hash digest
SHA256 1d336958acab6bc952312205adc0efdeaba47d3cd5d589fd71f1a0b4c9640677
MD5 33033431fb061872dfd54a013bdabd44
BLAKE2b-256 4011cdbb2d0e4bd685e35312a6d04dd7550c6d6290f905261756fdeb34a87be2

See more details on using hashes here.

File details

Details for the file huggingface_togetherai-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for huggingface_togetherai-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05c7035fc728460fc29c49db718b75b00b576213ba447f3ae0cfa3049c38e592
MD5 89560f9bca7859f9e194d81f915d5695
BLAKE2b-256 ca294fb959f7963b5903b65f280a2005d2ae2fc49dd00bb77bb7b56319e433d2

See more details on using hashes here.

Supported by

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