-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
546 additions
and
19 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...SKIT.FlurlHttpClient.Wechat.OpenAI/Extensions/WechatOpenAIClientExecuteAsyncExtensions.cs
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,33 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Flurl.Http; | ||
|
||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI | ||
{ | ||
public static class WechatOpenAIClientExecuteAsyncExtensions | ||
{ | ||
/// <summary> | ||
/// <para>异步调用 [POST] /v2/async/fetch 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/bot/fetch.html ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.AsyncFetchV2Response> ExecuteAsyncFetchV2Async(this WechatOpenAIClient client, Models.AsyncFetchV2Request request, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) throw new ArgumentNullException(nameof(client)); | ||
if (request is null) throw new ArgumentNullException(nameof(request)); | ||
|
||
IFlurlRequest flurlReq = client | ||
.CreateFlurlRequest(request, HttpMethod.Post, "v2", "async", "fetch"); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.AsyncFetchV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/SKIT.FlurlHttpClient.Wechat.OpenAI/Extensions/WechatOpenAIClientExecuteBotExtensions.cs
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,77 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Flurl.Http; | ||
|
||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI | ||
{ | ||
public static class WechatOpenAIClientExecuteBotExtensions | ||
{ | ||
/// <summary> | ||
/// <para>异步调用 [POST] /v2/bot/import/json 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/bot/import.html ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.BotImportJsonV2Response> ExecuteBotImportJsonV2Async(this WechatOpenAIClient client, Models.BotImportJsonV2Request request, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) throw new ArgumentNullException(nameof(client)); | ||
if (request is null) throw new ArgumentNullException(nameof(request)); | ||
|
||
IFlurlRequest flurlReq = client | ||
.CreateFlurlRequest(request, HttpMethod.Post, "v2", "bot", "import", "json"); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.BotImportJsonV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [POST] /v2/bot/publish 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/bot/publish.html ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.BotPublishV2Response> ExecuteBotPublishV2Async(this WechatOpenAIClient client, Models.BotPublishV2Request request, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) throw new ArgumentNullException(nameof(client)); | ||
if (request is null) throw new ArgumentNullException(nameof(request)); | ||
|
||
IFlurlRequest flurlReq = client | ||
.CreateFlurlRequest(request, HttpMethod.Post, "v2", "bot", "publish"); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.BotPublishV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// <para>异步调用 [POST] /v2/bot/effective_progress 接口。</para> | ||
/// <para> | ||
/// REF: <br/> | ||
/// <![CDATA[ https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/bot/progress.html ]]> | ||
/// </para> | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public static async Task<Models.BotEffectiveProgressV2Response> ExecuteBotEffectiveProgressV2Async(this WechatOpenAIClient client, Models.BotEffectiveProgressV2Request request, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) throw new ArgumentNullException(nameof(client)); | ||
if (request is null) throw new ArgumentNullException(nameof(request)); | ||
|
||
IFlurlRequest flurlReq = client | ||
.CreateFlurlRequest(request, HttpMethod.Post, "v2", "bot", "effective_progress"); | ||
|
||
return await client.SendFlurlRequestAsJsonAsync<Models.BotEffectiveProgressV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/SKIT.FlurlHttpClient.Wechat.OpenAI/Models/OpenAI/Async/AsyncFetchV2Request.cs
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,15 @@ | ||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /v2/async/fetch 接口的请求。</para> | ||
/// </summary> | ||
public class AsyncFetchV2Request : WechatOpenAIRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置任务 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("task_id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("task_id")] | ||
public string TaskId { get; set; } = string.Empty; | ||
} | ||
} |
133 changes: 133 additions & 0 deletions
133
src/SKIT.FlurlHttpClient.Wechat.OpenAI/Models/OpenAI/Async/AsyncFetchV2Response.cs
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,133 @@ | ||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /v2/async/fetch 接口的响应。</para> | ||
/// </summary> | ||
public class AsyncFetchV2Response : WechatOpenAIResponse<AsyncFetchV2Response.Types.Data> | ||
{ | ||
public static class Types | ||
{ | ||
public class Data : WechatOpenAIResponseData | ||
{ | ||
public static class Types | ||
{ | ||
public class Intent | ||
{ | ||
/// <summary> | ||
/// 获取或设置意图 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("id")] | ||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.TextualNumberReadOnlyConverter))] | ||
public long IntentId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置意图名称。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("name")] | ||
[System.Text.Json.Serialization.JsonPropertyName("name")] | ||
public string Name { get; set; } = default!; | ||
} | ||
|
||
public class FailedSkill | ||
{ | ||
/// <summary> | ||
/// 获取或设置技能名称。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("name")] | ||
[System.Text.Json.Serialization.JsonPropertyName("name")] | ||
public string Name { get; set; } = default!; | ||
} | ||
|
||
public class SucceededSkill : FailedSkill | ||
{ | ||
/// <summary> | ||
/// 获取或设置技能 ID。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("id")] | ||
[System.Text.Json.Serialization.JsonPropertyName("id")] | ||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Common.TextualNumberReadOnlyConverter))] | ||
public long SkillId { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置意图列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("intents")] | ||
[System.Text.Json.Serialization.JsonPropertyName("intents")] | ||
public Types.Intent[] IntentList { get; set; } = default!; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 获取或设置任务状态。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("state")] | ||
[System.Text.Json.Serialization.JsonPropertyName("state")] | ||
public int State { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置任务进度(单位:百分数)。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("progress")] | ||
[System.Text.Json.Serialization.JsonPropertyName("progress")] | ||
public int Progress { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置任务开始时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("start")] | ||
[System.Text.Json.Serialization.JsonPropertyName("start")] | ||
public long StartTimestamp { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置任务结束时间戳。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("end")] | ||
[System.Text.Json.Serialization.JsonPropertyName("end")] | ||
public long EndTimestamp { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导出任务的 URL。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("url")] | ||
[System.Text.Json.Serialization.JsonPropertyName("url")] | ||
public string? Url { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导入的总数量。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("total_count")] | ||
[System.Text.Json.Serialization.JsonPropertyName("total_count")] | ||
public int TotalCount { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导入失败的数量。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("fail_count")] | ||
[System.Text.Json.Serialization.JsonPropertyName("fail_count")] | ||
public int FailedCount { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导入失败的技能列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("fail_skill_info")] | ||
[System.Text.Json.Serialization.JsonPropertyName("fail_skill_info")] | ||
public Types.FailedSkill[]? FailedSkillList { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导入成功的数量。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("success_count")] | ||
[System.Text.Json.Serialization.JsonPropertyName("success_count")] | ||
public int SucceededCount { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置导入成功的技能列表。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("success_skill_info")] | ||
[System.Text.Json.Serialization.JsonPropertyName("success_skill_info")] | ||
public Types.SucceededSkill[]? SucceededSkillList { get; set; } | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/SKIT.FlurlHttpClient.Wechat.OpenAI/Models/OpenAI/Bot/BotEffectiveProgressV2Request.cs
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 @@ | ||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /v2/bot/effective_progress 接口的请求。</para> | ||
/// </summary> | ||
public class BotEffectiveProgressV2Request : WechatOpenAIRequest | ||
{ | ||
/// <summary> | ||
/// 获取或设置查询环境。 | ||
/// <para>默认值:"online"</para> | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("env")] | ||
[System.Text.Json.Serialization.JsonPropertyName("env")] | ||
public string Environment { get; set; } = "online"; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/SKIT.FlurlHttpClient.Wechat.OpenAI/Models/OpenAI/Bot/BotEffectiveProgressV2Response.cs
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,35 @@ | ||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models | ||
{ | ||
/// <summary> | ||
/// <para>表示 [POST] /v2/bot/effective_progress 接口的响应。</para> | ||
/// </summary> | ||
public class BotEffectiveProgressV2Response : WechatOpenAIResponse<BotEffectiveProgressV2Response.Types.Data> | ||
{ | ||
public static class Types | ||
{ | ||
public class Data : WechatOpenAIResponseData | ||
{ | ||
/// <summary> | ||
/// 获取或设置任务状态。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("status")] | ||
[System.Text.Json.Serialization.JsonPropertyName("status")] | ||
public int Status { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置任务进度(单位:百分数)。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("progress")] | ||
[System.Text.Json.Serialization.JsonPropertyName("progress")] | ||
public int Progress { get; set; } | ||
|
||
/// <summary> | ||
/// 获取或设置任务结束时间字符串。 | ||
/// </summary> | ||
[Newtonsoft.Json.JsonProperty("end_time")] | ||
[System.Text.Json.Serialization.JsonPropertyName("end_time")] | ||
public string? EndTimeString { get; set; } | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.