Skip to main content

A Python SDK for interacting with Dify API

Project description

Pydify

Pydify是一个Python SDK,用于与Dify API进行交互。它提供了一组简单易用的客户端类,让您能够轻松地使用Dify的各种功能。

功能特点

  • 多种应用类型支持:支持Chatbot、Agent、Text Generation、Workflow和Chatflow应用类型

  • 流式响应处理:支持处理流式(streaming)返回的消息

  • 文件上传:支持上传图像等文件进行多模态理解

  • 会话管理:提供会话历史记录管理功能

  • 文本到音频转换:支持将文本转换为音频

安装

pip install pydify

快速开始

以下是一个基本的聊天机器人示例:

from pydify import ChatbotClient

# 初始化客户端
client = ChatbotClient(
    api_key="your_api_key",
    app_id="your_app_id"
)

# 发送消息
response = client.send_message("Hello, how are you?")
print(response)

# 流式响应处理
def handle_message(message):
    print(f"接收到消息: {message}")

def handle_end():
    print("消息结束")

client.send_message(
    "Tell me a story",
    streaming=True,
    message_handler=handle_message,
    message_end_handler=handle_end
)

更多示例请查看项目的examples目录。

许可证

MIT

更多信息

完整文档请参考项目的README.md文件或访问GitHub仓库。

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

pydify-0.1.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

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

pydify-0.1.0-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file pydify-0.1.0.tar.gz.

File metadata

  • Download URL: pydify-0.1.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for pydify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f6e73f05606a44123725df6de7b39f941883e6c41249cb2444c1aadacee81b61
MD5 ae9283bbfe679a3e993b74cafae05186
BLAKE2b-256 a4fde2c582bbe6d907ebd267d1a4a637eed0540827dc4e0ef901afe91fec9536

See more details on using hashes here.

File details

Details for the file pydify-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pydify-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for pydify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bef5253a3cbb9d6f1ab198282f615fa24b91dee89c9e66c68478e419d5767c56
MD5 059bce17891ed57f6bd7dff8da8362a9
BLAKE2b-256 06a7253ac2e2d3df65204bc8ed96b8036468d779a1ffbf5d49b2f298dd4b43d7

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