* chore(python): temporarily disable `UP007` rule in Ruff Disable the `UP007` rule temporarily due to numerous existing violations in the current codebase. * ci(python): add lint and test for Python SDK * ci: Add mega-linter * chore(python): Add final newline to markdown files * fix(python): Fix linter issues by using ruff's auto fix * fix(python): Fix TRY400 linter violations Ruff suggests using `logger.exception` to log when logging an exception, instead of using `logging.error`. The former logs the exception and the traceback automatically. ref: https://docs.astral.sh/ruff/rules/error-instead-of-exception/ * fix(python): fix ruff linter violations * test(python): Add Test cases for LLM entities Test the initialization of `LLMResult` and `LLMResultChunk`. * test(python): Add test for `AgentModelConfig` Ensures that the `history_prompt_messages` attribute is not shared between instances of `AgentModelConfig`. * chore(python): output diffs in Ruff's format check * style(python): format code with Ruff * chore(python): Add a bash script for fix and format python code * chore: add `persist-credentials: false` to checkout action Enhances security by preventing subsequent steps from accessing GitHub credentials, reducing potential attack surfaces. Ref: https://github.com/actions/checkout#checkout-v4
Overview
The Agent node in Dify Chatflow/Workflow lets LLMs autonomously use tools. This plugin features two official Dify Agent reasoning strategies, enabling LLMs to dynamically select and run tools during runtime for multi-step problem-solving.
Strategies
1. Function Calling
Function Calling maps user commands to specific functions or tools. The LLM identifies the user's intent, decides which function to call, and extracts the required parameters. It is a straightforward mechanism for invoking external capabilities.
Pros:
- Precise: Directly calls the right tool for defined tasks, avoiding complex reasoning.
- Easy External Integration: Integrates external APIs and tools as callable functions.
- Structured Output: Provides structured function call information for easy processing.
2. ReAct (Reason + Act)
ReAct alternates between the LLM reasoning about the situation and taking actions. The LLM analyzes the current state and goal, selects and uses a tool, and then uses the tool's output for the next thought and action. This cycle repeats until the problem is resolved.
Pros:
- Leverages External Information: Effectively uses external tools to gather information for tasks the model cannot handle alone.
- Explainable Reasoning: Interwoven reasoning and action steps allow some tracking of the Agent's process.
- Wide Applicability: Suitable for tasks requiring external knowledge or specific actions, such as Q&A, information retrieval, and task execution.

