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

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: llama_index_llms_modelscope-0.3.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for llama_index_llms_modelscope-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1edf503f1fa043c0ba63e83d1176cbe24e56aa56ecf735f6c4f8390188517eb0
MD5 5115240f87c31c2e49cd561a858c99bf
BLAKE2b-256 7ba3fcdd4d39d3008c3a4f224ac34029ddf13c4210c6c741bcd3400c909a101a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_llms_modelscope-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d08fa8460c44a1655883210ff3cd988bd2ce2ddba183bf4712ba8eec0690272
MD5 072727db138160e48ec126fc07568f2b
BLAKE2b-256 05513d0c1040b8badf5a03a940f1d9ec74a9e7941ff3111d86f5385792ae6a98

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