-
Notifications
You must be signed in to change notification settings - Fork 5.1k
QnA Maker SDK 3.0.0-preview.1 #16086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexGhiondea
merged 11 commits into
Azure:master
from
sahithikkss-zz:sahithikkss/QnAmakerSDKPreview3
Oct 20, 2020
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8230c04
SDK for V5.0-preview.1
sahithikkss ed9a8aa
change version to 3.0.0-preview.1
sahithikkss d2e6191
Avoid boolean parameter, endpointsettings test
sahithikkss 54d67ec
session record updated
sahithikkss ab70cf0
testcase file and name corrected, PR comments addressed, made custom …
sahithikkss e0b29ad
comment updated, csproj version to check appcompat errors
sahithikkss f4b36d8
Remove AppCompatVersion as this would be major version upgrade
sahithikkss 0523e53
Dispose method removed.
sahithikkss a127d8c
## 3.0.0-preview.1 (2020-10-20)
sahithikkss 9d08882
Address PR comments and Simplify tests, skip one until service fix
sahithikkss 050eaa4
Addressed PR review comments
sahithikkss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
28 changes: 10 additions & 18 deletions
28
...c/Customizations/QnAMakerPreviewClient.cs → ...aker/src/Customizations/QnAMakerClient.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -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) | ||
sahithikkss-zz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| BaseUri = "{Endpoint}/qnamaker/v5.0-preview.1"; | ||
| throw new System.ArgumentNullException("credentials"); | ||
| } | ||
|
|
||
| Credentials = credentials; | ||
| Credentials.InitializeServiceClient(this); | ||
| BaseUri = "{Endpoint}/qnamaker"; | ||
| } | ||
| } | ||
| } | ||
39 changes: 0 additions & 39 deletions
39
sdk/cognitiveservices/Knowledge.QnAMaker/src/Customizations/QnAMakerPreviewRuntimeClient.cs
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
sdk/cognitiveservices/Knowledge.QnAMaker/src/Customizations/QnAMakerRuntimeClient.cs
This file contains hidden or 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,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); | ||
| } | ||
| } | ||
| } |
70 changes: 70 additions & 0 deletions
70
sdk/cognitiveservices/Knowledge.QnAMaker/src/Customizations/Runtime.cs
This file contains hidden or 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,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); | ||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.