AlibabaCloud-PaiEas¶
If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.
In [ ]:
Copied!
%pip install llama-index-llms-paieas
%pip install llama-index-llms-paieas
Requirement already satisfied: llama-index-llms-paieas in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (0.1.16) Requirement already satisfied: llama-index-core<0.11.0,>=0.10.57 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-llms-paieas) (0.10.58) Requirement already satisfied: llama-index-llms-openai<0.2.0,>=0.1.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-llms-paieas) (0.1.27) Requirement already satisfied: PyYAML>=6.0.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (6.0.1) Requirement already satisfied: SQLAlchemy>=1.4.49 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.0.31) Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.9.5) Requirement already satisfied: dataclasses-json in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.6.7) Requirement already satisfied: deprecated>=1.2.9.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.2.14) Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.0.8) Requirement already satisfied: fsspec>=2023.5.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2024.6.1) Requirement already satisfied: httpx in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.27.0) Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.6.0) Requirement already satisfied: networkx>=3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.1) Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.8.1) Requirement already satisfied: numpy<2.0.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.24.4) Requirement already satisfied: openai>=1.1.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.37.1) Requirement already satisfied: pandas in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.0.3) Requirement already satisfied: pillow>=9.0.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (10.4.0) Requirement already satisfied: requests>=2.31.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.32.3) Requirement already satisfied: tenacity!=8.4.0,<9.0.0,>=8.2.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (8.5.0) Requirement already satisfied: tiktoken>=0.3.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.7.0) Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (4.66.4) Requirement already satisfied: typing-extensions>=4.5.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (4.12.2) Requirement already satisfied: typing-inspect>=0.8.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.9.0) Requirement already satisfied: wrapt in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.16.0) Requirement already satisfied: aiosignal>=1.1.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.3.1) Requirement already satisfied: attrs>=17.3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (23.2.0) Requirement already satisfied: frozenlist>=1.1.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.4.1) Requirement already satisfied: multidict<7.0,>=4.5 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (6.0.5) Requirement already satisfied: yarl<2.0,>=1.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.9.4) Requirement already satisfied: async-timeout<5.0,>=4.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (4.0.3) Requirement already satisfied: click in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (8.1.7) Requirement already satisfied: joblib in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.4.2) Requirement already satisfied: regex>=2021.8.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2024.7.24) Requirement already satisfied: anyio<5,>=3.5.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (4.4.0) Requirement already satisfied: distro<2,>=1.7.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.9.0) Requirement already satisfied: pydantic<3,>=1.9.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.8.2) Requirement already satisfied: sniffio in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.3.1) Requirement already satisfied: certifi in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2024.7.4) Requirement already satisfied: httpcore==1.* in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.0.5) Requirement already satisfied: idna in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.7) Requirement already satisfied: h11<0.15,>=0.13 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpcore==1.*->httpx->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.14.0) Requirement already satisfied: charset-normalizer<4,>=2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.3.2) Requirement already satisfied: urllib3<3,>=1.21.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from requests>=2.31.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.2.2) Requirement already satisfied: greenlet!=0.4.17 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.0.3) Requirement already satisfied: mypy-extensions>=0.3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from typing-inspect>=0.8.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.0.0) Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from dataclasses-json->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (3.21.3) Requirement already satisfied: python-dateutil>=2.8.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2024.1) Requirement already satisfied: tzdata>=2022.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2024.1) Requirement already satisfied: exceptiongroup>=1.0.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from anyio<5,>=3.5.0->openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.2.2) Requirement already satisfied: packaging>=17.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (24.1) Requirement already satisfied: annotated-types>=0.4.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pydantic<3,>=1.9.0->openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (0.7.0) Requirement already satisfied: pydantic-core==2.20.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pydantic<3,>=1.9.0->openai>=1.1.0->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (2.20.1) Requirement already satisfied: six>=1.5 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas->llama-index-core<0.11.0,>=0.10.57->llama-index-llms-paieas) (1.16.0) Note: you may need to restart the kernel to use updated packages.
In [ ]:
Copied!
!pip install llama-index
!pip install llama-index
Collecting llama-index Downloading llama_index-0.10.58-py3-none-any.whl.metadata (11 kB) Collecting llama-index-agent-openai<0.3.0,>=0.1.4 (from llama-index) Downloading llama_index_agent_openai-0.2.9-py3-none-any.whl.metadata (729 bytes) Collecting llama-index-cli<0.2.0,>=0.1.2 (from llama-index) Downloading llama_index_cli-0.1.13-py3-none-any.whl.metadata (1.5 kB) Requirement already satisfied: llama-index-core==0.10.58 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index) (0.10.58) Collecting llama-index-embeddings-openai<0.2.0,>=0.1.5 (from llama-index) Downloading llama_index_embeddings_openai-0.1.11-py3-none-any.whl.metadata (655 bytes) Collecting llama-index-indices-managed-llama-cloud>=0.2.0 (from llama-index) Downloading llama_index_indices_managed_llama_cloud-0.2.7-py3-none-any.whl.metadata (3.8 kB) Collecting llama-index-legacy<0.10.0,>=0.9.48 (from llama-index) Downloading llama_index_legacy-0.9.48-py3-none-any.whl.metadata (8.5 kB) Requirement already satisfied: llama-index-llms-openai<0.2.0,>=0.1.27 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index) (0.1.27) Collecting llama-index-multi-modal-llms-openai<0.2.0,>=0.1.3 (from llama-index) Downloading llama_index_multi_modal_llms_openai-0.1.8-py3-none-any.whl.metadata (728 bytes) Collecting llama-index-program-openai<0.2.0,>=0.1.3 (from llama-index) Downloading llama_index_program_openai-0.1.7-py3-none-any.whl.metadata (760 bytes) Collecting llama-index-question-gen-openai<0.2.0,>=0.1.2 (from llama-index) Downloading llama_index_question_gen_openai-0.1.3-py3-none-any.whl.metadata (785 bytes) Collecting llama-index-readers-file<0.2.0,>=0.1.4 (from llama-index) Downloading llama_index_readers_file-0.1.31-py3-none-any.whl.metadata (5.4 kB) Collecting llama-index-readers-llama-parse>=0.1.2 (from llama-index) Downloading llama_index_readers_llama_parse-0.1.6-py3-none-any.whl.metadata (3.6 kB) Requirement already satisfied: PyYAML>=6.0.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (6.0.1) Requirement already satisfied: SQLAlchemy>=1.4.49 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.58->llama-index) (2.0.31) Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (3.9.5) Requirement already satisfied: dataclasses-json in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (0.6.7) Requirement already satisfied: deprecated>=1.2.9.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.2.14) Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.0.8) Requirement already satisfied: fsspec>=2023.5.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (2024.6.1) Requirement already satisfied: httpx in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (0.27.0) Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.6.0) Requirement already satisfied: networkx>=3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (3.1) Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (3.8.1) Requirement already satisfied: numpy<2.0.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.24.4) Requirement already satisfied: openai>=1.1.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.37.1) Requirement already satisfied: pandas in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (2.0.3) Requirement already satisfied: pillow>=9.0.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (10.4.0) Requirement already satisfied: requests>=2.31.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (2.32.3) Requirement already satisfied: tenacity!=8.4.0,<9.0.0,>=8.2.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (8.5.0) Requirement already satisfied: tiktoken>=0.3.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (0.7.0) Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (4.66.4) Requirement already satisfied: typing-extensions>=4.5.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (4.12.2) Requirement already satisfied: typing-inspect>=0.8.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (0.9.0) Requirement already satisfied: wrapt in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-core==0.10.58->llama-index) (1.16.0) Collecting llama-cloud>=0.0.11 (from llama-index-indices-managed-llama-cloud>=0.2.0->llama-index) Downloading llama_cloud-0.0.11-py3-none-any.whl.metadata (751 bytes) Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (4.12.3) Collecting pypdf<5.0.0,>=4.0.1 (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) Downloading pypdf-4.3.1-py3-none-any.whl.metadata (7.4 kB) Collecting striprtf<0.0.27,>=0.0.26 (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) Downloading striprtf-0.0.26-py3-none-any.whl.metadata (2.1 kB) Collecting llama-parse>=0.4.0 (from llama-index-readers-llama-parse>=0.1.2->llama-index) Downloading llama_parse-0.4.9-py3-none-any.whl.metadata (4.4 kB) Requirement already satisfied: aiosignal>=1.1.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (1.3.1) Requirement already satisfied: attrs>=17.3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (23.2.0) Requirement already satisfied: frozenlist>=1.1.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (1.4.1) Requirement already satisfied: multidict<7.0,>=4.5 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (6.0.5) Requirement already satisfied: yarl<2.0,>=1.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (1.9.4) Requirement already satisfied: async-timeout<5.0,>=4.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.58->llama-index) (4.0.3) Requirement already satisfied: soupsieve>1.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (2.5) Requirement already satisfied: pydantic>=1.10 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from llama-cloud>=0.0.11->llama-index-indices-managed-llama-cloud>=0.2.0->llama-index) (2.8.2) Requirement already satisfied: anyio in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core==0.10.58->llama-index) (4.4.0) Requirement already satisfied: certifi in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core==0.10.58->llama-index) (2024.7.4) Requirement already satisfied: httpcore==1.* in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core==0.10.58->llama-index) (1.0.5) Requirement already satisfied: idna in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core==0.10.58->llama-index) (3.7) Requirement already satisfied: sniffio in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpx->llama-index-core==0.10.58->llama-index) (1.3.1) Requirement already satisfied: h11<0.15,>=0.13 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from httpcore==1.*->httpx->llama-index-core==0.10.58->llama-index) (0.14.0) Requirement already satisfied: click in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.58->llama-index) (8.1.7) Requirement already satisfied: joblib in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.58->llama-index) (1.4.2) Requirement already satisfied: regex>=2021.8.3 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.58->llama-index) (2024.7.24) Requirement already satisfied: distro<2,>=1.7.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from openai>=1.1.0->llama-index-core==0.10.58->llama-index) (1.9.0) Requirement already satisfied: charset-normalizer<4,>=2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from requests>=2.31.0->llama-index-core==0.10.58->llama-index) (3.3.2) Requirement already satisfied: urllib3<3,>=1.21.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from requests>=2.31.0->llama-index-core==0.10.58->llama-index) (2.2.2) Requirement already satisfied: greenlet!=0.4.17 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.58->llama-index) (3.0.3) Requirement already satisfied: mypy-extensions>=0.3.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from typing-inspect>=0.8.0->llama-index-core==0.10.58->llama-index) (1.0.0) Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from dataclasses-json->llama-index-core==0.10.58->llama-index) (3.21.3) Requirement already satisfied: python-dateutil>=2.8.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core==0.10.58->llama-index) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core==0.10.58->llama-index) (2024.1) Requirement already satisfied: tzdata>=2022.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pandas->llama-index-core==0.10.58->llama-index) (2024.1) Requirement already satisfied: exceptiongroup>=1.0.2 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from anyio->httpx->llama-index-core==0.10.58->llama-index) (1.2.2) Requirement already satisfied: packaging>=17.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core==0.10.58->llama-index) (24.1) Requirement already satisfied: annotated-types>=0.4.0 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pydantic>=1.10->llama-cloud>=0.0.11->llama-index-indices-managed-llama-cloud>=0.2.0->llama-index) (0.7.0) Requirement already satisfied: pydantic-core==2.20.1 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from pydantic>=1.10->llama-cloud>=0.0.11->llama-index-indices-managed-llama-cloud>=0.2.0->llama-index) (2.20.1) Requirement already satisfied: six>=1.5 in /mnt/llm/xiaowen/miniconda3/envs/llama_env/lib/python3.9/site-packages (from python-dateutil>=2.8.2->pandas->llama-index-core==0.10.58->llama-index) (1.16.0) Downloading llama_index-0.10.58-py3-none-any.whl (6.8 kB) Downloading llama_index_agent_openai-0.2.9-py3-none-any.whl (13 kB) Downloading llama_index_cli-0.1.13-py3-none-any.whl (27 kB) Downloading llama_index_embeddings_openai-0.1.11-py3-none-any.whl (6.3 kB) Downloading llama_index_indices_managed_llama_cloud-0.2.7-py3-none-any.whl (9.5 kB) Downloading llama_index_legacy-0.9.48-py3-none-any.whl (2.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 42.6 MB/s eta 0:00:00:00:01 Downloading llama_index_multi_modal_llms_openai-0.1.8-py3-none-any.whl (5.9 kB) Downloading llama_index_program_openai-0.1.7-py3-none-any.whl (5.3 kB) Downloading llama_index_question_gen_openai-0.1.3-py3-none-any.whl (2.9 kB) Downloading llama_index_readers_file-0.1.31-py3-none-any.whl (38 kB) Downloading llama_index_readers_llama_parse-0.1.6-py3-none-any.whl (2.5 kB) Downloading llama_cloud-0.0.11-py3-none-any.whl (154 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 154.8/154.8 kB 5.8 MB/s eta 0:00:00 Downloading llama_parse-0.4.9-py3-none-any.whl (9.4 kB) Downloading pypdf-4.3.1-py3-none-any.whl (295 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 295.8/295.8 kB 12.1 MB/s eta 0:00:00 Downloading striprtf-0.0.26-py3-none-any.whl (6.9 kB) Installing collected packages: striprtf, pypdf, llama-cloud, llama-index-legacy, llama-parse, llama-index-readers-file, llama-index-indices-managed-llama-cloud, llama-index-embeddings-openai, llama-index-readers-llama-parse, llama-index-multi-modal-llms-openai, llama-index-cli, llama-index-agent-openai, llama-index-program-openai, llama-index-question-gen-openai, llama-index Successfully installed llama-cloud-0.0.11 llama-index-0.10.58 llama-index-agent-openai-0.2.9 llama-index-cli-0.1.13 llama-index-embeddings-openai-0.1.11 llama-index-indices-managed-llama-cloud-0.2.7 llama-index-legacy-0.9.48 llama-index-multi-modal-llms-openai-0.1.8 llama-index-program-openai-0.1.7 llama-index-question-gen-openai-0.1.3 llama-index-readers-file-0.1.31 llama-index-readers-llama-parse-0.1.6 llama-parse-0.4.9 pypdf-4.3.1 striprtf-0.0.26
Basic Usage¶
You will need to get an API key and url from AlibabaCloud PAI Eas. Once you have one, you can either pass it explicity to the model, or use the PAIEAS_API_KEY
and PAIEAS_API_BASE
environment variable.
In [ ]:
Copied!
!export PAIEAS_API_KEY=your_service_token
!export PAIEAS_API_BASE=your_access_address
!export PAIEAS_API_KEY=your_service_token
!export PAIEAS_API_BASE=your_access_address
Call complete
with a prompt¶
In [ ]:
Copied!
from llama_index.llms.paieas import PaiEas
llm = PaiEas()
resp = llm.complete("Write a poem about a magic backpack")
from llama_index.llms.paieas import PaiEas
llm = PaiEas()
resp = llm.complete("Write a poem about a magic backpack")
In [ ]:
Copied!
print(resp)
print(resp)
In a land of wonder and delight, Where dreams and magic come to light, There lived a young wanderer, with a heart full of glee, And in his backpack, a secret did he hold, A magic item, a treasure to see. This backpack, oh how it shimmered and glowed, With an enchantment that did flow, A subtle power, hidden from the eye, But to the owner, it was a sight so high. Its weight was light, yet held a weight of its own, As if it carried stories yet unknown, It could shrink when empty, grow when full of good, A true companion, a faithful tool. With a simple rustle, it spoke in a hush, Guiding the youth on his journey rough, It would expand to carry mountains, or carry a breeze, Its magic knew no bounds, no limits to please. Inside, it held treasures beyond measure, Secrets from the universe, indeed, A compass for lost directions, a lamp in the dark, A friend in need, a magic backpack's mark. It helped the wanderer through forests, across rivers wide, Assisted him in times of strife and pride, It taught him lessons, showed him the way, And in its embrace, he felt okay. So here's to the magic backpack, a wondrous thing, To the young traveler, it's a symphony of wings, A magic that exists, not just in our minds, But in the world, where the explorers find.
Call chat
with a list of messages¶
In [ ]:
Copied!
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.chat(messages)
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.chat(messages)
In [ ]:
Copied!
print(resp)
print(resp)
assistant: As a pirate, I be known as Jack "Sparrow" Silverhand, or simply Jack the Pirate. Ye can call me that if ye be feelin' adventurous!
Streaming¶
Using stream_complete
endpoint
In [ ]:
Copied!
resp = llm.stream_complete("Paul Graham is ")
resp = llm.stream_complete("Paul Graham is ")
In [ ]:
Copied!
for r in resp:
print(r.delta, end="")
for r in resp:
print(r.delta, end="")
Paul Graham is a computer scientist, entrepreneur, and investor. He was born on June 24, 1955, in New York City. Graham co-founded the online coding platform HackerRank, the startup venture firm Y Combinator, and Viaweb, which later became Yahoo! GeoMaps. He is also known for his influential writing, including the book "Hackers & Painters" and his blog, where he shares insights on technology, startups, and entrepreneurship. Graham is considered a prominent figure in the tech industry and is often cited for his early contributions to the growth of the Silicon Valley ecosystem.
Using stream_chat
endpoint
In [ ]:
Copied!
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.stream_chat(messages)
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality"
),
ChatMessage(role="user", content="What is your name"),
]
resp = llm.stream_chat(messages)
In [ ]:
Copied!
for r in resp:
print(r.delta, end="")
for r in resp:
print(r.delta, end="")
As a pirate, I don't have a fancy name like a landlubber might. I go by the fearsome moniker "Blackbeard" or "Captain Jack" to strike fear into the hearts of my enemies and justify my swashbuckling ways. But remember, I'm just a friendly AI here to chat, not to cause any real harm!
Async¶
In [ ]:
Copied!
resp = await llm.acomplete("Paul Graham is ")
resp = await llm.acomplete("Paul Graham is ")
In [ ]:
Copied!
print(resp)
print(resp)
Paul Graham is a renowned entrepreneur, computer scientist, and venture capitalist. Born on April 24, 1973, in Massachusetts, USA, he is best known for co-founding Y Combinator, a startup accelerator that has fueled many successful companies such as Airbnb, Dropbox, and GitHub. Graham is also the author of several influential books, including "Hackers and Painters" and "Startup School," which provide insights into his views on entrepreneurship and technology. He has been a significant figure in the tech industry and is often seen as a thought leader in the field.
In [ ]:
Copied!
resp = await llm.astream_complete("Paul Graham is ")
resp = await llm.astream_complete("Paul Graham is ")
In [ ]:
Copied!
async for delta in resp:
print(delta.delta, end="")
async for delta in resp:
print(delta.delta, end="")
Paul Graham is an American entrepreneur, computer scientist, and writer. He co-founded the software company Y Combinator, which is a well-known startup accelerator and investment firm. Graham is also known for his blog, "Hackers & Painters," where he shares his thoughts on various topics including entrepreneurship, technology, and education. He has written several influential books, including "Hackers: Heroes of the Computer Age" and "Why You Can't Build a Startup on Your Living Room Couch." Graham has been influential in the tech industry and is considered a prominent figure in the startup ecosystem.