Skip to main content

一个使用智谱AI GLM4V-Plus模型进行图片描述的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: 图片的本地路径或URL
  • prompt: 关于图片的提问
  • is_url: 是否为URL链接,默认为False(即本地文件)

返回值:

  • 返回模型的文本回答
  • 如果发生错误,返回错误信息字符串

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shiertier_caption-0.2.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shiertier_caption-0.2.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_caption-0.2.1.tar.gz.

File metadata

  • Download URL: shiertier_caption-0.2.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for shiertier_caption-0.2.1.tar.gz
Algorithm Hash digest
SHA256 00c1f3bbdce3348147138a6968bbf747b0de4f5ad8dcf9c75477295f7e8b0af2
MD5 2b3de4ce5f1355dc2a1fab2c7021cff3
BLAKE2b-256 61e26f52173039a5f6d26bb80a69f6c7abfad09b20e93afe975dbb9b1c437d33

See more details on using hashes here.

File details

Details for the file shiertier_caption-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for shiertier_caption-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 18db3a6ec9c65f63edfcf34eeadacee33b56740fd824129aa18bb413576d1d05
MD5 2f6ff7387524ed0875473032edd431b8
BLAKE2b-256 0ca62598397f8482fc352644f4d4d2b21768bbd9d8d778654edb7f02fbb6e389

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page