-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from cnblogs/support-microsoft-extensions-ai
feat: support microsoft extensions ai
- Loading branch information
Showing
28 changed files
with
1,376 additions
and
76 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
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
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 |
---|---|---|
@@ -1,21 +1,18 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Cnblogs.DashScope.Sample; | ||
namespace Cnblogs.DashScope.Sample; | ||
|
||
public enum SampleType | ||
{ | ||
[Description("Simple prompt completion")] | ||
TextCompletion, | ||
|
||
[Description("Simple prompt completion with incremental output")] | ||
TextCompletionSse, | ||
|
||
[Description("Conversation between user and assistant")] | ||
ChatCompletion, | ||
|
||
[Description("Conversation with tools")] | ||
ChatCompletionWithTool, | ||
|
||
[Description("Conversation with files")] | ||
ChatCompletionWithFiles | ||
ChatCompletionWithFiles, | ||
|
||
MicrosoftExtensionsAi, | ||
|
||
MicrosoftExtensionsAiToolCall | ||
} |
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,25 @@ | ||
using System.ComponentModel; | ||
using System.Text.Json; | ||
using Cnblogs.DashScope.Core; | ||
using Microsoft.Extensions.AI; | ||
|
||
namespace Cnblogs.DashScope.Sample; | ||
|
||
public static class ToolCallWithExtensions | ||
{ | ||
public static async Task ToolCallWithExtensionAsync(this IDashScopeClient dashScopeClient) | ||
{ | ||
[Description("Gets the weather")] | ||
string GetWeather() => Random.Shared.NextDouble() > 0.5 ? "It's sunny" : "It's raining"; | ||
|
||
var chatOptions = new ChatOptions { Tools = [AIFunctionFactory.Create(GetWeather)] }; | ||
|
||
var client = dashScopeClient.AsChatClient("qwen-max").AsBuilder().UseFunctionInvocation().Build(); | ||
await foreach (var message in client.CompleteStreamingAsync("What is weather today?", chatOptions)) | ||
{ | ||
Console.WriteLine(JsonSerializer.Serialize(message)); | ||
} | ||
|
||
Console.WriteLine(); | ||
} | ||
} |
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Product>Cnblogs.DashScope.AI</Product> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<PackageTags>Cnblogs;Dashscope;Microsoft.Extensions.AI;Sdk;Embedding;</PackageTags> | ||
<Description>Implementation of generative AI abstractions for DashScope endpoints.</Description> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Cnblogs.DashScope.Sdk\Cnblogs.DashScope.Sdk.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5"/> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.