Merge pull request #4 from Microsoft/host-split
Allow host base URI as an argument to ctor
This commit is contained in:
Коммит
c111aaa55e
|
@ -11,11 +11,11 @@
|
|||
<iconUrl>https://www.luis.ai/Content/images/luis_darker_logo.png</iconUrl>
|
||||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>$description$</description>
|
||||
<releaseNotes>Initial release.</releaseNotes>
|
||||
<copyright>Copyright (c) 2015</copyright>
|
||||
<releaseNotes>User-configurable hostname.</releaseNotes>
|
||||
<copyright>Copyright (c) 2016</copyright>
|
||||
<tags>Microsoft Cognitive Services LUIS</tags>
|
||||
<dependencies>
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
</package>
|
||||
</package>
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace Microsoft.Cognitive.LUIS
|
|||
/// </summary>
|
||||
public class LuisClient : IDisposable
|
||||
{
|
||||
private const string DEFAULT_BASE_URI = "https://api.projectoxford.ai/luis/v1/application";
|
||||
|
||||
/// <summary>
|
||||
/// flag to indidicate whether to return full result of all intents not just the top scoring intent (for preview features only)
|
||||
/// </summary>
|
||||
|
@ -90,20 +92,31 @@ namespace Microsoft.Cognitive.LUIS
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
|
||||
/// Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="appId">The application ID of the LUIS application</param>
|
||||
/// <param name="appKey">The application subscription key of the LUIS application</param>
|
||||
/// <param name="preview">A flag indicating whether to use preview features or not (Dialogue)</param>
|
||||
/// top scoring in case of using the dialogue</param>
|
||||
public LuisClient(string appId, string appKey, bool preview = false)
|
||||
public LuisClient(string appId, string appKey, bool preview = false) : this(appId, appKey, DEFAULT_BASE_URI, preview) { }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new Luis client with a shared <see cref="HttpClient"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="appId">The application ID of the LUIS application</param>
|
||||
/// <param name="appKey">The application subscription key of the LUIS application</param>
|
||||
/// <param name="baseApiUrl">Root URI for the service endpoint.</param>
|
||||
/// <param name="preview">A flag indicating whether to use preview features or not (Dialogue)</param>
|
||||
/// top scoring in case of using the dialogue</param>
|
||||
public LuisClient(string appId, string appKey, string baseApiUrl, bool preview = false)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(appId)) throw new ArgumentException(nameof(appId));
|
||||
if (String.IsNullOrWhiteSpace(appKey)) throw new ArgumentException(nameof(appKey));
|
||||
if (String.IsNullOrWhiteSpace(baseApiUrl)) throw new ArgumentException(nameof(baseApiUrl));
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.DefaultRequestHeaders.Add("OCP-APIM-Subscription-Key", appKey);
|
||||
BASE_API_URL = "https://api.projectoxford.ai/luis/v1/application";
|
||||
BASE_API_URL = baseApiUrl;
|
||||
|
||||
Preview = preview;
|
||||
_appId = appId;
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
|||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Microsoft.Cognitive.LUIS")]
|
||||
[assembly: AssemblyDescription("Microsoft.Cognitive.LUIS")]
|
||||
[assembly: AssemblyDescription("Microsoft Cognitive Services LUIS Client Library")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Microsoft Cognitive Services")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016 Microsoft")]
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace Microsoft.Cognitive.LUIS
|
|||
var values = (JArray)compositeEntity["children"] ?? new JArray();
|
||||
CompositeEntityChildren = ParseValuesArray(values);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
CompositeEntityChildren = null;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Microsoft.Cognitive.LUIS
|
|||
{
|
||||
Score = (double)entity["score"];
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
Score = -1;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Microsoft.Cognitive.LUIS
|
|||
var values = (JArray)parameter["value"] ?? new JArray();
|
||||
ParameterValues = ParseValuesArray(values);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
ParameterValues = null;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче