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/Qwen1.5-7B-Chat", 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.2.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: llama_index_llms_modelscope-0.2.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-1014-azure

File hashes

Hashes for llama_index_llms_modelscope-0.2.2.tar.gz
Algorithm Hash digest
SHA256 bda9ed008a04e4d5f9982bb2b8c56938923803015efe2fc35f32cb29bf7bb046
MD5 550e6cc4a49774c82d502ed314f3c115
BLAKE2b-256 1a73bca389d096798b5992dc88b947d8345b2b151eaaa3d7d7c523f950c35fa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16c5e8f899c291d2cfaedfb46fbc68aa41021c3438a59be9ddcae2fcbb692bf8
MD5 d1c0a9483aae6946fdde3dffca041da5
BLAKE2b-256 b40cdcd80bce44be64f7bf932aeb8af0d712cabe5220f20320a340ced7309779

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page