Skip to main content

dify sdk

A dify sdk package wrapped with pydantic

English | 简体中文

Best Practices

Pass the request_id as a parameter in the node settings of the Dify app. Then, use the async_run or async_chat method to record the corresponding ID. After a single call ends, send back both the request_id and the operation result through an HTTP callback. This way, you can avoid waiting for the resources occupied by the large model.

Examples

Work Flow

from pydify_sdk import DifyWorkFlow

app = DifyWorkFlow("your_app_key", app_name="your_app_name")
user = "user_id" 
data = {"request_id": "XXX", "param": "some words"}  # workflow inputs
app.async_run(user, data)

Chat Flow

from pydify_sdk import DifyChatFlow

app = DifyChatFlow("your_app_key", app_name="your_app_name")
user = "user_id"
query = "some words"  # Chat content
data = {"request_id": "XXX"}
app.async_chat(user, query)

Public API

  • upload_file: upload file to dify server
  • get_app_info: get the app info
  • get_app_parameters: get the app parameters
  • get_app_tools: get the tools' icon that the app can use

Work Flow API

  • run: run the workflow with stream response
  • sync_run: run the workflow as a regular request(maybe timeout!)
  • async_run: run the workflow via http callback(best practices)
  • get_work_result: get the work flow run result by task_id
  • stop_work: stop the work flow by task_id
  • get_logs: get the work flow app logs

Chat Flow API

  • chat: chat with stream response
  • sync_chat: chat as a regular request(maybe timeout!)
  • async_chat: chat via http callback(best practices)
  • stop_chat: stop the chat by task_id
  • feedback_chat: feedback the chat result by message_id
  • get_suggested: get next question suggestions by message_id
  • get_chat_history: get the chat history by conversation_id
  • get_conversations: get the conversations
  • delete_conversation: delete the conversation by conversation_id
  • delete_chat_history: delete the chat history by conversation_id
  • rename_conversation: rename the conversation by conversation_id
  • create_annotation: create an annotation
  • update_annotation: update the annotation by annotation_id
  • delete_annotation: delete the annotation by annotation_id

Environment Variable Configuration

  • DIFY_API_URL: Configure the global dify server address
  • DIFY_LOGGER_ON: Configure whether to print logs when initiating requests

Metadata

Release files for pydify-sdk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydify-sdk 0.1.1
File Size Uploaded Provenance Actions
pydify_sdk-0.1.1.tar.gz 18.1 kB Without provenance Details for pydify_sdk-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydify-sdk 0.1.1
File Interpreter ABI Platform Actions
pydify_sdk-0.1.1-py3-none-any.whl Python 3 none any Details for pydify_sdk-0.1.1-py3-none-any.whl

Total release size: 38.2 kB

Release files / pydify_sdk-0.1.1.tar.gz

Download URL pydify_sdk-0.1.1.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1b19310f4b6528d1ac6485e681d25b0fa348f503399f0e59282a195289c58171
BLAKE2b-256 checksum
How to use checksums
c2dc8fa2e881aacec55061d854c49b79e2bac706fa533f6f03787cfe6f6fbb32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / pydify_sdk-0.1.1-py3-none-any.whl

Download URL pydify_sdk-0.1.1-py3-none-any.whl
Size 20.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e2ef099f2e570c5d6838802980330e41f08d42fb6ddb2aeafac0eb870bf321e
BLAKE2b-256 checksum
How to use checksums
61113440d59e1e01a4e91c92b1ba5d0a4fba57defb86a39f53c99ae401900bd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for pydify-sdk 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page