mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 02:29:40 +08:00
feat(openai): 新增 v2 版机器人对话相关接口
This commit is contained in:
@@ -73,5 +73,27 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI
|
|||||||
|
|
||||||
return await client.SendFlurlRequestAsJsonAsync<Models.BotEffectiveProgressV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
return await client.SendFlurlRequestAsJsonAsync<Models.BotEffectiveProgressV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>异步调用 [POST] /v2/bot/query 接口。</para>
|
||||||
|
/// <para>
|
||||||
|
/// REF: <br/>
|
||||||
|
/// <![CDATA[ https://developers.weixin.qq.com/doc/aispeech/confapi/dialog/bot/query.html ]]>
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<Models.BotQueryV2Response> ExecuteBotQueryV2Async(this WechatOpenAIClient client, Models.BotQueryV2Request 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", "query");
|
||||||
|
|
||||||
|
return await client.SendFlurlRequestAsJsonAsync<Models.BotQueryV2Response>(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ using Flurl.Http;
|
|||||||
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
||||||
{
|
{
|
||||||
using SKIT.FlurlHttpClient.Internal;
|
using SKIT.FlurlHttpClient.Internal;
|
||||||
|
using SKIT.FlurlHttpClient.Primitives;
|
||||||
|
|
||||||
internal class WechatOpenAIRequestEncryptionInterceptor : HttpInterceptor
|
internal class WechatOpenAIRequestEncryptionInterceptor : HttpInterceptor
|
||||||
{
|
{
|
||||||
@@ -90,19 +91,19 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
|||||||
if (context.FlurlCall.HttpResponseMessage.StatusCode != HttpStatusCode.OK)
|
if (context.FlurlCall.HttpResponseMessage.StatusCode != HttpStatusCode.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte[] respBytes = Array.Empty<byte>();
|
string respBody = string.Empty;
|
||||||
if (context.FlurlCall.HttpResponseMessage.Content is not null)
|
if (context.FlurlCall.HttpResponseMessage.Content is not null)
|
||||||
{
|
{
|
||||||
HttpContent httpContent = context.FlurlCall.HttpResponseMessage.Content;
|
HttpContent httpContent = context.FlurlCall.HttpResponseMessage.Content;
|
||||||
respBytes = await
|
respBody = await
|
||||||
#if NET5_0_OR_GREATER
|
#if NET5_0_OR_GREATER
|
||||||
httpContent.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);
|
httpContent.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||||
#else
|
#else
|
||||||
_AsyncEx.RunTaskWithCancellationTokenAsync(httpContent.ReadAsByteArrayAsync(), cancellationToken).ConfigureAwait(false);
|
_AsyncEx.RunTaskWithCancellationTokenAsync(httpContent.ReadAsStringAsync(), cancellationToken).ConfigureAwait(false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] respBytesDecrypted;
|
string respBodyDecrypted;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const int AES_BLOCK_SIZE = 16;
|
const int AES_BLOCK_SIZE = 16;
|
||||||
@@ -110,10 +111,10 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
|||||||
byte[] ivBytes = new byte[AES_BLOCK_SIZE]; // iv 是 key 的前 16 个字节
|
byte[] ivBytes = new byte[AES_BLOCK_SIZE]; // iv 是 key 的前 16 个字节
|
||||||
Buffer.BlockCopy(keyBytes, 0, ivBytes, 0, ivBytes.Length);
|
Buffer.BlockCopy(keyBytes, 0, ivBytes, 0, ivBytes.Length);
|
||||||
|
|
||||||
respBytesDecrypted = Utilities.AESUtility.DecryptWithCBC(
|
respBodyDecrypted = Utilities.AESUtility.DecryptWithCBC(
|
||||||
keyBytes: keyBytes,
|
encodingKey: EncodedString.ToBase64String(keyBytes),
|
||||||
ivBytes: ivBytes,
|
encodingIV: EncodedString.ToBase64String(ivBytes),
|
||||||
cipherBytes: respBytes
|
encodingCipher: new EncodedString(respBody, EncodingKinds.Base64)
|
||||||
)!;
|
)!;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -122,7 +123,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.FlurlCall.HttpResponseMessage!.Content?.Dispose();
|
context.FlurlCall.HttpResponseMessage!.Content?.Dispose();
|
||||||
context.FlurlCall.HttpResponseMessage!.Content = new ByteArrayContent(respBytesDecrypted);
|
context.FlurlCall.HttpResponseMessage!.Content = new StringContent(respBodyDecrypted);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRequestUrlPath(Uri uri)
|
private string GetRequestUrlPath(Uri uri)
|
||||||
@@ -144,7 +145,7 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Interceptors
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,101 +33,6 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
|||||||
public bool IsLatestValid { get; set; }
|
public bool IsLatestValid { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Message
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置技能 ID。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("ans_node_id")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("ans_node_id")]
|
|
||||||
[System.Text.Json.Serialization.JsonNumberHandling(System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString)]
|
|
||||||
public int AnswerNodeId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置技能名称。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("ans_node_name")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("ans_node_name")]
|
|
||||||
public string AnswerNodeName { get; set; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置置信度。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("confidence")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("confidence")]
|
|
||||||
public decimal Confidence { get; set; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置消息类型。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("msg_type")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("msg_type")]
|
|
||||||
public string MessageType { get; set; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置消息内容。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("content")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("content")]
|
|
||||||
public string Content { get; set; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置消息状态。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("status")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("status")]
|
|
||||||
public string Status { get; set; } = default!;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置是否是列表选择。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("list_options")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("list_options")]
|
|
||||||
public bool IsListOptions { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置是否仅选择。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("take_options_only")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("take_options_only")]
|
|
||||||
public bool IsTakeOptionsOnly { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置当前事件。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("event")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("event")]
|
|
||||||
public string? Event { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置调试信息。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("debug_info")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("debug_info")]
|
|
||||||
public string? DebugInfo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置窗口标题。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("resp_title")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("resp_title")]
|
|
||||||
public string? ResponseTitle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置场景状态。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("scene_status")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("scene_status")]
|
|
||||||
public string? SceneStatus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置会话 ID。
|
|
||||||
/// </summary>
|
|
||||||
[Newtonsoft.Json.JsonProperty("session_id")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("session_id")]
|
|
||||||
public string? SessionId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Option
|
public class Option
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -208,14 +113,14 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Newtonsoft.Json.JsonProperty("norm")]
|
[Newtonsoft.Json.JsonProperty("norm")]
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("norm")]
|
[System.Text.Json.Serialization.JsonPropertyName("norm")]
|
||||||
public string? Norm { get; set; }
|
public string? NormalizedValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置归一化的值详细信息。
|
/// 获取或设置归一化的值详细信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Newtonsoft.Json.JsonProperty("norm_detail")]
|
[Newtonsoft.Json.JsonProperty("norm_detail")]
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("norm_detail")]
|
[System.Text.Json.Serialization.JsonPropertyName("norm_detail")]
|
||||||
public string? NormDetail { get; set; }
|
public string? NormalizedValueDetail { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置回复的意图名称。
|
/// 获取或设置回复的意图名称。
|
||||||
@@ -311,14 +216,6 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
|||||||
[System.Text.Json.Serialization.JsonPropertyName("msgtype")]
|
[System.Text.Json.Serialization.JsonPropertyName("msgtype")]
|
||||||
public string MessageType { get; set; } = default!;
|
public string MessageType { get; set; } = default!;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取或设置回答详细信息。
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("相关接口或字段于 2022-04-15 下线。")]
|
|
||||||
[Newtonsoft.Json.JsonProperty("msg")]
|
|
||||||
[System.Text.Json.Serialization.JsonPropertyName("msg")]
|
|
||||||
public Types.Message[]? MessageList { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置机器人回复的状态。
|
/// 获取或设置机器人回复的状态。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@@ -0,0 +1,60 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /v2/bot/query 接口的请求。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class BotQueryV2Request : WechatOpenAIRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置查询语句。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("query")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("query")]
|
||||||
|
public string QueryString { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置查询环境。
|
||||||
|
/// <para>默认值:"online"</para>
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("env")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("env")]
|
||||||
|
public string Environment { get; set; } = "online";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置第一优先级的限定技能命中范围列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("first_priority_skills")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("first_priority_skills")]
|
||||||
|
public IList<string>? FirstPrioritySkillList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置第二优先级的限定技能命中范围列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("second_priority_skills")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("second_priority_skills")]
|
||||||
|
public IList<string>? SecondPrioritySkillList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置用户标识。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("userid")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("userid")]
|
||||||
|
public string? UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置用户昵称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("user_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("user_name")]
|
||||||
|
public string? UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置用户头像 URL。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("avatar")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("avatar")]
|
||||||
|
public string? AvatarUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,128 @@
|
|||||||
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.Models
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>表示 [POST] /v2/bot/query 接口的响应。</para>
|
||||||
|
/// </summary>
|
||||||
|
public class BotQueryV2Response : WechatOpenAIResponse<BotQueryV2Response.Types.Data>
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class Data : WechatOpenAIResponseData
|
||||||
|
{
|
||||||
|
public static class Types
|
||||||
|
{
|
||||||
|
public class Option
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置推荐分类。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("ans_node_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("ans_node_name")]
|
||||||
|
public string AnswerNodeName { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置推荐标准问题。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("title")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("title")]
|
||||||
|
public string Title { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置推荐回答。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("answer")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("answer")]
|
||||||
|
public string Answer { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置推荐信息指数。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("confidence")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("confidence")]
|
||||||
|
public decimal Confidence { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Slot
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置槽位名称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置槽位值。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("value")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("value")]
|
||||||
|
public string Value { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置归一化的值。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("norm")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("norm")]
|
||||||
|
public string? NormalizedValue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置回答的类型。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("answer_type")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("answer_type")]
|
||||||
|
public string AnswerType { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置命中的回答。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("answer")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("answer")]
|
||||||
|
public string Answer { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置机器人回复状态。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("status")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("status")]
|
||||||
|
public string Status { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置消息 ID。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("msg_id")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("msg_id")]
|
||||||
|
public string MessageId { get; set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置技能名称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("skill_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("skill_name")]
|
||||||
|
public string? SkillName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置意图名称。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("intent_name")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("intent_name")]
|
||||||
|
public string? IntentName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置推荐问题列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("options")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("options")]
|
||||||
|
public Types.Option[]? OptionList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置槽位数据列表。
|
||||||
|
/// </summary>
|
||||||
|
[Newtonsoft.Json.JsonProperty("slots")]
|
||||||
|
[System.Text.Json.Serialization.JsonPropertyName("slots")]
|
||||||
|
public Types.Slot[]? SlotList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -12,23 +12,6 @@
|
|||||||
"intent_confirm_status": "",
|
"intent_confirm_status": "",
|
||||||
"is_default_answer": false,
|
"is_default_answer": false,
|
||||||
"list_options": false,
|
"list_options": false,
|
||||||
"msg": [
|
|
||||||
{
|
|
||||||
"ans_node_id": 17130001,
|
|
||||||
"ans_node_name": "猜拳",
|
|
||||||
"confidence": 1,
|
|
||||||
"content": "2",
|
|
||||||
"debug_info": "",
|
|
||||||
"event": "",
|
|
||||||
"list_options": false,
|
|
||||||
"msg_type": "text",
|
|
||||||
"resp_title": "开始猜拳",
|
|
||||||
"scene_status": "",
|
|
||||||
"session_id": "",
|
|
||||||
"status": "FAQ",
|
|
||||||
"take_options_only": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"msg_id": "31904d53",
|
"msg_id": "31904d53",
|
||||||
"ret": 0,
|
"ret": 0,
|
||||||
"scene_status": "",
|
"scene_status": "",
|
||||||
|
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"query": "我叫我妈妈的姐姐叫什么?",
|
||||||
|
"env": "online",
|
||||||
|
"first_priority_skills": [],
|
||||||
|
"second_priority_skills": [],
|
||||||
|
"user_name": "测试用户名",
|
||||||
|
"avatar": "https://example.com/img/avatar.png",
|
||||||
|
"userid": "123"
|
||||||
|
}
|
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"data": {
|
||||||
|
"answer": "姨妈",
|
||||||
|
"answer_type": "text",
|
||||||
|
"intent_name": "亲戚关系问询",
|
||||||
|
"msg_id": "212140c2-b358-4d72-8049-cd4f9053fcc7",
|
||||||
|
"options": null,
|
||||||
|
"skill_name": "亲戚关系",
|
||||||
|
"slots": [
|
||||||
|
{
|
||||||
|
"name": "亲戚称呼1",
|
||||||
|
"norm": "妈妈",
|
||||||
|
"value": "妈妈"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "亲戚称呼2",
|
||||||
|
"norm": "姐姐",
|
||||||
|
"value": "姐姐"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"status": "GENERAL_FAQ"
|
||||||
|
},
|
||||||
|
"msg": "success",
|
||||||
|
"request_id": "212140c2-b358-4d72-8049-cd4f9053fcc7"
|
||||||
|
}
|
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
||||||
|
{
|
||||||
|
public class TestCase_ApiExecuteBotTests
|
||||||
|
{
|
||||||
|
[Fact(DisplayName = "测试用例:调用 API [POST] /v2/bot/query")]
|
||||||
|
public async Task TestExecuteTokenV2()
|
||||||
|
{
|
||||||
|
var request = new Models.BotQueryV2Request()
|
||||||
|
{
|
||||||
|
QueryString = "我叫我妈妈的姐姐叫什么?",
|
||||||
|
Environment = "debug",
|
||||||
|
UserId = "TEST_USERID",
|
||||||
|
UserName = "TEST_USERNAME",
|
||||||
|
AccessToken = TestConfigs.WechatAccessToken
|
||||||
|
};
|
||||||
|
var response = await TestClients.OpenAIInstance.ExecuteBotQueryV2Async(request);
|
||||||
|
|
||||||
|
Assert.NotNull(response.Data);
|
||||||
|
Assert.NotNull(response.Data.MessageId);
|
||||||
|
Assert.NotNull(response.Data.AnswerType);
|
||||||
|
Assert.NotNull(response.Data.Answer);
|
||||||
|
Assert.NotNull(response.Data.Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -11,7 +11,8 @@ namespace SKIT.FlurlHttpClient.Wechat.OpenAI.UnitTests
|
|||||||
var request = new Models.TokenV2Request() { AccountId = TestConfigs.WechatAccountId };
|
var request = new Models.TokenV2Request() { AccountId = TestConfigs.WechatAccountId };
|
||||||
var response = await TestClients.OpenAIInstance.ExecuteTokenV2Async(request);
|
var response = await TestClients.OpenAIInstance.ExecuteTokenV2Async(request);
|
||||||
|
|
||||||
Assert.NotNull(response.Data?.AccessToken);
|
Assert.NotNull(response.Data);
|
||||||
|
Assert.NotNull(response.Data.AccessToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user