我对这项技术很陌生,但我想在.NET应用程序中使用Watson的API对话。我如何在.NET中调用Watson云服务?c#/。net中的IBM Watson Conversation API客户端的示例网络
回答
我认为IBM对'简单'有相当远的理解。他们的sample apps比较隐晦。最重要的是,他们最近烧毁/弃用了他们的旧API。这里是new API description。您需要先获取一些watsone凭证。
您应该可以像使用其他RESTful API一样使用v1 Converstaions API。我喜欢Flurl这个任务。
namespace WhatsOn
{
using System;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
TalkToWatson().Wait();
}
public static async Task TalkToWatson()
{
var baseurl = "https://gateway.watsonplatform.net/conversation/api";
var workspace = "25dfa8a0-0263-471b-8980-317e68c30488";
var username = "...get your own...";
var password = "...get your own...";
var context = null as object;
var input = Console.ReadLine();
var message = new { input = new { text = input }, context };
var resp = await baseurl
.AppendPathSegments("v1", "workspaces", workspace, "message")
.SetQueryParam("version","2016-11-21")
.WithBasicAuth(username, password)
.AllowAnyHttpStatus()
.PostJsonAsync(message);
var json = await resp.Content.ReadAsStringAsync();
var answer = new
{
intents = default(object),
entities = default(object),
input = default(object),
output = new
{
text = default(string[])
},
context = default(object)
};
answer = JsonConvert.DeserializeAnonymousType(json, answer);
var output = answer?.output?.text?.Aggregate(
new StringBuilder(),
(sb,l) => sb.AppendLine(l),
sb => sb.ToString());
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine($"{resp.StatusCode}: {output}");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(json);
Console.ResetColor();
}
}
}
您可以使用REST界面调用任何Watson Cloud服务,如前面的答案所示。只要确保正确格式化JSON负载,您需要的所有信息都在Conversation API Reference中。
这就是说,有一个SDK for .NET虽然它可能仍然是不成熟的。您可以在GitHub上看到Watson Developer Cloud上的所有当前SDK和实用程序。
以及如何?:https://github.com/watson-developer-cloud/dotnet-standard-sdk#installing-the-watson-net-standard-sdk。 –
这对我来说是新的....但看起来它应该做你想做的。 –
- 1. 如何在IBM Watson Conversation的UI中命名一个节点
- 2. NodeJS api - 客户端的“net”
- 3. C#REST客户端示例?
- 4. chatbot的超时Watson Conversation Service
- 5. watson-developer-cloud/android-sdk-Conversation
- 6. Watson Conversation API何时使用哪个包?
- 7. 如何根据IBM Watson Conversation服务的速率限制检查#API呼叫
- 8. IBM Watson Alchemy API VerifyError
- 9. 从.NET客户端调用Web API(C#)
- 10. SharePoint - 客户端API - 没有NET,MFC/C++?
- 11. C++服务器/客户端网络
- 12. 任何SourceGear Vault客户端API示例?
- 13. 多网络请求&网络客户端
- 14. Asp .net中的网络客户端软件工厂
- 15. Cocoa中的并发网络客户端
- 16. Phpmyadmin Mysql网络客户端和终端客户端的差异
- 17. 客户端网络堆栈
- 18. UploadWebFile SkyDrive .Net API客户端
- 19. 客户端网络服务
- 20. Qgis网络客户端/ Openlayers
- 21. iphone网络客户端
- 22. 显示带有对话框进度和网络客户端的webview客户端
- 23. 处理多个网络客户端
- 24. 如何在用户需要Watson-Conversation时显示文件?
- 25. 新的Google DocumentsList API .NET客户端?
- 26. c#休息客户端示例
- 27. IBM Watson使用Alchemy API
- 28. Java与网络HTTP客户端性能
- 29. IBM Conversation API - 什么应该是端点URL和参数
- 30. 网络(http客户端)的boost asio库
请将其发布在西班牙网站上。本网站仅为英文版。 – Carcigenicate
Por支持preguntarlo [aqui](http://es.stackoverflow.com/)。 –
不过要说清楚,这是一个不好的问题,用英语问的问题仍然不清楚或者过分。 – Marcin