Skip to content

Commit fce85a6

Browse files
committed
feat: implement IChatClient
1 parent 7452bc6 commit fce85a6

File tree

10 files changed

+599
-234
lines changed

10 files changed

+599
-234
lines changed

Cnblogs.DashScope.Sdk.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.Core", "s
1818
EndProject
1919
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.DashScope.Sdk.SnapshotGenerator", "test\Cnblogs.DashScope.Sdk.SnapshotGenerator\Cnblogs.DashScope.Sdk.SnapshotGenerator.csproj", "{5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1}"
2020
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cnblogs.Extensions.AI.DashScope", "src\Cnblogs.Extensions.AI.DashScope\Cnblogs.Extensions.AI.DashScope.csproj", "{5D5AD75A-8084-4738-AC56-B8A23E649452}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|Any CPU = Debug|Any CPU
@@ -30,6 +32,7 @@ Global
3032
{C910495B-87AB-4AC1-989C-B6720695A139} = {008988ED-0A3B-4272-BCC3-7B4110699345}
3133
{CC389455-A3EA-4F09-B524-4DC351A1E1AA} = {008988ED-0A3B-4272-BCC3-7B4110699345}
3234
{5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1} = {CFC8ECB3-5248-46CD-A56C-EC088F2A3804}
35+
{5D5AD75A-8084-4738-AC56-B8A23E649452} = {008988ED-0A3B-4272-BCC3-7B4110699345}
3336
EndGlobalSection
3437
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3538
{FA6A118A-8D26-4B7A-9952-8504B8A0025B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -56,5 +59,9 @@ Global
5659
{5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1}.Debug|Any CPU.Build.0 = Debug|Any CPU
5760
{5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1}.Release|Any CPU.ActiveCfg = Release|Any CPU
5861
{5088DE77-1CE3-46FB-B9D0-27A6C9A5EED1}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{5D5AD75A-8084-4738-AC56-B8A23E649452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{5D5AD75A-8084-4738-AC56-B8A23E649452}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{5D5AD75A-8084-4738-AC56-B8A23E649452}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{5D5AD75A-8084-4738-AC56-B8A23E649452}.Release|Any CPU.Build.0 = Release|Any CPU
5966
EndGlobalSection
6067
EndGlobal

src/Cnblogs.DashScope.Core/MultimodalMessageContent.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ public static MultimodalMessageContent ImageContent(string url, int? minPixels =
3333
return new MultimodalMessageContent(url, MinPixels: minPixels, MaxPixels: maxPixels);
3434
}
3535

36+
/// <summary>
37+
/// Represents an image content.
38+
/// </summary>
39+
/// <param name="bytes">Image binary to sent using base64 data uri.</param>
40+
/// <param name="mediaType">Image media type.</param>
41+
/// <param name="minPixels">For qwen-vl-ocr only. Minimal pixels for ocr task.</param>
42+
/// <param name="maxPixels">For qwen-vl-ocr only. Maximum pixels for ocr task.</param>
43+
/// <returns></returns>
44+
public static MultimodalMessageContent ImageContent(
45+
ReadOnlySpan<byte> bytes,
46+
string mediaType,
47+
int? minPixels = null,
48+
int? maxPixels = null)
49+
{
50+
return ImageContent(
51+
$"data:{mediaType};base64,{Convert.ToBase64String(bytes)}",
52+
minPixels,
53+
maxPixels);
54+
}
55+
3656
/// <summary>
3757
/// Represents a text content.
3858
/// </summary>

src/Cnblogs.DashScope.Core/ToolCall.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
/// </summary>
66
/// <param name="Id">Id of this tool call.</param>
77
/// <param name="Type">Type of the tool.</param>
8+
/// <param name="Index">Index of this tool in input tool list.</param>
89
/// <param name="Function">Not null if type is function.</param>
9-
public record ToolCall(string? Id, string Type, FunctionCall? Function);
10+
public record ToolCall(string? Id, string Type, int Index, FunctionCall Function);

src/Cnblogs.DashScope.Sdk/Cnblogs.DashScope.Sdk.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="JsonSchema.Net.Generation" Version="4.5.1" />
9-
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" />
109
</ItemGroup>
1110
<ItemGroup>
1211
<ProjectReference Include="..\Cnblogs.DashScope.Core\Cnblogs.DashScope.Core.csproj" />

src/Cnblogs.DashScope.Sdk/DashScopeChatClient.cs

Lines changed: 0 additions & 231 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Product>Cnblogs.Extensions.AI.DashScope</Product>
4+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
5+
<PackageTags>Cnblogs;Dashscope;Microsoft.Extensions.AI;Sdk;Embedding;</PackageTags>
6+
<Description>Implementation of generative AI abstractions for DashScope endpoints.</Description>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<ProjectReference Include="..\Cnblogs.DashScope.Sdk\Cnblogs.DashScope.Sdk.csproj" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5"/>
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)