feat(openai): 升级公共组件

This commit is contained in:
Fu Diwei
2022-01-21 10:09:50 +08:00
parent a1ae77ddb9
commit 60e5ed6cea
12 changed files with 153 additions and 122 deletions

View File

@@ -52,16 +52,16 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// 获取或设置结果。
/// </summary>
[Newtonsoft.Json.JsonProperty("product")]
[Newtonsoft.Json.JsonConverter(typeof(Converters.NewtonsoftJsonProductPropertyArrayConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Converters.ResponsePropertyProductPropertyArrayNewtonsoftJsonConverter))]
[System.Text.Json.Serialization.JsonPropertyName("product")]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.SystemTextJsonProductPropertyArrayConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.ResponsePropertyProductPropertyArraySystemTextJsonConverter))]
public Types.ProductProperty[] ProductPropertyList { get; set; } = default!;
}
}
internal static class Converters
{
internal class NewtonsoftJsonProductPropertyArrayConverter : Newtonsoft.Json.JsonConverter<Types.Result.Types.ProductProperty[]?>
internal class ResponsePropertyProductPropertyArrayNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter<Types.Result.Types.ProductProperty[]?>
{
public override bool CanRead
{
@@ -154,7 +154,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
}
}
internal class SystemTextJsonProductPropertyArrayConverter : System.Text.Json.Serialization.JsonConverter<Types.Result.Types.ProductProperty[]?>
internal class ResponsePropertyProductPropertyArraySystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter<Types.Result.Types.ProductProperty[]?>
{
public override Types.Result.Types.ProductProperty[]? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
@@ -250,9 +250,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// 获取或设置抽取结果信息。
/// </summary>
[Newtonsoft.Json.JsonProperty("entities")]
[Newtonsoft.Json.JsonConverter(typeof(Converters.NewtonsoftJsonProductPropertyArrayConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Converters.ResponsePropertyProductPropertyArrayNewtonsoftJsonConverter))]
[System.Text.Json.Serialization.JsonPropertyName("entities")]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.SystemTextJsonProductPropertyArrayConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.ResponsePropertyProductPropertyArraySystemTextJsonConverter))]
public Types.Result Result { get; set; } = default!;
}
}

View File

@@ -31,7 +31,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
internal static class Converters
{
internal class NewtonsoftJsonResultArrayConverter : Newtonsoft.Json.JsonConverter<Types.Result[]?>
internal class ResponsePropertyResultArrayNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter<Types.Result[]?>
{
public override bool CanRead
{
@@ -114,7 +114,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
}
}
internal class SystemTextJsonResultArrayConverter : System.Text.Json.Serialization.JsonConverter<Types.Result[]?>
internal class ResponsePropertyResultArraySystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter<Types.Result[]?>
{
public override Types.Result[]? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
@@ -193,9 +193,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// 获取或设置结果。
/// </summary>
[Newtonsoft.Json.JsonProperty("result")]
[Newtonsoft.Json.JsonConverter(typeof(Converters.NewtonsoftJsonResultArrayConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Converters.ResponsePropertyResultArrayNewtonsoftJsonConverter))]
[System.Text.Json.Serialization.JsonPropertyName("result")]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.SystemTextJsonResultArrayConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.ResponsePropertyResultArraySystemTextJsonConverter))]
public Types.Result[] ResultList { get; set; } = default!;
}
}

View File

@@ -31,7 +31,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
internal static class Converters
{
internal class NewtonsoftJsonResultArrayConverter : Newtonsoft.Json.JsonConverter<Types.Result[]?>
internal class ResponsePropertyResultArrayNewtonsoftJsonConverter : Newtonsoft.Json.JsonConverter<Types.Result[]?>
{
public override bool CanRead
{
@@ -114,7 +114,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
}
}
internal class SystemTextJsonResultArrayConverter : System.Text.Json.Serialization.JsonConverter<Types.Result[]?>
internal class ResponsePropertyResultArraySystemTextJsonConverter : System.Text.Json.Serialization.JsonConverter<Types.Result[]?>
{
public override Types.Result[]? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
@@ -193,9 +193,9 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// 获取或设置结果。
/// </summary>
[Newtonsoft.Json.JsonProperty("result")]
[Newtonsoft.Json.JsonConverter(typeof(Converters.NewtonsoftJsonResultArrayConverter))]
[Newtonsoft.Json.JsonConverter(typeof(Converters.ResponsePropertyResultArrayNewtonsoftJsonConverter))]
[System.Text.Json.Serialization.JsonPropertyName("result")]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.SystemTextJsonResultArrayConverter))]
[System.Text.Json.Serialization.JsonConverter(typeof(Converters.ResponsePropertyResultArraySystemTextJsonConverter))]
public Types.Result[] ResultList { get; set; } = default!;
}
}

View File

@@ -0,0 +1,27 @@
## SKIT.FlurlHttpClient.Wechat.OpenAI
[![GitHub Stars](https://img.shields.io/github/stars/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat?logo=github&label=Stars)](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat) [![GitHub Forks](https://img.shields.io/github/forks/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat?logo=github&label=Forks)](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat) [![NuGet Download](https://img.shields.io/nuget/dt/SKIT.FlurlHttpClient.Wechat.OpenAI.svg?sanitize=true&label=Downloads)](https://www.nuget.org/packages/SKIT.FlurlHttpClient.Wechat.OpenAI) [![License](https://img.shields.io/github/license/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat?label=License)](https://mit-license.org/)
基于 `Flurl.Http` 的微信对话开放平台 API 版客户端。
---
### 【功能特性】
- 基于微信对话开放平台 API 封装。
- 支持平台接入、第三方接入两种模式。
- 对于第三方接入,请求时自动生成加密参数,无需开发者手动干预。
- 对于平台接入,请求时自动生成请求唯一标识,无需开发者手动干预。
- 提供了解析回调通知事件等扩展方法。
---
### 【开发文档】
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat)。
---
### 【更新日志】
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat/blob/main/CHANGELOG.md)。

View File

@@ -9,6 +9,8 @@
<PropertyGroup>
<PackageId>SKIT.FlurlHttpClient.Wechat.OpenAI</PackageId>
<PackageIcon>LOGO.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat</PackageProjectUrl>
<PackageTags>Flurl.Http Wechat Weixin MicroMessage WechatAI WechatOpenAI WexinAI WeixinOpenAI 微信 微信智能对话 微信对话开放平台 微信智能对话开放平台 智能对话平台</PackageTags>
@@ -17,18 +19,29 @@
<Authors>Fu Diwei</Authors>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<None Include="../../LOGO.png" Pack="true" PackagePath="/" />
<None Include="README.md" Pack="true" PackagePath="/" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461'" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JWT" Version="8.8.1" />
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.1.1" />
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.2.0" />
</ItemGroup>
</Project>

View File

@@ -10,7 +10,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
public static class SHA1Utility
{
/// <summary>
/// 获取信息摘要。
/// 获取 SHA-1 信息摘要。
/// </summary>
/// <param name="bytes">信息字节数组。</param>
/// <returns>信息摘要。</returns>
@@ -24,7 +24,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Utilities
}
/// <summary>
/// 获取信息摘要。
/// 获取 SHA-1 信息摘要。
/// </summary>
/// <param name="message">文本信息。</param>
/// <returns>信息摘要。</returns>