➜./dify-plugin-darwin-arm64plugininit─╯EditprofileofthepluginPluginname (press Entertonextstep): # 填写插件的名称Author (press Entertonextstep): # 填写插件作者Description (press Entertonextstep): # 填写插件的描述---Selectthelanguageyouwanttouseforplugindevelopment,andpressEntertocontinue,BTW,youneedPython3.12+todevelopthePluginifyouchoosePython.-> python# 选择 Python 环境go (not supportedyet)---Basedontheabilityyouwanttoextend,wehavedividedthePluginintofourtypes:Tool,Model,Extension,andAgentStrategy.-Tool:It's a tool provider, but not only limited to tools, you can implement an endpoint there, for example, you need both Sending Message and Receiving Message if you are- Model: Just a model provider, extending others is not allowed.- Extension: Other times, you may only need a simple http service to extend the functionalities, Extension is the right choice for you.- Agent Strategy: Implement your own logics here, just by focusing on Agent itselfWhat'smore,wehaveprovidedthetemplateforyou,youcanchooseoneofthembelow:tool-> agent-strategy# 选择 Agent 策略模板llmtext-embedding---Configurethepermissionsoftheplugin,useupanddowntonavigate,tabtoselect,afterselection,pressentertofinishBackwardsInvocation:Tools:Enabled: [✔] You can invoke tools inside Dify ifit's enabled # 默认开启Models: Enabled: [✔] You can invoke models inside Dify if it'senabled# 默认开启LLM: [✔] You can invoke LLM models inside Dify ifit's enabled # 默认开启 → Text Embedding: [✘] You can invoke text embedding models inside Dify if it'senabledRerank: [✘] You can invoke rerank models inside Dify ifit's enabled TTS: [✘] You can invoke TTS models inside Dify if it'senabledSpeech2Text: [✘] You can invoke speech2text models inside Dify ifit's enabled Moderation: [✘] You can invoke moderation models inside Dify if it'senabledApps:Enabled: [✘] Ability to invoke apps like BasicChat/ChatFlow/Agent/Workflow etc.Resources:Storage:Enabled: [✘] Persistence storage for the pluginSize:N/AThemaximumsizeofthestorageEndpoints:Enabled: [✘] Ability to register endpoints
identity:
name: basic_agent # the name of the agent_strategy
author: novice # the author of the agent_strategy
label:
en_US: BasicAgent # the engilish label of the agent_strategy
description:
en_US: BasicAgent # the english description of the agent_strategy
parameters:
- name: model # the name of the model parameter
type: model-selector # model-type
scope: tool-call&llm # the scope of the parameter
required: true
label:
en_US: Model
zh_Hans: 模型
pt_BR: Model
- name: tools # the name of the tools parameter
type: array[tools] # the type of tool parameter
required: true
label:
en_US: Tools list
zh_Hans: 工具列表
pt_BR: Tools list
- name: query # the name of the query parameter
type: string # the type of query parameter
required: true
label:
en_US: Query
zh_Hans: 查询
pt_BR: Query
- name: maximum_iterations
type: number
required: false
default: 5
label:
en_US: Maxium Iterations
zh_Hans: 最大迭代次数
pt_BR: Maxium Iterations
max: 50 # if you set the max and min value, the display of the parameter will be a slider
min: 1
extra:
python:
source: strategies/basic_agent.py
from dify_plugin.entities.agent import AgentInvokeMessage
from dify_plugin.interfaces.agent import AgentModelConfig, AgentStrategy, ToolEntity
from pydantic import BaseModel
class BasicParams(BaseModel):
maximum_iterations: int
model: AgentModelConfig
tools: list[ToolEntity]
query: str
history_messages: []
history_messages: [UserPromptMessage(role=<PromptMessageRole.USER: 'user'>, content='hello, my name is novice', name=None), AssistantPromptMessage(role=<PromptMessageRole.ASSISTANT: 'assistant'>, content='Hello, Novice! How can I assist you today?', name=None, tool_calls=[])]