Qwen (Alibaba Cloud)
Overview
The QwenLLMService integrates Alibaba Cloud's Qwen (Tongyi Qianwen) models. It is highly capable in both English and Chinese and is accessible via the DashScope API.
Installation
pip install piopiy-ai
Prerequisites
- An Alibaba Cloud (DashScope) API key (Get yours here).
- Set your API key in your environment:
export DASHSCOPE_API_KEY="your_api_key_here"
Configuration
QwenLLMService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your DashScope API key. |
model | str | "qwen-plus" | Model identifier (e.g., qwen-max, qwen-turbo). |
base_url | str | "https://dashscope-intl.aliyuncs.com/compatible-mode/v1" | API endpoint. |
Usage
Basic Setup
import os
from piopiy.services.qwen.llm import QwenLLMService
llm = QwenLLMService(
api_key=os.getenv("DASHSCOPE_API_KEY"),
model="qwen-max"
)
Notes
- Multilingual Excellence: Qwen models are particularly strong in East Asian languages while maintaining state-of-the-art performance in English.
- Versatility: Suitable for a wide range of tasks from creative writing to complex reasoning.