{"id":25495494,"url":"https://github.com/mrqadeer/huggingface_togetherai","last_synced_at":"2025-11-09T16:30:13.449Z","repository":{"id":277175203,"uuid":"931510513","full_name":"mrqadeer/huggingface_togetherai","owner":"mrqadeer","description":"A powerful LangChain wrapper for integrating Hugging Face API with Together AI, enabling seamless access to cutting-edge DeepSeek-R1 and Meta LLaMA models (e.g., meta-llama/Llama-3.3-70B-Instruct-Turbo).","archived":false,"fork":false,"pushed_at":"2025-02-12T14:08:09.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T15:27:34.893Z","etag":null,"topics":["deepseek-r1","huggingface","langchain-python","meta-llama","togetherai"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/huggingface-togetherai/0.1.0/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrqadeer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-12T11:59:37.000Z","updated_at":"2025-02-12T14:08:13.000Z","dependencies_parsed_at":"2025-02-12T15:27:37.954Z","dependency_job_id":"09acd3c2-0010-4933-9aa3-7f63ab1334fe","html_url":"https://github.com/mrqadeer/huggingface_togetherai","commit_stats":null,"previous_names":["mrqadeer/huggingface_togetherai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrqadeer%2Fhuggingface_togetherai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrqadeer%2Fhuggingface_togetherai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrqadeer%2Fhuggingface_togetherai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrqadeer%2Fhuggingface_togetherai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrqadeer","download_url":"https://codeload.github.com/mrqadeer/huggingface_togetherai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576845,"owners_count":19662112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek-r1","huggingface","langchain-python","meta-llama","togetherai"],"created_at":"2025-02-19T00:37:03.271Z","updated_at":"2025-11-09T16:30:13.393Z","avatar_url":"https://github.com/mrqadeer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Huggingface-TogetherAI LangChain Wrapper\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/)\n\nA **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.\n\n## ✨ Features\n\n- 🚀 **Custom LangChain Chat Model** – Optimized for Hugging Face + Together AI.\n- ⚡ **Sync \u0026 Async Support** – Run queries in synchronous or asynchronous mode.\n- 🌊 **Streaming Capabilities** – Supports token streaming for real-time responses.\n- 🛠️ **Tool Calling \u0026 Structured Output** – Enables function calling and JSON outputs.\n- 🔧 **Configurable Model Parameters** – Fine-tune temperature, max tokens, etc.\n\n## 📦 Installation\n\n```bash\npip install huggingface-togetherai \n```\n\n## 🚀 Quick Start\n\n```python\nfrom huggingface_togetherai import ChatHuggingFaceTogetherAI\n\nhf_token = \"your_huggingface_token\"\nhf_llm = ChatHuggingFaceTogetherAI(\n    model=\"deepseek-ai/DeepSeek-R1\",\n    hf_token=hf_token\n)\n\nresponse = hf_llm.invoke(\"Hi!\")\nprint(response)\n```\n\n## 🤔 Why Use Huggingface-TogetherAI?\n\nIn **LangChain**, the `HuggingFaceEndpoint` class is typically used for Hugging Face models:\n\n```python\nfrom langchain_huggingface import HuggingFaceEndpoint\nfrom langchain_huggingface.chat_models import ChatHuggingFace\n\nhf_endpoint = HuggingFaceEndpoint(\n    repo_id=\"deepseek-ai/DeepSeek-R1\",\n    task=\"text-generation\",\n    huggingfacehub_api_token=hf_token\n)\n\nlangchain_llm = ChatHuggingFace(llm=hf_endpoint)\nlangchain_llm.invoke(\"Hello\")\n```\n\nHowever, this results in an error:\n\n```\nThe model deepseek-ai/DeepSeek-R1 is too large to be loaded automatically (688GB \u003e 10GB).\n```\n\n### ✅ The Better Alternative: Huggingface-TogetherAI\n\nWith **Huggingface-TogetherAI**, you can seamlessly use large models without running into memory issues:\n\n```python\nfrom huggingface_togetherai import ChatHuggingFaceTogetherAI\n\nhf_llm = ChatHuggingFaceTogetherAI(\n    model=\"deepseek-ai/DeepSeek-R1\",\n    hf_token=hf_token,\n    other_params...\n)\n\nresponse = hf_llm.invoke(\"Hello\")\nprint(response)  # Output: '\u003cthink\u003e\\n\\n\u003c/think\u003e\\n\\nHello! How can I assist you today? 😊'\n```\n\n### 🎉 Good News!\n\n✅ You can leverage **all [Langchain](https://www.langchain.com/) functionalities** for standard LLMs with this package.\n\n## 📜 License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrqadeer%2Fhuggingface_togetherai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrqadeer%2Fhuggingface_togetherai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrqadeer%2Fhuggingface_togetherai/lists"}