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-2.2.0.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

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

pydify-2.2.0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pydify-2.2.0.tar.gz
Algorithm Hash digest
SHA256 e8b29bf2373f25fe945d24cfae5b137d63ae74f5caf9c3cc4a7f5e031d1454bc
MD5 53043185993dbd9b441df9108f65f7c7
BLAKE2b-256 b8d23d70d995eab60afe64fac2410eef8a7f547b4f73a7272d28b5ee4b345348

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydify-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.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-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c05ab715982dcff83c751c079b143b79f0b4819f92180a089f447a669e3976a3
MD5 046e45804333d8c53c179f0190bc81bc
BLAKE2b-256 a7c67a727c31536f1fb88cc960b4030d9cf8b23dd0ec2c16581a750b96af61d5

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