IcedMango.DifyAi 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package IcedMango.DifyAi --version 1.1.1                
NuGet\Install-Package IcedMango.DifyAi -Version 1.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IcedMango.DifyAi" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IcedMango.DifyAi --version 1.1.1                
#r "nuget: IcedMango.DifyAi, 1.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IcedMango.DifyAi as a Cake Addin
#addin nuget:?package=IcedMango.DifyAi&version=1.1.1

// Install IcedMango.DifyAi as a Cake Tool
#tool nuget:?package=IcedMango.DifyAi&version=1.1.1                

Description

English | δΈ­ζ–‡

A simple Dify C# SDK.

Currently support partial robot api.

Wiki api working in progress.

UnitTest missing, will be added soon. If you have encountered any problem, please feel free to open an issue or PR.

Important Notice

This project is under early development, and the API may change at any time. You may encounter bugs, missing features, or incomplete documentation.

QuickStart

Install

Install-Package IcedMango.DifyAi 

Service Registration:

Startup.cs


//Startup.cs

using DifyAi.ServiceExtension;


public void ConfigureServices(IServiceCollection services)
{
    ...other code
    
    // register service
    services.AddDifyAiServices();
}

appsetting.json

Note:

  • BaseUrl: EndPoint of dify api instance. Must end with /
  • BotApiKey: You can start with 'Bearer app-your-bot-key' or just use 'app-your-bot-key'
  • Proxy: Proxy setting, support http, https, socks5. Leave empty if you don't need it.
{
  "DifyAi": {
    "BaseUrl": "https://example.com/v1/", 
    "BotApiKey": "app-your-bot-key",
    "Proxy": "socks5://127.0.0.1:8889"
  }
}

Usage

using DifyAi.Dto.ParamDto;
using DifyAi.Services;

namespace TestDifyAi;

public class TestClass
{
    private readonly IDifyAiChatServices _difyAiChatServices;

    public TestClass(IDifyAiChatServices difyAiChatServices)
    {
        _difyAiChatServices = difyAiChatServices;
    }

    public async Task<string> TestCompletion()
    {
        var res = await _difyAiChatServices.CreateChatCompletionBlockModeAsync(new Dify_CreateChatCompletionParamDto()
        {
            Query = "Who are you?",
            User = "IcedMango",
            ConversationId = string.Empty
        });
        
        if (res.Success == true)
        {
            return res.Data.Answer;
        }

        return "Error";
    }
}


Api Document

Click Here

Todo List

  • Robot Api(done, no chat completion stream return/text to speech)
  • Api Document
  • UnitTest
  • Message Completion Stream Mode
  • Wiki Related Api

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution License Agreement

By contributing, you agree to license your contribution to project owner under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.7 125 6/12/2024
1.1.6 65 6/11/2024
1.1.5 80 6/1/2024
1.1.3 85 5/22/2024
1.1.1 77 5/21/2024