https://github.com/modelscope/langchain-modelscope
Langchain integration for ModelScope
https://github.com/modelscope/langchain-modelscope
Last synced: 7 months ago
JSON representation
Langchain integration for ModelScope
- Host: GitHub
- URL: https://github.com/modelscope/langchain-modelscope
- Owner: modelscope
- License: apache-2.0
- Created: 2024-12-27T02:57:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-27T08:32:50.000Z (about 1 year ago)
- Last Synced: 2025-06-04T13:45:54.714Z (7 months ago)
- Language: Python
- Size: 64.5 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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=
```
## 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")
```