mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 14:04:32 +08:00
feat(openai): 新增数据统计相关接口
This commit is contained in:
parent
ec10df05e6
commit
d2ee3c6d92
@ -0,0 +1,52 @@
|
||||
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 WechatOpenAIClientExecuteStatisticsExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/dialog_user_specified_date 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/statistic/dialog_user_specified_date.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.DialogUserSpecifiedDateResponse> ExecuteDialogUserSpecifiedDateAsync(this WechatOpenAIClient client, Models.DialogUserSpecifiedDateRequest 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.Post, "v2", "dialog_user_specified_date");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.DialogUserSpecifiedDateResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /v2/user_query_yesterday_data 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/aispeech/openapi/api/v2/statistic/user_query_yesterday_data.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.UserQueryYesterdayDataResponse> ExecuteUserQueryYesterdayDataAsync(this WechatOpenAIClient client, Models.UserQueryYesterdayDataRequest 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.Post, "v2", "user_query_yesterday_data");
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.UserQueryYesterdayDataResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/dialog_user_specified_date 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class DialogUserSpecifiedDateRequest : WechatOpenAIRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置起始日期字符串(格式:yyyy-MM-dd)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("start_date")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("start_date")]
|
||||
public string StartDateString { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结束日期字符串(格式:yyyy-MM-dd)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("end_date")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("end_date")]
|
||||
public string EndDateString { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/dialog_user_specified_date 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class DialogUserSpecifiedDateResponse : WechatOpenAIResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置日期字符串(格式:yyyy-MM-dd)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("date")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("date")]
|
||||
public string DateString { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置数量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("count")]
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置对话数据列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("q_a_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("q_a_count")]
|
||||
public Types.Data[] DialogDataList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户数据列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_count")]
|
||||
public Types.Data[] UserDataList { get; set; } = default!;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/user_query_yesterday_data 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class UserQueryYesterdayDataRequest : WechatOpenAIRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /v2/user_query_yesterday_data 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class UserQueryYesterdayDataResponse : WechatOpenAIResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置对话数量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("q_a_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("q_a_count")]
|
||||
public int DialogCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户数量。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_count")]
|
||||
public int UserCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置新消息总数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("new_news_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("new_news_count")]
|
||||
public int NewMessageCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置新消息人数。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("new_news_user_count")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("new_news_user_count")]
|
||||
public int NewMessageUserCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置热问列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("hot_query_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("hot_query_list")]
|
||||
public string[] HotQueryList { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置命中率(范围:0~1)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("hit_rate")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("hit_rate")]
|
||||
public double HitRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置错误率(范围:0~1)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("miss_rate")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("miss_rate")]
|
||||
public double MissRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户增长率(范围:0~1)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_growth_rate")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_growth_rate")]
|
||||
public double UserGrowthRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置命中增长率(范围:0~1)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("hit_growth_rate")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("hit_growth_rate")]
|
||||
public double HitGrowthRate { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"start_date": "2021-08-11",
|
||||
"end_date": "2021-08-18"
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "请求成功",
|
||||
"request_id": "255i0ug8-l9q4-3801-44ft-w7csjn9e5142",
|
||||
"q_a_count": [
|
||||
{
|
||||
"date": "2021-08-11",
|
||||
"count": 911
|
||||
},
|
||||
{
|
||||
"date": "2021-08-12",
|
||||
"count": 1316
|
||||
}
|
||||
],
|
||||
"user_count": [
|
||||
{
|
||||
"date": "2021-08-11",
|
||||
"count": 267
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "请求成功",
|
||||
"request_id": "255i0ug8-l9q4-3801-44ft-w7csjn9e5140",
|
||||
"hit_rate": 0.94,
|
||||
"q_a_count": 985,
|
||||
"user_count": 280,
|
||||
"hot_query_list": [ "我想看新闻", "好听的歌", "我想知道今天天气" ],
|
||||
"miss_rate": 0.06000000000000005,
|
||||
"new_news_count": 2021,
|
||||
"new_news_user_count": 605,
|
||||
"user_growth_rate": 0.16,
|
||||
"hit_growth_rate": 0.02
|
||||
}
|
Loading…
Reference in New Issue
Block a user