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.2.tar.gz (47.0 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.2-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydify-0.1.2.tar.gz
  • Upload date:
  • Size: 47.0 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.2.tar.gz
Algorithm Hash digest
SHA256 2daf50c6323d52dadb3960ea72f658e0d0e0fbb04fd031ea73a61c79c044e99f
MD5 6f294e6c84ac5b7ac826181f0e18f60d
BLAKE2b-256 d00ba86bbe20364d3c8d3c1739388773e177b7d45f501082b49c97d45b47bbe6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydify-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 32.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c231e452affe0a895673631a26463915206f7decb7be69e2772dc78a99116d7
MD5 11de750988ab8037ad2fc0369c8a3e67
BLAKE2b-256 4dad82ba47a579b36bdb5e8673f73a3a1a6ec45a4036903856c51fa2e4e3882f

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