Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Dapr .NET SDK documentation #1409

Merged
merged 50 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ed77b49
Updated documentation to reflect new DaprClient DI injection capabili…
WhitWaldo Nov 20, 2024
748b21c
Clarified relationship between DAPR_HTTP_ENDPOINT and DAPR_HTTP_PORT …
WhitWaldo Nov 20, 2024
c2f15fd
Clarified configuration prioritization order on DaprClientBuilder as …
WhitWaldo Nov 21, 2024
db626c4
Merge branch 'master' into daprclient-docs
WhitWaldo Nov 21, 2024
b6ee842
Merge branch 'master' into daprclient-docs
WhitWaldo Nov 24, 2024
74b7cf2
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 3, 2024
c0aac20
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 4, 2024
9e29773
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 4, 2024
a5e1506
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 5, 2024
6a30087
Fixed typo - great catch Philip!
WhitWaldo Dec 10, 2024
db59897
Merge remote-tracking branch 'origin/daprclient-docs' into daprclient…
WhitWaldo Dec 10, 2024
6186b0b
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 10, 2024
392232e
Added information about using Dapr.Jobs favoring dependency injection
WhitWaldo Dec 10, 2024
8ca9b8e
Merge remote-tracking branch 'origin/daprclient-docs' into daprclient…
WhitWaldo Dec 10, 2024
7dce4d0
Building out .NET AI docs
WhitWaldo Dec 10, 2024
d34d8c2
Merge remote-tracking branch 'origin/daprclient-docs' into daprclient…
WhitWaldo Dec 10, 2024
ed64004
Building out .NET AI docs
WhitWaldo Dec 10, 2024
8463451
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 11, 2024
10a4607
Added first-draft of .NET Aspire docs
WhitWaldo Dec 11, 2024
1577fc0
Added first-draft of .NET Aspire docs
WhitWaldo Dec 11, 2024
f63b390
Added first-draft of .NET Aspire docs
WhitWaldo Dec 11, 2024
5a885e4
Reordered the weighting of the development docs to reflect investment…
WhitWaldo Dec 11, 2024
2490222
Updated .NET SDK links to point to a better endpoint
WhitWaldo Dec 11, 2024
f52c284
Merge remote-tracking branch 'origin/daprclient-docs' into daprclient…
WhitWaldo Dec 11, 2024
dbf7b6c
Updated more of the .NET SDK links
WhitWaldo Dec 11, 2024
c0579dc
Reweighted document order
WhitWaldo Dec 11, 2024
26aa2b6
Building out pubsub docs
WhitWaldo Dec 11, 2024
6a6afd2
Tweak to clarify use of the Dapr SDK
WhitWaldo Dec 11, 2024
e02e112
Added missing whitespace for clarity
WhitWaldo Dec 11, 2024
c7a4b8c
Simplified alert about .NET versioning
WhitWaldo Dec 11, 2024
f4be508
Added Dapr.Jobs as a prereq
WhitWaldo Dec 11, 2024
d1ae5e3
Added some minor formatting tweaks
WhitWaldo Dec 11, 2024
8a3784f
Added body of the pubsub how to documentation
WhitWaldo Dec 11, 2024
48558d8
Updated table layout + reformatted
WhitWaldo Dec 11, 2024
76b322e
Added note about using DI functionality in best practices
WhitWaldo Dec 11, 2024
d2ec7c4
Fixed several typos
WhitWaldo Dec 11, 2024
8a24182
Corrected updated overload
WhitWaldo Dec 11, 2024
c58f7b9
Added best practices documentation for PubSub functionality
WhitWaldo Dec 11, 2024
12419a0
Updated contribution guide
WhitWaldo Dec 11, 2024
1b29528
Added current .NET version support to contributor guide
WhitWaldo Dec 11, 2024
34cdffd
Minor word addition
WhitWaldo Dec 11, 2024
89d0b95
Renamed for consistency
WhitWaldo Dec 11, 2024
49bfc9e
Tweaks to introduction text
WhitWaldo Dec 11, 2024
a494c08
Added Conversation usage documentation
WhitWaldo Dec 11, 2024
f2376e6
Updated to reflect updated extension method name following merge of #…
WhitWaldo Dec 11, 2024
0041807
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 11, 2024
c21659b
Built out Jobs introduction
WhitWaldo Dec 11, 2024
73a3f28
Merge remote-tracking branch 'origin/daprclient-docs' into daprclient…
WhitWaldo Dec 11, 2024
2daa522
Updated support message for Dapr.Workflows
WhitWaldo Dec 11, 2024
535b264
Merge branch 'master' into daprclient-docs
WhitWaldo Dec 11, 2024
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
106 changes: 98 additions & 8 deletions daprdocs/content/en/dotnet-sdk-contributing/dotnet-contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,112 @@ weight: 3000
description: Guidelines for contributing to the Dapr .NET SDK
---

When contributing to the [.NET SDK](https://github.com/dapr/dotnet-sdk) the following rules and best-practices should be followed.
# Welcome!
If you're reading this, you're likely interested in contributing to Dapr and/or the Dapr .NET SDK. Welcome to the project
and thank you for your interest in contributing!

Please review the documentation, familiarize yourself with what Dapr is and what it's seeking to accomplish and reach
out on [Discord](https://bit.ly/dapr-discord). Let us know how you'd like to contribute and we'd be happy to chime in
with ideas and suggestions.

There are many ways to contribute to Dapr:
- Submit bug reports for the [Dapr runtime](https://github.com/dapr/dapr/issues/new/choose) or the [Dapr .NET SDK](https://github.com/dapr/dotnet-sdk/issues/new/choose)
- Propose new [runtime capabilities](https://github.com/dapr/proposals/issues/new/choose) or [SDK functionality](https://github.com/dapr/dotnet-sdk/issues/new/choose)
- Improve the documentation in either the [larger Dapr project](https://github.com/dapr/docs) or the [Dapr .NET SDK specifically](https://github.com/dapr/dotnet-sdk/tree/master/daprdocs)
- Add new or improve existing [components](https://github.com/dapr/components-contrib/) that implement the various building blocks
- Augment the [.NET pluggable component SDK capabilities](https://github.com/dapr-sandbox/components-dotnet-sdk)
- Improve the Dapr .NET SDK code base and/or fix a bug (detailed below)

If you're new to the code base, please feel encouraged to ask in the #dotnet-sdk channel in Discord about how
to implement changes or generally ask questions. You are not required to seek permission to work on anything, but do
note that if an issue is assigned to someone, it's an indication that someone might have already started work on it.
Especially if it's been a while since the last activity on that issue, please feel free to reach out and see if it's
still something they're interested in pursuing or whether you can take over, and open a pull request with your
implementation.

If you'd like to assign yourself to an issue, respond to the conversation with "/assign" and the bot will assign you
to it.

We have labeled some issues as `good-first-issue` or `help wanted` indicating that these are likely to be small,
self-contained changes.

If you're not certain about your implementation, please create it as a draft pull request and solicit feedback
from the [.NET maintainers](https://github.com/orgs/dapr/teams/maintainers-dotnet-sdk) by tagging
`@dapr/maintainers-dotnet-sdk` and providing some context about what you need assistance with.

# Contribution Rules and Best Practices

When contributing to the [.NET SDK](https://github.com/dapr/dotnet-sdk) the following rules and best-practices should
be followed.

## Pull Requests
Pull requests that contain only formatting changes are generally discouraged. Pull requests should instead seek to
fix a bug, add new functionality, or improve on existing capabilities.

Do aim to minimize the contents of your pull request to span only a single issue. Broad PRs that touch on a lot of files
are not likely to be reviewed or accepted in a short timeframe. Accommodating many different issues in a single PR makes
it hard to determine whether your code fully addresses the underlying issue(s) or not and complicates the code review.

## Tests
All pull requests should include unit and/or integration tests that reflect the nature of what was added or changed
so it's clear that the functionality works as intended. Avoid using auto-generated tests that duplicate testing the
same functionality several times. Rather, seek to improve code coverage by validating each possible path of your
changes so future contributors can more easily navigate the contours of your logic and more readily identify limitations.

## Examples

The `examples` directory contains code samples for users to run to try out specific functionality of the various .NET SDK packages and extensions. When writing new and updated samples keep in mind:
The `examples` directory contains code samples for users to run to try out specific functionality of the various
Dapr .NET SDK packages and extensions. When writing new and updated samples keep in mind:

- All examples should be runnable on Windows, Linux, and MacOS. While .NET Core code is consistent among operating systems, any pre/post example commands should provide options through [codetabs]({{< ref "contributing-docs.md#tabbed-content" >}})
- Contain steps to download/install any required pre-requisites. Someone coming in with a fresh OS install should be able to start on the example and complete it without an error. Links to external download pages are fine.
- All examples should be runnable on Windows, Linux, and MacOS. While .NET Core code is consistent among operating
systems, any pre/post example commands should provide options through
[codetabs]({{< ref "contributing-docs.md#tabbed-content" >}})
- Contain steps to download/install any required pre-requisites. Someone coming in with a fresh OS install should be
able to start on the example and complete it without an error. Links to external download pages are fine.

## Docs
## Documentation

The `daprdocs` directory contains the markdown files that are rendered into the [Dapr Docs](https://docs.dapr.io) website. When the documentation website is built this repo is cloned and configured so that its contents are rendered with the docs content. When writing docs keep in mind:
The `daprdocs` directory contains the markdown files that are rendered into the [Dapr Docs](https://docs.dapr.io) website. When the
documentation website is built this repo is cloned and configured so that its contents are rendered with the docs
content. When writing docs keep in mind:

- All rules in the [docs guide]({{< ref contributing-docs.md >}}) should be followed in addition to these.
- All files and directories should be prefixed with `dotnet-` to ensure all file/directory names are globally unique across all Dapr documentation.
- All files and directories should be prefixed with `dotnet-` to ensure all file/directory names are globally
- unique across all Dapr documentation.

All pull requests should strive to include both XML documentation in the code clearly indicating what functionality
does and why it's there as well as changes to the published documentation to clarify for other developers how your change
improves the Dapr framework.

## GitHub Dapr Bot Commands

Checkout the [daprbot documentation](https://docs.dapr.io/contributing/daprbot/) for Github commands you can run in this repo for common tasks. For example, you can comment `/assign` on an issue to assign it to yourself.
Checkout the [daprbot documentation](https://docs.dapr.io/contributing/daprbot/) for Github commands you can run in this repo for common tasks. For example,
you can comment `/assign` on an issue to assign it to yourself.

## Commit Sign-offs
All code submitted to the Dapr .NET SDK must be signed off by the developer authoring it. This means that every
commit must end with the following:
> Signed-off-by: First Last <[email protected]>

The name and email address must match the registered GitHub name and email address of the user committing the changes.
We use a bot to detect this in pull requests and we will be unable to merge the PR if this check fails to validate.

If you notice that a PR has failed to validate because of a failed DCO check early on in the PR history, please consider
squashing the PR locally and resubmitting to ensure that the sign-off statement is included in the commit history.

# Languages, Tools and Processes
All source code in the Dapr .NET SDK is written in C# and targets the latest language version available to the earliest
supported .NET SDK. As of v1.15, this means that because .NET 6 is still supported, the latest language version available
is [C# version 10](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-10).

As of v1.15, the following versions of .NET are supported:

| Version | Notes |
| --- |-----------------------------------------------------------------|
| .NET 6 | Will be discontinued in v1.16 |
| .NET 7 | Only supported in Dapr.Workflows, will be discontinued in v1.16 |
| .NET 8 | Will continue to be supported in v1.16 |
| .NET 9 | Will continue to be supported in v1.16 |

Contributors are welcome to use whatever IDE they're most comfortable developing in, but please do not submit
IDE-specific preference files along with your contributions as these will be rejected.
83 changes: 6 additions & 77 deletions daprdocs/content/en/dotnet-sdk-docs/dotnet-ai/_index.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,12 @@
_index.md

---
type: docs
title: "Getting started with the Dapr AI .NET SDK client"
title: "Dapr AI .NET SDK"
linkTitle: "AI"
weight: 10000
description: How to get up and running with the Dapr AI .NET SDK
no_list: true
weight: 50000
description: Get up and running with the Dapr AI .NET SDK
---

The Dapr AI client package allows you to interact with the AI capabilities provided by the Dapr sidecar.

## Installation

To get started with the Dapr AI .NET SDK client, install the following package from NuGet:
```sh
dotnet add package Dapr.AI
```

A `DaprConversationClient` holes access to networking resources in the form of TCP sockets used to communicate with the Dapr sidecar.

### Dependency Injection

The `AddDaprAiConversation()` method will register the Dapr client ASP.NET Core dependency injection and is the recommended approach
for using this package. This method accepts an optional options delegate for configuring the `DaprConversationClient` and a
`ServiceLifetime` argument, allowing you to specify a different lifetime for the registered services instead of the default `Singleton`
value.

The following example assumes all default values are acceptable and is sufficient to register the `DaprConversationClient`:

```csharp
services.AddDaprAiConversation();
```

The optional configuration delegate is used to configure the `DaprConversationClient` by specifying options on the
`DaprConversationClientBuilder` as in the following example:
```csharp
services.AddSingleton<DefaultOptionsProvider>();
services.AddDaprAiConversation((serviceProvider, clientBuilder) => {
//Inject a service to source a value from
var optionsProvider = serviceProvider.GetRequiredService<DefaultOptionsProvider>();
var standardTimeout = optionsProvider.GetStandardTimeout();

//Configure the value on the client builder
clientBuilder.UseTimeout(standardTimeout);
});
```

### Manual Instantiation
Rather than using dependency injection, a `DaprConversationClient` can also be built using the static client builder.

For best performance, create a single long-lived instance of `DaprConversationClient` and provide access to that shared instance throughout
your application. `DaprConversationClient` instances are thread-safe and intended to be shared.

Avoid creating a `DaprConversationClient` per-operation.

A `DaprConversationClient` can be configured by invoking methods on the `DaprConversationClientBuilder` class before calling `.Build()`
to create the client. The settings for each `DaprConversationClient` are separate and cannot be changed after calling `.Build()`.

```csharp
var daprConversationClient = new DaprConversationClientBuilder()
.UseJsonSerializerSettings( ... ) //Configure JSON serializer
.Build();
```

See the .NET [documentation here]({{< ref dotnet-client >}}) for more information about the options available when configuring the Dapr client via the builder.

## Try it out
Put the Dapr AI .NET SDK to the test. Walk through the samples to see Dapr in action:

| SDK Samples | Description |
| ----------- | ----------- |
| [SDK samples](https://github.com/dapr/dotnet-sdk/tree/master/examples) | Clone the SDK repo to try out some examples and get started. |

## Building Blocks

This part of the .NET SDK allows you to interface with the Conversations API to send and receive messages from
large language models.

### Send messages

With the Dapr AI package, you can interact with the Dapr AI workloads from a .NET application.

Today, Dapr provides the Conversational API to engage with large language models. To get started with this workload,
walk through the [Dapr Conversational AI]({{< ref dotnet-ai-conversation-howto.md >}}) how-to guide.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
type: docs
title: "How to: Create and use Dapr AI Conversations in the .NET SDK"
linkTitle: "How to: Use the AI Conversations client"
weight: 500100
description: Learn how to create and use the Dapr Conversational AI client using the .NET SDK
---

## Prerequisites
- [.NET 6](https://dotnet.microsoft.com/download/dotnet/6.0), [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0), or [.NET 9](https://dotnet.microsoft.com/download/dotnet/9.0) installed
- [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/)
- [Initialized Dapr environment](https://docs.dapr.io/getting-started/install-dapr-selfhost)

{{% alert title="Note" color="primary" %}}

.NET 6 is supported as the minimum required for the Dapr .NET SDK packages in this release. Only .NET 8 and .NET 9
will be supported in Dapr v1.16 and later releases.

{{% /alert %}}

## Installation

To get started with the Dapr AI .NET SDK client, install the [Dapr.AI package](https://www.nuget.org/packages/Dapr.AI) from NuGet:
```sh
dotnet add package Dapr.AI
```

A `DaprConversationClient` maintains access to networking resources in the form of TCP sockets used to communicate with the Dapr sidecar.

### Dependency Injection

The `AddDaprAiConversation()` method will register the Dapr client ASP.NET Core dependency injection and is the recommended approach
for using this package. This method accepts an optional options delegate for configuring the `DaprConversationClient` and a
`ServiceLifetime` argument, allowing you to specify a different lifetime for the registered services instead of the default `Singleton`
value.

The following example assumes all default values are acceptable and is sufficient to register the `DaprConversationClient`:

```csharp
services.AddDaprAiConversation();
```

The optional configuration delegate is used to configure the `DaprConversationClient` by specifying options on the
`DaprConversationClientBuilder` as in the following example:
```csharp
services.AddSingleton<DefaultOptionsProvider>();
services.AddDaprAiConversation((serviceProvider, clientBuilder) => {
//Inject a service to source a value from
var optionsProvider = serviceProvider.GetRequiredService<DefaultOptionsProvider>();
var standardTimeout = optionsProvider.GetStandardTimeout();

//Configure the value on the client builder
clientBuilder.UseTimeout(standardTimeout);
});
```

### Manual Instantiation
Rather than using dependency injection, a `DaprConversationClient` can also be built using the static client builder.

For best performance, create a single long-lived instance of `DaprConversationClient` and provide access to that shared instance throughout
your application. `DaprConversationClient` instances are thread-safe and intended to be shared.

Avoid creating a `DaprConversationClient` per-operation.

A `DaprConversationClient` can be configured by invoking methods on the `DaprConversationClientBuilder` class before calling `.Build()`
to create the client. The settings for each `DaprConversationClient` are separate and cannot be changed after calling `.Build()`.

```csharp
var daprConversationClient = new DaprConversationClientBuilder()
.UseJsonSerializerSettings( ... ) //Configure JSON serializer
.Build();
```

See the .NET [documentation here]({{< ref dotnet-client >}}) for more information about the options available when configuring the Dapr client via the builder.

## Try it out
Put the Dapr AI .NET SDK to the test. Walk through the samples to see Dapr in action:

| SDK Samples | Description |
| ----------- | ----------- |
| [SDK samples](https://github.com/dapr/dotnet-sdk/tree/master/examples) | Clone the SDK repo to try out some examples and get started. |

## Building Blocks

This part of the .NET SDK allows you to interface with the Conversations API to send and receive messages from
large language models.

### Send messages


Loading
Loading