Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
askwatson
Advanced tools
Readme
This module is in npm as askwatson
. It provides a simple API for asking Watson a question on Bluemix using the
question_and_answer service
.
Basically you will need to get set up on Bluemix/CF and follow the instructions given
for the sample Node.js application here https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/qaapi/#commonApplication, including running the cf
commands, but
I have factored out that code a bit into two modules, so your application can
be cleaner. In case you need help finding the cf
command line program you can download it from here https://github.com/cloudfoundry/cli/releases (under Installers) and install it with dpkg -i <filename>
.
The first module is called bluemix-request-simple
and it has the parts for pulling
the host and port out of the environment and using them in a request.
The other module is this one, which is very simple to use:
watson.ask('healthcare', 'What is the most common kind of cancer', function(err, answers) {
console.log(answers);
});
This will need to run on Bluemix so a more complete example would be:
var watson = require('askwatson')
, restify = require('restify');
var server = restify.createServer();
server.get('/:domain/:question', function(req, res) {
watson.ask(req.params.domain, req.params.question, function(e, ans) {
res.send(ans);
});
});
server.listen(process.env.VCAP_APP_PORT, process.env.VCAP_APP_HOST, function() {
console.log('%s listening at %s', server.name, server.url);
});
Note that if you use GET as in this example it will be simpler to test but you can only use short questions (try curl "http://whatever.mybluemix.net/healthcare/What+is+the+most+common+kind+of+cancer"
). If you use something longer for the question it will blow up the app, so you will probably want to use POST.
FAQs
Ask IBM Watson a question on Bluemix
The npm package askwatson receives a total of 11 weekly downloads. As such, askwatson popularity was classified as not popular.
We found that askwatson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.