# shiertier_caption
一个使用智谱AI GLM4V-Flash模型进行图片描述的Python包。
## 安装
```bash
pip install shiertier_caption
```
## 使用方法
```python
from shiertier_caption import GLM4VFlash
# 初始化客户端
client = GLM4VFlash(api_key="your_api_key")
# 使用本地图片
response = client.prompt(
image_path_or_url="path/to/your/image.jpg",
prompt="描述这张图片"
)
print(response)
# 使用URL图片
response = client.prompt(
image_path_or_url="https://example.com/image.jpg",
prompt="描述这张图片",
is_url=True
)
print(response)
```
## 功能特点
- 支持本地图片和URL图片
- 简单易用的API接口
- 自动处理base64编码
- 完整的错误处理
## API文档
### GLM4VFlash类
```python
GLM4VFlash(api_key: str)
```
参数:
- `api_key`: 智谱AI的API密钥
### prompt方法
```python
prompt(image_path_or_url: str, prompt: str, is_url: bool = False) -> str
```
参数:
- `image_path_or_url`: 图片的本地路径或URL
- `prompt`: 关于图片的提问
- `is_url`: 是否为URL链接,默认为False(即本地文件)
返回值:
- 返回模型的文本回答
- 如果发生错误,返回错误信息字符串
## 许可证
MIT License
Raw data
{
"_id": null,
"home_page": null,
"name": "shiertier-caption",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "zhipuai, glm4v, shiertier_caption, image, ai",
"author": null,
"author_email": "shiertier <junjietext@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/32/b0/65eb887f9fd47a87902521ca66a33458a62ce1e285ab49079e6a1c58f497/shiertier_caption-0.2.9.tar.gz",
"platform": null,
"description": "# shiertier_caption\n\n\u4e00\u4e2a\u4f7f\u7528\u667a\u8c31AI GLM4V-Flash\u6a21\u578b\u8fdb\u884c\u56fe\u7247\u63cf\u8ff0\u7684Python\u5305\u3002\n\n## \u5b89\u88c5\n\n```bash\npip install shiertier_caption\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n```python\nfrom shiertier_caption import GLM4VFlash\n\n# \u521d\u59cb\u5316\u5ba2\u6237\u7aef\nclient = GLM4VFlash(api_key=\"your_api_key\")\n\n# \u4f7f\u7528\u672c\u5730\u56fe\u7247\nresponse = client.prompt(\n image_path_or_url=\"path/to/your/image.jpg\",\n prompt=\"\u63cf\u8ff0\u8fd9\u5f20\u56fe\u7247\"\n)\nprint(response)\n\n# \u4f7f\u7528URL\u56fe\u7247\nresponse = client.prompt(\n image_path_or_url=\"https://example.com/image.jpg\",\n prompt=\"\u63cf\u8ff0\u8fd9\u5f20\u56fe\u7247\",\n is_url=True\n)\nprint(response)\n```\n\n## \u529f\u80fd\u7279\u70b9\n\n- \u652f\u6301\u672c\u5730\u56fe\u7247\u548cURL\u56fe\u7247\n- \u7b80\u5355\u6613\u7528\u7684API\u63a5\u53e3\n- \u81ea\u52a8\u5904\u7406base64\u7f16\u7801\n- \u5b8c\u6574\u7684\u9519\u8bef\u5904\u7406\n\n## API\u6587\u6863\n\n### GLM4VFlash\u7c7b\n\n```python\nGLM4VFlash(api_key: str)\n```\n\n\u53c2\u6570:\n- `api_key`: \u667a\u8c31AI\u7684API\u5bc6\u94a5\n\n### prompt\u65b9\u6cd5\n\n```python\nprompt(image_path_or_url: str, prompt: str, is_url: bool = False) -> str\n```\n\n\u53c2\u6570:\n- `image_path_or_url`: \u56fe\u7247\u7684\u672c\u5730\u8def\u5f84\u6216URL\n- `prompt`: \u5173\u4e8e\u56fe\u7247\u7684\u63d0\u95ee\n- `is_url`: \u662f\u5426\u4e3aURL\u94fe\u63a5\uff0c\u9ed8\u8ba4\u4e3aFalse\uff08\u5373\u672c\u5730\u6587\u4ef6\uff09\n\n\u8fd4\u56de\u503c:\n- \u8fd4\u56de\u6a21\u578b\u7684\u6587\u672c\u56de\u7b54\n- \u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\u5b57\u7b26\u4e32\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License \n",
"bugtrack_url": null,
"license": null,
"summary": "\u4e00\u4e2a\u4f7f\u7528\u667a\u8c31AI GLM4V-Plus\u6a21\u578b\u8fdb\u884c\u56fe\u7247\u63cf\u8ff0\u7684Python\u5305",
"version": "0.2.9",
"project_urls": {
"Documentation": "https://github.com/shiertier_utils/shiertier_caption#readme",
"Homepage": "https://github.com/shiertier_utils/shiertier_caption",
"Issues": "https://github.com/shiertier_utils/shiertier_caption/issues",
"Repository": "https://github.com/shiertier_utils/shiertier_caption.git"
},
"split_keywords": [
"zhipuai",
" glm4v",
" shiertier_caption",
" image",
" ai"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "50869ce0dca3eed241a397f1aebcbe70e8920884582365d336afe62f9ae8ec05",
"md5": "c28a5f659cdac2add8dad52b6831ecb9",
"sha256": "97d3b844303f4739abd4a69d78bc6b7e7296ac718cc48b873487e1d8f93b621e"
},
"downloads": -1,
"filename": "shiertier_caption-0.2.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c28a5f659cdac2add8dad52b6831ecb9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7614,
"upload_time": "2025-01-28T21:23:33",
"upload_time_iso_8601": "2025-01-28T21:23:33.784746Z",
"url": "https://files.pythonhosted.org/packages/50/86/9ce0dca3eed241a397f1aebcbe70e8920884582365d336afe62f9ae8ec05/shiertier_caption-0.2.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "32b065eb887f9fd47a87902521ca66a33458a62ce1e285ab49079e6a1c58f497",
"md5": "ba53bcd28bc344835703941164caf916",
"sha256": "1672914dbc83c330406d649de04d4107421336f6290dcbf1932fd475d85f6a0f"
},
"downloads": -1,
"filename": "shiertier_caption-0.2.9.tar.gz",
"has_sig": false,
"md5_digest": "ba53bcd28bc344835703941164caf916",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7370,
"upload_time": "2025-01-28T21:23:34",
"upload_time_iso_8601": "2025-01-28T21:23:34.846961Z",
"url": "https://files.pythonhosted.org/packages/32/b0/65eb887f9fd47a87902521ca66a33458a62ce1e285ab49079e6a1c58f497/shiertier_caption-0.2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-28 21:23:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shiertier_utils",
"github_project": "shiertier_caption#readme",
"github_not_found": true,
"lcname": "shiertier-caption"
}