mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 23:13:32 +08:00
feat(openai): 新增异步任务查询相关接口
This commit is contained in:
parent
f2238aa3ba
commit
d6d86f6e67
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
||||
{
|
||||
public static class WechatOpenAIClientExecuteAsyncExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /v1/async/fetch 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v1/task_fetch.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.AsyncFetchResponse> ExecuteAsyncFetchAsync(this WechatOpenAIClient client, Models.AsyncFetchRequest 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
|
||||
.CreateRequest(request, HttpMethod.Get, "v1", "async", "fetch")
|
||||
.SetQueryParam("task_id", request.TaskId);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.AsyncFetchResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /v1/async/fetch 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class AsyncFetchRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string TaskId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /v1/async/fetch 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class AsyncFetchResponse : WechatOpenAIResponse<AsyncFetchResponse.Types.Data>
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
/// <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 string Progress { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置任务耗时。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("cost")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("cost")]
|
||||
public string Cost { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置导出任务的下载链接。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置接口访问令牌。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("success_skill_info")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("success_skill_info")]
|
||||
public IDictionary<string, object>? SuccessSkillMap { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"cost": "22496769ms",
|
||||
"progress": "100/100",
|
||||
"state": 2,
|
||||
"url": "http://openai-75050.gzc.vod.tencent-cloud.com/40238_knowledge1588562918359.csv"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user