Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 284 additions & 0 deletions BotSharp.sln

Large diffs are not rendered by default.

466 changes: 466 additions & 0 deletions src/Plugins/BotSharp.Plugin.Dify/ARCHITECTURE.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/Plugins/BotSharp.Plugin.Dify/BotSharp.Plugin.Dify.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(TargetFramework)</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>$(LangVersion)</LangVersion>
<VersionPrefix>$(BotSharpVersion)</VersionPrefix>
<GeneratePackageOnBuild>$(GeneratePackageOnBuild)</GeneratePackageOnBuild>
<GenerateDocumentationFile>$(GenerateDocumentationFile)</GenerateDocumentationFile>
<OutputPath>$(SolutionDir)packages</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
</ItemGroup>

</Project>
46 changes: 46 additions & 0 deletions src/Plugins/BotSharp.Plugin.Dify/DifyPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using BotSharp.Abstraction.Plugins;
using BotSharp.Abstraction.Settings;
using BotSharp.Plugin.Dify.Functions;
using BotSharp.Plugin.Dify.HostedServices;
using BotSharp.Plugin.Dify.Services;
using BotSharp.Plugin.Dify.Settings;
using Microsoft.Extensions.Configuration;

namespace BotSharp.Plugin.Dify;

/// <summary>
/// Plugin for integrating BotSharp with Dify workflows
/// This plugin enables BotSharp to act as a router/orchestrator
/// while delegating workflow execution to Dify for flexible content generation
/// </summary>
public class DifyPlugin : IBotSharpPlugin
{
public string Id => "f8a5c2d1-3e4b-4c5d-8f9a-1b2c3d4e5f6a";
public string Name => "Dify Workflow Integration";
public string Description => "Enables BotSharp to execute Dify workflows with async task polling support";
public string IconUrl => "https://docs.dify.ai/logo.png";

public SettingsMeta Settings => new SettingsMeta("Dify");

public object GetNewSettingsInstance() => new DifySettings();

public void RegisterDI(IServiceCollection services, IConfiguration config)
{
// Register settings
services.AddScoped(provider =>
{
var settingService = provider.GetRequiredService<ISettingService>();
return settingService.Bind<DifySettings>("Dify");
});

// Register services
services.AddScoped<DifyWorkflowService>();
services.AddSingleton<DifyTaskStorageService>();

// Register function callback
services.AddScoped<IFunctionCallback, CallDifyWorkflowFn>();

// Register background service for polling
services.AddHostedService<DifyTaskPollingService>();
}
}
Loading