Skip to main content

llama-index llms modelscope integration

Project description

LlamaIndex Llms Integration: ModelScope

Installation

To install the required package, run:

!pip install llama-index-llms-modelscope

Basic Usage

Initialize the ModelScopeLLM

To use the ModelScopeLLM model, create an instance by specifying the model name and revision:

import sys
from llama_index.llms.modelscope import ModelScopeLLM

llm = ModelScopeLLM(model_name="qwen/Qwen3-8B", model_revision="master")

Generate Completions

To generate a text completion for a prompt, use the complete method:

rsp = llm.complete("Hello, who are you?")
print(rsp)

Using Message Requests

You can chat with the model by using a list of messages. Here’s how to set it up:

from llama_index.core.base.llms.types import MessageRole, ChatMessage

messages = [
    ChatMessage(
        role=MessageRole.SYSTEM, content="You are a helpful assistant."
    ),
    ChatMessage(role=MessageRole.USER, content="How to make cake?"),
]
resp = llm.chat(messages)
print(resp)

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/modelscope/

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

llama_index_llms_modelscope-0.5.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_modelscope-0.5.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_modelscope-0.5.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.5.0.tar.gz
Algorithm Hash digest
SHA256 6003f0146f307b95b2739523022428f4f8692c24bc9dfaee766af4f17248a33a
MD5 4b2dbe266e2e5ce42d2c680db623b54a
BLAKE2b-256 003037251c202b6b5f7a9495e463c9fb7948b58b3b27f06d0bcc0b97d6055144

See more details on using hashes here.

File details

Details for the file llama_index_llms_modelscope-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf4af93594e28bfb1017d8752dcc690c07b5f49df1b527efa83ffe8f54d27433
MD5 5a96458b6c1114185b6c225336fb2662
BLAKE2b-256 fdbf70b137936c23abfcec47b78ea784a422526083652868db1d93b7dbe84126

See more details on using hashes here.

Supported by

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