Metadata-Version: 2.1
Name: langchain-together
Version: 0.0.2.post2
Summary: An integration package connecting Together and LangChain
Home-page: https://github.com/langchain-ai/langchain
License: MIT
Requires-Python: >=3.8.1,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: aiohttp (>=3.9.1,<4.0.0)
Requires-Dist: langchain-core (>=0.1,<0.2)
Requires-Dist: requests (>=2,<3)
Requires-Dist: together (>=0.2.10,<0.3.0)
Project-URL: Repository, https://github.com/langchain-ai/langchain
Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/partners/together
Description-Content-Type: text/markdown

# langchain-together

This package contains the LangChain integration for Together's generative models.

## Installation

```sh
pip install -U langchain-together
```

## Embeddings

You can use Together's embedding models through `TogetherEmbeddings` class.

```py
from langchain_together import TogetherEmbeddings

embeddings = TogetherEmbeddings(
    model='togethercomputer/m2-bert-80M-8k-retrieval'
)
embeddings.embed_query("What is a large language model?")
```

## LLMs

You can use Together's generative AI models as Langchain LLMs:

```py
from langchain_together import Together
from langchain_core.prompts import PromptTemplate

llm = Together(
    model="togethercomputer/RedPajama-INCITE-7B-Base",
    temperature=0.7,
    max_tokens=64,
    top_k=1,
    # together_api_key="..."
)

template = """Question: {question}
Answer: """
prompt = PromptTemplate.from_template(template)

chain = prompt | llm

question = "Who was the president in the year Justin Beiber was born?"
print(chain.invoke({"question": question}))
```

