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.1.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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.5.1.tar.gz
Algorithm Hash digest
SHA256 a655195295401bd2478f77daa7161c05c05b75c263d6d6d0cb5f58887107e077
MD5 edad58a0e04e7d416b0fd1a16c59cdd9
BLAKE2b-256 f5ef7517b930767a35b3342e8c5ce87448f0178bfd9a68267af8799b242d8362

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5a0ce917f86a24a79b36848eb46fef22aa018e94d7fb3d9aac1a1438d520ce3
MD5 bece38ce3359d2932bd0e5efc8235610
BLAKE2b-256 a2a5c2bc9c24f3ad23e4479b9feab74e5bcdf70b2afa4fa07f0e86c7878699f9

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