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.1.0.tar.gz (47.1 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.1.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydify-2.1.0.tar.gz
  • Upload date:
  • Size: 47.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pydify-2.1.0.tar.gz
Algorithm Hash digest
SHA256 4f2a581a94066e3233d6f2aebfe0f3be93a0bf78997cfe91ef0297494a7893df
MD5 5090c02ed4e2ba8fecf5c7be8f920dca
BLAKE2b-256 12548b2843ad6d63582ea50c8fa4c3e27d653ea48e653117b0d5a40e36cd404a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydify-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for pydify-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f089564ddcc3cffef5c15b41ace5050557549d0290429886d72fd765edbf802
MD5 9a932dd1026891b95077424cccce2585
BLAKE2b-256 2dd2c4e5587c3f072ea0ad25938b7e608c8049bc2a2b718f5aaa06dc1e303328

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