-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature_upgrade_statusapi_1.0.0
Signed-off-by: Whit Waldo <[email protected]>
- Loading branch information
Showing
43 changed files
with
3,333 additions
and
2,134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" /> | ||
<PackageVersion Include="FluentAssertions" Version="5.9.0" /> | ||
<PackageVersion Include="GitHubActionsTestLogger" Version="1.1.2" /> | ||
<PackageVersion Include="Google.Api.CommonProtos" Version="2.2.0" /> | ||
<PackageVersion Include="Google.Protobuf" Version="3.28.2" /> | ||
<PackageVersion Include="Grpc.AspNetCore" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Core.Testing" Version="2.46.6" /> | ||
<PackageVersion Include="Grpc.Net.Client" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Net.ClientFactory" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Tools" Version="2.67.0" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.35" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.35" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.2" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.2" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.DurableTask.Client.Grpc" Version="1.3.0" /> | ||
<PackageVersion Include="Microsoft.DurableTask.Worker.Grpc" Version="1.3.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" /> | ||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="6.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Http" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | ||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" /> | ||
<PackageVersion Include="MinVer" Version="2.3.0" /> | ||
<PackageVersion Include="Moq" Version="4.20.72" /> | ||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageVersion Include="protobuf-net.Grpc.AspNetCore" Version="1.2.2" /> | ||
<PackageVersion Include="Serilog.AspNetCore" Version="6.1.0" /> | ||
<PackageVersion Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" /> | ||
<PackageVersion Include="System.Formats.Asn1" Version="6.0.1" /> | ||
<PackageVersion Include="System.Text.Json" Version="6.0.10" /> | ||
<PackageVersion Include="xunit" Version="2.9.2" /> | ||
<PackageVersion Include="xunit.extensibility.core" Version="2.9.2" /> | ||
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> | ||
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" /> | ||
<PackageVersion Include="FluentAssertions" Version="5.9.0" /> | ||
<PackageVersion Include="GitHubActionsTestLogger" Version="1.1.2" /> | ||
<PackageVersion Include="Google.Api.CommonProtos" Version="2.2.0" /> | ||
<PackageVersion Include="Google.Protobuf" Version="3.28.2" /> | ||
<PackageVersion Include="Grpc.AspNetCore" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Core.Testing" Version="2.46.6" /> | ||
<PackageVersion Include="Grpc.Net.Client" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Net.ClientFactory" Version="2.66.0" /> | ||
<PackageVersion Include="Grpc.Tools" Version="2.67.0" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.35" /> | ||
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.35" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.2" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.2" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" /> | ||
<PackageVersion Include="Microsoft.DurableTask.Client.Grpc" Version="1.3.0" /> | ||
<PackageVersion Include="Microsoft.DurableTask.Worker.Grpc" Version="1.3.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4" /> | ||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="6.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Http" Version="6.0.0" /> | ||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | ||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" /> | ||
<PackageVersion Include="MinVer" Version="2.3.0" /> | ||
<PackageVersion Include="Moq" Version="4.20.72" /> | ||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageVersion Include="protobuf-net.Grpc.AspNetCore" Version="1.2.2" /> | ||
<PackageVersion Include="Serilog.AspNetCore" Version="6.1.0" /> | ||
<PackageVersion Include="Serilog.Sinks.Console" Version="4.1.0" /> | ||
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" /> | ||
<PackageVersion Include="System.Formats.Asn1" Version="6.0.1" /> | ||
<PackageVersion Include="System.Text.Json" Version="6.0.10" /> | ||
<PackageVersion Include="xunit" Version="2.9.2" /> | ||
<PackageVersion Include="xunit.extensibility.core" Version="2.9.2" /> | ||
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
_index.md | ||
|
||
--- | ||
type: docs | ||
title: "Getting started with the Dapr AI .NET SDK client" | ||
linkTitle: "AI" | ||
weight: 10000 | ||
description: How to get up and running with the Dapr AI .NET SDK | ||
no_list: true | ||
--- | ||
|
||
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 | ||
|
||
|
7 changes: 7 additions & 0 deletions
7
daprdocs/content/en/dotnet-sdk-docs/dotnet-ai/dotnet-ai-usage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
type: docs | ||
title: "Best practices with the Dapr AI .NET SDK client" | ||
linkTitle: "Best Practices" | ||
weight: 100000 | ||
description: How to get up and running with the Dapr .NET SDK | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\Dapr.AI\Dapr.AI.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Dapr.AI.Conversation; | ||
using Dapr.AI.Conversation.Extensions; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddDaprAiConversation(); | ||
|
||
var app = builder.Build(); | ||
|
||
var conversationClient = app.Services.GetRequiredService<DaprConversationClient>(); | ||
var response = await conversationClient.ConverseAsync("conversation", | ||
new List<DaprConversationInput> | ||
{ | ||
new DaprConversationInput( | ||
"Please write a witty haiku about the Dapr distributed programming framework at dapr.io", | ||
DaprConversationRole.Generic) | ||
}); | ||
|
||
Console.WriteLine("Received the following from the LLM:"); | ||
foreach (var resp in response.Outputs) | ||
{ | ||
Console.WriteLine($"\t{resp.Result}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Dapr.AI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b1f597635c44597fcecb493e2b1327033b29b1a98ac956a1a538664b68f87d45fbaada0438a15a6265e62864947cc067d8da3a7d93c5eb2fcbb850e396c8684dba74ea477d82a1bbb18932c0efb30b64ff1677f85ae833818707ac8b49ad8062ca01d2c89d8ab1843ae73e8ba9649cd28666b539444dcdee3639f95e2a099bb2")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// ------------------------------------------------------------------------ | ||
// Copyright 2024 The Dapr Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ------------------------------------------------------------------------ | ||
|
||
using Google.Protobuf.WellKnownTypes; | ||
|
||
namespace Dapr.AI.Conversation; | ||
|
||
/// <summary> | ||
/// Options used to configure the conversation operation. | ||
/// </summary> | ||
/// <param name="ConversationId">The identifier of the conversation this is a continuation of.</param> | ||
public sealed record ConversationOptions(string? ConversationId = null) | ||
{ | ||
/// <summary> | ||
/// Temperature for the LLM to optimize for creativity or predictability. | ||
/// </summary> | ||
public double Temperature { get; init; } = default; | ||
/// <summary> | ||
/// Flag that indicates whether data that comes back from the LLM should be scrubbed of PII data. | ||
/// </summary> | ||
public bool ScrubPII { get; init; } = default; | ||
/// <summary> | ||
/// The metadata passing to the conversation components. | ||
/// </summary> | ||
public IReadOnlyDictionary<string, string> Metadata { get; init; } = new Dictionary<string, string>(); | ||
/// <summary> | ||
/// Parameters for all custom fields. | ||
/// </summary> | ||
public IReadOnlyDictionary<string, Any> Parameters { get; init; } = new Dictionary<string, Any>(); | ||
} |
Oops, something went wrong.