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.4.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f6b9bb29596b7c36cc4b40ab0a9ad9cb9948b5b9b370e1426ddb285508b298e3
MD5 ab9d06c24eff2564aa3ed4a41950b122
BLAKE2b-256 322fa24698d9a9bbc4f277492e78d20616f7ec9b1a718e9f5a2c0579a8781250

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4aad21db1a2456c1bdc062bda548c11ccbe8a441b7a68974c0e26c6fdb191f02
MD5 6886c690c11c43b83d4a25aa8debb04f
BLAKE2b-256 38d3f5b2efed52df98a236385bffbe52d52ca670d87cd8ff2d367e20c89c1234

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