Metadata-Version: 2.1
Name: langchain-modelscope-integration
Version: 0.1.0
Summary: An integration package connecting ModelScope and LangChain
Home-page: https://github.com/modelscope/langchain-modelscope
License: Apache-2.0
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: Apache Software 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: langchain-core (>=0.3.15,<0.4.0)
Requires-Dist: langchain-openai (>=0.2.14,<0.3.0)
Requires-Dist: modelscope (>=1.21.0,<2.0.0)
Requires-Dist: openai (>=1.58.1,<2.0.0)
Project-URL: Repository, https://github.com/modelscope/langchain-modelscope
Description-Content-Type: text/markdown

# langchain-modelscope-integration

This package contains the LangChain integration with ModelScope

## Installation

```bash
pip install -U langchain-modelscope-integration
```

Head to [ModelScope](https://modelscope.cn/) to sign up to ModelScope and generate an [SDK token](https://modelscope.cn/my/myaccesstoken). Once you've done this set the `MODELSCOPE_SDK_TOKEN` environment variable:

```bash
export MODELSCOPE_SDK_TOKEN=<your_sdk_token>
```

## Chat Models

`ModelScopeChatEndpoint` class exposes chat models from ModelScope. See available models [here](https://www.modelscope.cn/docs/model-service/API-Inference/intro).

```python
from langchain_modelscope import ModelScopeChatEndpoint

llm = ModelScopeChatEndpoint(model="Qwen/Qwen2.5-Coder-32B-Instruct")
llm.invoke("Sing a ballad of LangChain.")
```

## Embeddings

`ModelScopeEmbeddings` class exposes embeddings from ModelScope.

```python
from langchain_modelscope import ModelScopeEmbeddings

embeddings = ModelScopeEmbeddings(model_id="damo/nlp_corom_sentence-embedding_english-base")
embeddings.embed_query("What is the meaning of life?")
```

## LLMs
`ModelScopeLLM` class exposes LLMs from ModelScope.

```python
from langchain_modelscope import ModelScopeLLM

llm = ModelScopeLLM(model="Qwen/Qwen2.5-Coder-32B-Instruct")
llm.invoke("The meaning of life is")
```

