一个使用智谱AI GLM4V-Flash模型进行图片描述的Python包
Project description
shiertier_caption
一个使用智谱AI GLM4V-Flash模型进行图片描述的Python包。
安装
pip install shiertier_caption
使用方法
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类
GLM4VFlash(api_key: str)
参数:
api_key: 智谱AI的API密钥
prompt方法
prompt(image_path_or_url: str, prompt: str, is_url: bool = False) -> str
参数:
image_path_or_url: 图片的本地路径或URLprompt: 关于图片的提问is_url: 是否为URL链接,默认为False(即本地文件)
返回值:
- 返回模型的文本回答
- 如果发生错误,返回错误信息字符串
许可证
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shiertier_caption-0.0.5.tar.gz.
File metadata
- Download URL: shiertier_caption-0.0.5.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e81f181f19fc150b21462b8fbd032c8a150f07f0a3a4a4b3b015d71c578a77e3
|
|
| MD5 |
61851c641f939ac14171d0b425754382
|
|
| BLAKE2b-256 |
e36e62bf286351fa27875ca4bf1a5f227477fc389594cc7513b22d295bc5cdb9
|
File details
Details for the file shiertier_caption-0.0.5-py3-none-any.whl.
File metadata
- Download URL: shiertier_caption-0.0.5-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3666e35c8f47452daa960de8588d77de574655c4b222c3af5ded16aca89644c7
|
|
| MD5 |
1403204125cfe347a21282cca1695223
|
|
| BLAKE2b-256 |
f5f869bb1ea517ed6c02eef234b833d52e7cd8a7b9ec4de0e41f261fa4daf01d
|