# LlamaIndex Readers Integration: Alibabacloud_Aisearch
## Installation
```
pip install llama-index-readers-alibabacloud-aisearch
```
## Usage
Supported file types: ppt/pptx, doc/docx, pdf, images and so on.
For further details, please visit:
- [document-analyze-api-details](https://help.aliyun.com/zh/open-search/search-platform/developer-reference/api-details)
- [image-analyze-api-details](https://help.aliyun.com/zh/open-search/search-platform/developer-reference/opensearch-api-details)
You can specify the `endpoint` and `aisearch_api_key` in the constructor, or set the environment variables `AISEARCH_ENDPOINT` and `AISEARCH_API_KEY`.
### Read local files
```python
from llama_index.readers.alibabacloud_aisearch import (
AlibabaCloudAISearchDocumentReader,
AlibabaCloudAISearchImageReader,
)
from llama_index.core import SimpleDirectoryReader
document_reader = AlibabaCloudAISearchDocumentReader()
image_reader = AlibabaCloudAISearchImageReader()
file_extractor = {}
for suffix in (".pdf", ".docx", ".doc", ".ppt", ".pptx"):
file_extractor[suffix] = document_reader
for suffix in (".jpg", ".jpeg", ".png", ".bmp", ".tiff"):
file_extractor[suffix] = image_reader
documents = SimpleDirectoryReader(
"./data", file_extractor=file_extractor
).load_data(show_progress=True)
print(documents)
```
### Read remote files
```python
from llama_index.readers.alibabacloud_aisearch import (
AlibabaCloudAISearchImageReader,
)
image_reader = AlibabaCloudAISearchImageReader(
service_id="ops-image-analyze-ocr-001"
)
image_urls = [
"https://img.alicdn.com/imgextra/i1/O1CN01WksnF41hlhBFsXDNB_!!6000000004318-0-tps-1000-1400.jpg",
]
# The file_type is automatically determined based on the file extension.
# If it cannot be identified, manual specification of the file_type is required.
documents = image_reader.load_data(file_path=image_urls, file_type="jpg")
print(documents)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-readers-alibabacloud-aisearch",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8.1",
"maintainer_email": null,
"keywords": null,
"author": "llama-index",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/97/87/19b4a4629535c8ae7cc70506779830f6ee07891ac7a1911b4e4bf3b616e8/llama_index_readers_alibabacloud_aisearch-0.1.0.tar.gz",
"platform": null,
"description": "# LlamaIndex Readers Integration: Alibabacloud_Aisearch\n\n## Installation\n\n```\npip install llama-index-readers-alibabacloud-aisearch\n```\n\n## Usage\n\nSupported file types: ppt/pptx, doc/docx, pdf, images and so on.\nFor further details, please visit:\n\n- [document-analyze-api-details](https://help.aliyun.com/zh/open-search/search-platform/developer-reference/api-details)\n- [image-analyze-api-details](https://help.aliyun.com/zh/open-search/search-platform/developer-reference/opensearch-api-details)\n\nYou can specify the `endpoint` and `aisearch_api_key` in the constructor, or set the environment variables `AISEARCH_ENDPOINT` and `AISEARCH_API_KEY`.\n\n### Read local files\n\n```python\nfrom llama_index.readers.alibabacloud_aisearch import (\n AlibabaCloudAISearchDocumentReader,\n AlibabaCloudAISearchImageReader,\n)\nfrom llama_index.core import SimpleDirectoryReader\n\ndocument_reader = AlibabaCloudAISearchDocumentReader()\nimage_reader = AlibabaCloudAISearchImageReader()\n\nfile_extractor = {}\nfor suffix in (\".pdf\", \".docx\", \".doc\", \".ppt\", \".pptx\"):\n file_extractor[suffix] = document_reader\nfor suffix in (\".jpg\", \".jpeg\", \".png\", \".bmp\", \".tiff\"):\n file_extractor[suffix] = image_reader\n\ndocuments = SimpleDirectoryReader(\n \"./data\", file_extractor=file_extractor\n).load_data(show_progress=True)\nprint(documents)\n```\n\n### Read remote files\n\n```python\nfrom llama_index.readers.alibabacloud_aisearch import (\n AlibabaCloudAISearchImageReader,\n)\n\nimage_reader = AlibabaCloudAISearchImageReader(\n service_id=\"ops-image-analyze-ocr-001\"\n)\nimage_urls = [\n \"https://img.alicdn.com/imgextra/i1/O1CN01WksnF41hlhBFsXDNB_!!6000000004318-0-tps-1000-1400.jpg\",\n]\n\n# The file_type is automatically determined based on the file extension.\n# If it cannot be identified, manual specification of the file_type is required.\ndocuments = image_reader.load_data(file_path=image_urls, file_type=\"jpg\")\nprint(documents)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index readers alibabacloud_aisearch integration",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5561bff08ca197cc56149c809903d7d643656721263556141b47fb0281993751",
"md5": "9736f3cac5b983db4c7e92782a69086f",
"sha256": "91edf94db55b7d1c3d1fa1d2a0d16f68ce7f3020815423144b5a8ec14bd6f444"
},
"downloads": -1,
"filename": "llama_index_readers_alibabacloud_aisearch-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9736f3cac5b983db4c7e92782a69086f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8.1",
"size": 4903,
"upload_time": "2024-09-11T04:15:42",
"upload_time_iso_8601": "2024-09-11T04:15:42.014965Z",
"url": "https://files.pythonhosted.org/packages/55/61/bff08ca197cc56149c809903d7d643656721263556141b47fb0281993751/llama_index_readers_alibabacloud_aisearch-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "978719b4a4629535c8ae7cc70506779830f6ee07891ac7a1911b4e4bf3b616e8",
"md5": "b1d448a215ad4ed7f609f80e6f3b6227",
"sha256": "8da2ba9a8888018f0946206cd43bdcbd8f6c95504882cb06d8a92409c3c8343f"
},
"downloads": -1,
"filename": "llama_index_readers_alibabacloud_aisearch-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "b1d448a215ad4ed7f609f80e6f3b6227",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8.1",
"size": 4276,
"upload_time": "2024-09-11T04:15:43",
"upload_time_iso_8601": "2024-09-11T04:15:43.646324Z",
"url": "https://files.pythonhosted.org/packages/97/87/19b4a4629535c8ae7cc70506779830f6ee07891ac7a1911b4e4bf3b616e8/llama_index_readers_alibabacloud_aisearch-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-11 04:15:43",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-readers-alibabacloud-aisearch"
}