Metadata-Version: 2.1
Name: llama-index-llms-modelscope
Version: 0.2.2
Summary: llama-index llms modelscope integration
License: MIT
Author: ModelScope
Author-email: modelscope@list.alibaba-inc.com
Requires-Python: >=3.8.1,<3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: llama-index-core (>=0.11.0,<0.12.0)
Requires-Dist: modelscope (>=1.12.0)
Requires-Dist: torch (>=2.1.2,<3.0.0)
Requires-Dist: transformers[torch] (>=4.37.0,<5.0.0)
Description-Content-Type: text/markdown

# LlamaIndex Llms Integration: ModelScope

## Installation

To install the required package, run:

```bash
!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:

```python
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:

```python
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:

```python
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/

