chore(openai): 调整目录结构

This commit is contained in:
Fu Diwei 2022-11-21 10:23:28 +08:00
parent e4981f164e
commit 922e70f8db
23 changed files with 262 additions and 38 deletions

View File

@ -7,26 +7,6 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
/// </summary>
public static class WechatOpenAIPlatformClientEventExtensions
{
private class EncryptedWechatOpenAIEvent
{
[Newtonsoft.Json.JsonProperty("Encrypt")]
[System.Text.Json.Serialization.JsonPropertyName("Encrypt")]
public string EncryptedData { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("TimeStamp")]
[System.Text.Json.Serialization.JsonPropertyName("TimeStamp")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalStringConverter))]
public string Timestamp { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("Nonce")]
[System.Text.Json.Serialization.JsonPropertyName("Nonce")]
public string Nonce { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("MsgSignature")]
[System.Text.Json.Serialization.JsonPropertyName("MsgSignature")]
public string Signature { get; set; } = default!;
}
private static TEvent InnerDeserializeEventFromXml<TEvent>(this WechatOpenAIPlatformClient client, string callbackXml)
where TEvent : WechatOpenAIPlatformEvent
{
@ -96,7 +76,6 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
throw new Exceptions.WechatOpenAIEventSerializationException("Serialize event failed. Please see the `InnerException` for more details.", ex);
}
if (string.IsNullOrEmpty(client.Credentials.EncodingAESKey))
throw new Exceptions.WechatOpenAIEventSerializationException("Encrypt event failed, because there is no encoding AES key.");
if (string.IsNullOrEmpty(client.Credentials.Token))

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@ -6,7 +6,7 @@ using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI
{
public static class WechatOpenAIPlatformClientExecuteQueryExtensions
public static class WechatOpenAIPlatformClientExecuteDialogExtensions
{
/// <summary>
/// <para>异步调用 [POST] /sign/{TOKEN} 接口。</para>
@ -48,7 +48,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
/// <summary>
/// <para>异步调用 [POST] /gethotquerylist/{TOKEN} 接口。</para>
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/platform/api/gethotquerylist.html </para>
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/gethotquerylist.html </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>

View File

@ -0,0 +1,67 @@
using System.Xml.Serialization;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
/// <summary>
/// <para>表示 [POST] /gethotquerydetail/{TOKEN} 接口的请求。</para>
/// </summary>
[XmlRoot("xml")]
public class GetHotQueryDetailRequest : WechatOpenAIPlatformRequest, WechatOpenAIPlatformRequest.Serialization.IEncryptedXmlable
{
/// <summary>
/// 获取或设置分页页数。
/// <para>默认值1</para>
/// </summary>
[XmlElement("pageNo")]
public int Page { get; set; } = 1;
/// <summary>
/// 获取或设置分页每页数量。
/// <para>默认值10</para>
/// </summary>
[XmlElement("pageSize")]
public int Limit { get; set; } = 10;
/// <summary>
/// 获取或设置命中类型。
/// </summary>
[XmlElement("matchType", IsNullable = true)]
public int? MatchType { get; set; }
/// <summary>
/// 获取或设置问题类型。
/// </summary>
[XmlElement("cluesType", IsNullable = true)]
public int? ClueType { get; set; }
/// <summary>
/// 获取或设置报告类型。
/// </summary>
[XmlElement("reportType", IsNullable = true)]
public int? ReportType { get; set; }
/// <summary>
/// 获取或设置日期字符串格式yyyy-MM-dd
/// </summary>
[XmlElement("date")]
public string DateString { get; set; } = string.Empty;
/// <summary>
/// 获取或设置开发者的 OpenId。
/// </summary>
[XmlElement("openid")]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置聚类结果类别 ID。
/// </summary>
[XmlElement("clusterId")]
public string ClusterId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置聚类结果。
/// </summary>
[XmlElement("hotQuesCluster", IsNullable = true)]
public string? HotQuestionCluster { get; set; }
}
}

View File

@ -0,0 +1,90 @@
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
/// <summary>
/// <para>表示 [POST] /gethotquerydetail/{TOKEN} 接口的响应。</para>
/// </summary>
public class GetHotQueryDetailResponse : WechatOpenAIPlatformResponse<GetHotQueryDetailResponse.Types.Data>
{
public static class Types
{
public class Data
{
public static class Types
{
public class HotQuery
{
/// <summary>
/// 获取或设置提问总数。
/// </summary>
[Newtonsoft.Json.JsonProperty("askCount")]
[System.Text.Json.Serialization.JsonPropertyName("askCount")]
public int AskCount { get; set; }
/// <summary>
/// 获取或设置提问用户数。
/// </summary>
[Newtonsoft.Json.JsonProperty("askUserCount")]
[System.Text.Json.Serialization.JsonPropertyName("askUserCount")]
public int AskUserCount { get; set; }
/// <summary>
/// 获取或设置命中的技能。
/// </summary>
[Newtonsoft.Json.JsonProperty("hitIntent")]
[System.Text.Json.Serialization.JsonPropertyName("hitIntent")]
public string? HitIntent { get; set; }
/// <summary>
/// 获取或设置相似问题。
/// </summary>
[Newtonsoft.Json.JsonProperty("ques")]
[System.Text.Json.Serialization.JsonPropertyName("ques")]
public string Question { get; set; } = default!;
/// <summary>
/// 获取或设置问题得分。
/// </summary>
[Newtonsoft.Json.JsonProperty("score")]
[System.Text.Json.Serialization.JsonPropertyName("score")]
public double Score { get; set; }
}
}
/// <summary>
/// 获取或设置问题数量。
/// </summary>
[Newtonsoft.Json.JsonProperty("count")]
[System.Text.Json.Serialization.JsonPropertyName("count")]
public int HotQuestionCount { get; set; }
/// <summary>
/// 获取或设置分页总页数。
/// </summary>
[Newtonsoft.Json.JsonProperty("totalPages")]
[System.Text.Json.Serialization.JsonPropertyName("totalPages")]
public int TotalPageCount { get; set; }
/// <summary>
/// 获取或设置热问列表。
/// </summary>
[Newtonsoft.Json.JsonProperty("list")]
[System.Text.Json.Serialization.JsonPropertyName("list")]
public Types.HotQuery[] HotQueryList { get; set; } = default!;
}
}
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("code")]
[System.Text.Json.Serialization.JsonPropertyName("code")]
public override int? ErrorCode { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("msg")]
[System.Text.Json.Serialization.JsonPropertyName("msg")]
public override string? ErrorMessage { get; set; }
}
}

View File

@ -1,4 +1,4 @@
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
/// <summary>
/// <para>表示 [POST] /gethotquerylist/{TOKEN} 接口的响应。</para>
@ -25,11 +25,11 @@
public string Question { get; set; } = default!;
/// <summary>
/// 获取或设置分数
/// 获取或设置问题得分。
/// </summary>
[Newtonsoft.Json.JsonProperty("score")]
[System.Text.Json.Serialization.JsonPropertyName("score")]
public int Score { get; set; }
public double Score { get; set; }
}
}
@ -50,8 +50,8 @@
/// <summary>
/// 获取或设置问法总数。
/// </summary>
[Newtonsoft.Json.JsonProperty("askUserCount")]
[System.Text.Json.Serialization.JsonPropertyName("askUserCount")]
[Newtonsoft.Json.JsonProperty("quesCount")]
[System.Text.Json.Serialization.JsonPropertyName("quesCount")]
public int QuestionCount { get; set; }
/// <summary>
@ -61,6 +61,20 @@
[System.Text.Json.Serialization.JsonPropertyName("cluesType")]
public int ClueType { get; set; }
/// <summary>
/// 获取或设置聚类结果类别 ID。
/// </summary>
[Newtonsoft.Json.JsonProperty("clusterId")]
[System.Text.Json.Serialization.JsonPropertyName("clusterId")]
public string ClusterId { get; set; } = default!;
/// <summary>
/// 获取或设置聚类结果。
/// </summary>
[Newtonsoft.Json.JsonProperty("hotQuesCluster")]
[System.Text.Json.Serialization.JsonPropertyName("hotQuesCluster")]
public string? HotQuestionCluster { get; set; }
/// <summary>
/// 获取或设置示例列表
/// </summary>
@ -99,5 +113,19 @@
public Types.HotQuery[] HotQueryList { get; set; } = default!;
}
}
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("code")]
[System.Text.Json.Serialization.JsonPropertyName("code")]
public override int? ErrorCode { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Newtonsoft.Json.JsonProperty("msg")]
[System.Text.Json.Serialization.JsonPropertyName("msg")]
public override string? ErrorMessage { get; set; }
}
}

View File

@ -1,4 +1,4 @@
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
/// <summary>
/// <para>表示 [POST] /nlp/recommend_questions/{TOKEN} 接口的请求。</para>

View File

@ -1,4 +1,4 @@
using System.Xml.Serialization;
using System.Xml.Serialization;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
@ -28,9 +28,8 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// <summary>
/// 获取或设置有效期(单位:秒)。
/// <para>默认值1800</para>
/// </summary>
[XmlElement("expires")]
public int ExpiresIn { get; set; } = 1800;
[XmlElement("expires", IsNullable = true)]
public int? ExpiresIn { get; set; }
}
}

View File

@ -1,4 +1,4 @@
using System.Xml.Serialization;
using System.Xml.Serialization;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
@ -19,5 +19,11 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// </summary>
[XmlElement("openid")]
public string OpenId { get; set; } = string.Empty;
/// <summary>
/// 获取或设置获取类型。
/// </summary>
[XmlElement("type", IsNullable = true)]
public int? Type { get; set; }
}
}

View File

@ -1,4 +1,4 @@
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
/// <summary>
/// <para>表示 [POST] /kefustate/get/{TOKEN} 接口的响应。</para>
@ -6,10 +6,17 @@
public class KefuStateGetResponse : WechatOpenAIPlatformResponse
{
/// <summary>
/// 获取或设置客接入状态。
/// 获取或设置客接入状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("kefustate")]
[System.Text.Json.Serialization.JsonPropertyName("kefustate")]
public string State { get; set; } = default!;
/// <summary>
/// 获取或设置人工客服接入状态。
/// </summary>
[Newtonsoft.Json.JsonProperty("status")]
[System.Text.Json.Serialization.JsonPropertyName("status")]
public string Status { get; set; } = default!;
}
}

View File

@ -1,4 +1,4 @@
using System.Xml.Serialization;
using System.Xml.Serialization;
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
{
@ -49,5 +49,11 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models.Platform
/// </summary>
[XmlElement("kefuavatar", IsNullable = true)]
public string? KfAvatarUrl { get; set; }
/// <summary>
/// 获取或设置分类或技能名称。
/// </summary>
[XmlElement("ans_node_name", IsNullable = true)]
public string? AnswerNodeName { get; set; }
}
}

View File

@ -0,0 +1,17 @@
{
"code": 0,
"msg": "",
"data": {
"count": 0,
"totalPages": 0,
"list": [
{
"ques": "",
"score": 0,
"hitIntent": "",
"askCount": 0,
"askUserCount": 0
}
]
}
}

View File

@ -0,0 +1,25 @@
{
"code": 0,
"msg": "",
"data": {
"hotQuesClusterCount": 0,
"hotQuesCount": 0,
"totalPages": 0,
"list": [
{
"askCount": 0,
"askUserCount": 0,
"quesCount": 0,
"cluesType": 0,
"clusterId": "",
"hotQuesCluster": "",
"exampleQues": [
{
"ques": "",
"score": 0
}
]
}
]
}
}