Dapr SDK for .NET
Go to file
Whit Waldo 7b5ca4fb6c
Add .NET client for LLM Conversations support (#1382)
* Updated prototype

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added Dapr.AI project and unit test project to contain the conversational building block (and potentially future other projects)

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Changed default values

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed unnecessary method

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added a few unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added example project

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added missing copyright headers

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Changed type name -> DaprLlmInput to DaprConversationInput

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Returning read only list

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Update to use IReadOnlyDictionary

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added method to abstract class

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Striving for consistency in how properties are specified on the record

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Refactored enum extensions out to Dapr.Common since it will be used in AI project

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added JSON converter for System.Text.Json to handle enum serialization based on the enum member attributes

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added unit tests to prove out generic enum JSON converter using EnumMember attributes

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added JSON converter to new enum for Dapr Conversation role

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Set up role to map to the string used in grpc call to sidecar

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* No need for the JSON converter after all

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added missing package version to fix build error

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed duplicate using statement breaking build

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed missing [Fact] annotation

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated proto types to reflect type name changes in https://github.com/dapr/dapr/pull/8250

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added support for service lifetime

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Building out documentation for Dapr AI

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Simplified registration

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Tweaked package version

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Using IConfiguration to source DaprClient values if provided in service provider

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed Models.* directories, flattened into Conversation namespace

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Swapped out to use IReadOnlyDictionary

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added suggested optimization

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed bad using statement

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updates to use uniform method for standing up new Dapr clients

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed duplicate project reference

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed build error

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixing build errors

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed bad references

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed several build errors

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixing more build errors

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated to fix several build errors

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed bad refernce

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixing more build errors

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Role is required when submitting conversation input

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed impossible path since the role cannot be nullable

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed impossible path from logic now that role cannot be null

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
2024-12-10 09:06:44 -06:00
.devcontainer Bug/476 multiple methods per interface with JSON serialization doesn´t work (#1343) 2024-12-03 14:26:00 -06:00
.github Support .NET 9 (#1404) 2024-12-03 23:50:42 -06:00
daprdocs Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
docs SDK Docs (#572) 2021-02-16 22:15:33 -08:00
examples Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
properties Fixed security advisory updates across dependencies (transitive and direct) (#1366) 2024-10-15 18:09:53 -05:00
src Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
test Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
.codecov.yml Added codecov integration (#436) 2020-10-19 19:06:21 -07:00
.editorconfig [Workflow] Improve management API usability (#1087) 2023-05-12 15:44:33 -07:00
.gitignore Implement Bulk Publish functionality (#1001) 2023-01-26 11:34:09 -08:00
CODEOWNERS Update CODEOWNERS 2021-07-13 11:30:41 -07:00
CONTRIBUTING.md Improvement of the dotnet-contributing files (#1330) 2024-10-16 15:41:46 -05:00
Directory.Packages.props Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
LICENSE replaced license headers (#802) 2021-12-10 13:39:06 -08:00
README.md Fixed badge broken links (#1290) 2024-05-21 21:25:19 -07:00
all.sln Add .NET client for LLM Conversations support (#1382) 2024-12-10 09:06:44 -06:00
global.json Support .NET 9 (#1404) 2024-12-03 23:50:42 -06:00

README.md

Dapr SDK for .NET

NuGet Version NuGet Downloads GitHub Actions Workflow Status codecov GitHub License GitHub issue custom search in repo Discord YouTube Channel Views X (formerly Twitter) Follow

Dapr SDK for .NET allows you to:

  • Interact with Dapr applications through a Dapr client
  • Build routes and controllers in ASP.NET
  • Implement the Virtual Actor model, based on the actor design pattern

This SDK can run locally, in a container, and in any distributed systems environment.

Releases

We publish nuget packages to nuget.org for each release.

Using nugets built locally in your project

<RepoRoot> is the path where you cloned this repository. Nuget packages are dropped under /bin/<Debug|Release>/nugets when you build locally.

Example

# Add Dapr.Actors nuget package
dotnet add package Dapr.Actors -s <RepoRoot>/bin/<Debug|Release>/nugets

# Add Dapr.Actors.AspNetCore nuget package
dotnet add package Dapr.Actors.AspNetCore -s <RepoRoot>/bin/<Debug|Release>/nugets

Documentation

The docs for the Dapr .NET SDK can be found on the Dapr docs site.

Examples

Visit the examples folder for a variety of examples to get you up and running with the Dapr .NET SDK.

Contributing

This repo builds the following packages:

  • Dapr.Client
  • Dapr.AspNetCore
  • Dapr.Actors
  • Dapr.Actors.AspNetCore
  • Dapr.Extensions.Configuration
  • Dapr.Workflow

Prerequisites

Each project is a normal C# project. At minimum, you need .NET 6.0 SDK to build, test, and generate NuGet packages.

Also make sure to reference the .NET SDK contribution guide

macOS/Linux:

On macOS or Linux we recommend Visual Studio Code with the C# Extension. See here for a getting started guide for VS Code and .NET.

Windows:

On Windows, we recommend installing the latest Visual Studio 2019 which will set you up with all the .NET build tools and allow you to open the solution files. Community Edition is free and can be used to build everything here.

Make sure you update Visual Studio to the most recent release.

Build

To build everything and generate NuGet packages, run dotnet cli commands. Binaries and NuGet packages will be dropped in a bin directory at the repo root.

# Build sdk, samples and tests.
dotnet build -c Debug  # for release, -c Release

# Run unit-test
dotnet test

# Generate nuget packages in /bin/Debug/nugets
dotnet pack

Each project can also be built individually directly through the CLI or your editor/IDE. You can open the solution file all.sln in repo root to load all sdk, samples and test projects.