Skip to content

modelscope/langchain-modelscope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

langchain-modelscope-integration

This package contains the LangChain integration with ModelScope

Installation

pip install -U langchain-modelscope-integration

Head to ModelScope to sign up to ModelScope and generate an SDK token. Once you've done this set the MODELSCOPE_SDK_TOKEN environment variable:

export MODELSCOPE_SDK_TOKEN=<your_sdk_token>

Chat Models

ModelScopeChatEndpoint class exposes chat models from ModelScope. See available models here.

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.

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.

from langchain_modelscope import ModelScopeLLM

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

About

Langchain integration for ModelScope

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published