A package for quickly calling dify
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydify_sdk-0.1.1.tar.gz.
File metadata
- Download URL: pydify_sdk-0.1.1.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b19310f4b6528d1ac6485e681d25b0fa348f503399f0e59282a195289c58171
|
|
| MD5 |
8001fb7e0eef2cded29b1608aa5f4f40
|
|
| BLAKE2b-256 |
c2dc8fa2e881aacec55061d854c49b79e2bac706fa533f6f03787cfe6f6fbb32
|
File details
Details for the file pydify_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pydify_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e2ef099f2e570c5d6838802980330e41f08d42fb6ddb2aeafac0eb870bf321e
|
|
| MD5 |
73adcd08a74ae99140cb5ae7aa1bf459
|
|
| BLAKE2b-256 |
61113440d59e1e01a4e91c92b1ba5d0a4fba57defb86a39f53c99ae401900bd6
|