Skip to main content

An integration package connecting ModelScope and LangChain

Project description

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_modelscope_integration-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file langchain_modelscope_integration-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langchain_modelscope_integration-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e50fc9eb6b7b187a73ce535cdfd49e442f3d90c27e1d570b786549e3ee508f9
MD5 f510f6dfcb05654fda95907d4eeeb395
BLAKE2b-256 06f4480da31d8a01a69a76122e1bf32a8a27c865b2de21e3483217ea93cfc3d8

See more details on using hashes here.

File details

Details for the file langchain_modelscope_integration-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_modelscope_integration-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94ebfdba8526fc1165406ca3fa0566a0a237f890d283cffacf0dbc1e45e6c42e
MD5 d4f5b5a7af68908313e8093ccebdda29
BLAKE2b-256 621baf5aa7ecb1ba363da978410d7ea58b2183b45a9cad7a056f1ad9cec22bbc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page