Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions sdk/cognitiveservices/Knowledge.QnAMaker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## 2.1.0-preview.2 (Unreleased)


## 3.0.0-preview.1 (2020-10-20)
SDK with support for complete V5-preview.1 API and customized Runtime client
## 2.1.0-preview.1 (2020-10-14)
SDK with custom clients for V5-preview.1 API
## 2.0.1 (2020-08-13)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker
{
public partial class QnAMakerClient
{
/// <summary>
/// Initializes a new instance of the QnAMakerClient class.
/// Initializes a new instance of the QnAMakerClient class for QnA Maker resources with hosted Runtime.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name="isPreview">
/// Optional. The flag used to change BaseUri if it is true.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public QnAMakerClient(ServiceClientCredentials credentials, bool isPreview = false, params DelegatingHandler[] handlers) : this(credentials, handlers)
{
if (isPreview)
internal QnAMakerClient(EndpointKeyServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
{
if (credentials == null)
{
BaseUri = "{Endpoint}/qnamaker/v5.0-preview.1";
throw new System.ArgumentNullException("credentials");
}

Credentials = credentials;
Credentials.InitializeServiceClient(this);
BaseUri = "{Endpoint}/qnamaker";
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Microsoft.Rest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker
{
public class QnAMakerRuntimeClient
{
public Runtime Runtime { get; set; }
private QnAMakerClient client { get; set; }

public string RuntimeEndpoint {
set
{
if (client != null)
{
client.Endpoint = value;
}
}

get
{
if (client != null && client.Endpoint != null)
{
return client.Endpoint;
}
else
{
return string.Empty;
}
}
}

/// <summary>
/// Initializes a new instance of the QnAMakerRuntimeClient class.
/// An adapter class for supporting (hosted) Runtime operations using Knowledgebase operations (generateAnswer and train) from QnAMakerClient V5.preview.1.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public QnAMakerRuntimeClient(EndpointKeyServiceClientCredentials credentials, params DelegatingHandler[] handlers)
{
this.client = new QnAMakerClient(credentials, handlers);
Runtime = new Runtime(this.client);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker
{
using Models;
using System.Threading;
using System.Threading.Tasks;

/// <summary>
/// Customized Runtime operations - using V5.0-preivew.1 Knowledgebase operations for generateAnswer and train APIs.
/// </summary>
public class Runtime
{
/// <summary>
/// Initializes a new instance of the Runtime class.
/// </summary>
/// <param name='client'>
/// Reference to the service client.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
internal Runtime(QnAMakerClient client)
{
if (client == null)
{
throw new System.ArgumentNullException("client");
}
Client = client;
}

/// <summary>
/// Gets a reference to the QnAMakerRuntimeClient
/// </summary>
private QnAMakerClient Client { get; set; }

/// <summary>
/// GenerateAnswer call to query the knowledgebase.
/// </summary>
/// <param name='kbId'>
/// Knowledgebase id.
/// </param>
/// <param name='generateAnswerPayload'>
/// Post body of the request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public async Task<QnASearchResultList> GenerateAnswerAsync(string kbId, QueryDTO generateAnswerPayload, CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.Knowledgebase.GenerateAnswerAsync(kbId, generateAnswerPayload, cancellationToken);
}

/// <summary>
/// Train call to add suggestions to the knowledgebase.
/// </summary>
/// <param name='kbId'>
/// Knowledgebase id.
/// </param>
/// <param name='trainPayload'>
/// Post body of the request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public async Task TrainAsync(string kbId, FeedbackRecordsDTO trainPayload, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.Knowledgebase.TrainAsync(kbId, trainPayload, cancellationToken);
}

}
}
Loading