Skip to content
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

Discovery is not working #4

Open
AlaGarali opened this issue Jul 10, 2018 · 4 comments
Open

Discovery is not working #4

AlaGarali opened this issue Jul 10, 2018 · 4 comments

Comments

@AlaGarali
Copy link

Dear Sir @desmarchris :
I created a chatbot application according to your tutorial. Conversation service is working but Discovery service is not working knowing that I have added discovery intent and questions and in dialog i have discovery dialog node. The extensions of documents uploaded in discovery service are .json (containing title, text and url). You find here the error found.
Please help me to find the solution.

image

@AlaGarali
Copy link
Author

Dear @desmarchris :
I fixed the error data.results[0].text by data.results.text but no result shown as mentioned in this picture:

image

This figure shows that, in the discovery service, the results.text variable is not NULL or Undefined

image

Help me please ...

@desmarchris
Copy link
Owner

it may have to do with no entities being detected, can you try just using the discovery.js and delete the other two files?

@AlaGarali
Copy link
Author

@desmarchris
I deleted the other two files and this is the code in discovery.js :

function sendToDiscovery(query) {
return new Promise(function(resolve, reject) {
var DiscoveryV1 = require('watson-developer-cloud/discovery/v1');

var discovery = new DiscoveryV1({
  username: process.env.DISCOVERY_USERNAME,
  password: process.env.DISCOVERY_PASSWORD,
  version_date: '2018-03-05'
});

var environment_id = process.env.ENVIRONMENT_ID;
var collection_id = process.env.COLLECTION_ID;
var qopts = {query: query, //natural_language_query: query,
   highlight: true,
   passages_count: 1,
   passages: true,
   return_fields: ['text'],
   count:1
   aggregation:
   '[term(enriched_text.entities.text).term(enriched_text.sentiment.document.label),' +
   'term(enriched_text.categories.label).term(enriched_text.sentiment.document.label),' +
   'term(enriched_text.concepts.text).term(enriched_text.sentiment.document.label),' +
   'term(enriched_text.keywords.text).term(enriched_text.sentiment.document.label),' +
   'term(enriched_text.entities.type).term(enriched_text.sentiment.document.label)]'
}
discovery.query({
  environment_id: environment_id,
  collection_id: collection_id,
  query : qopts
}, function(error, response) {
    if (error) {
      reject(error);
    } else {
      if (response.results == null) {
        console.log("L'appel au service Discovery est terminé, mais il n'a pas retourné de réponses. Vérifier le format des données injectées dans le service Discovery.");
        reject(error);
      } else {
        console.log(response.results.text);
        resolve(response.results.text);
      }
    }
});

});
}
module.exports = sendToDiscovery;


The response.result.text returned is undefined as shown in this picture:

image

Please help me ...

@AlaGarali
Copy link
Author

AlaGarali commented Jul 12, 2018

I'm trying to build Customer Support Agent with Watson Conversation and Discovery Service and uploading FAQs documents (.docx, .pdf, .html) to Discovery service.

I would like to know, how can I have the right answer of a question asked, from documents (html, docx, pdf, ...) uploaded on discovery service ? How can I configure discovery service or discovery.query (){} to return the best answer of user's question ? Should I use another service such as WKS or not ? Please find below my discovery.js file code:

function sendToDiscovery(query) {
return new Promise(function(resolve, reject) {
var DiscoveryV1 = require('watson-developer-cloud/discovery/v1');

    var discovery = new DiscoveryV1({
      username: process.env.DISCOVERY_USERNAME,
      password: process.env.DISCOVERY_PASSWORD,
      version_date: '2018-03-05'
    });

    var environment_id = process.env.ENVIRONMENT_ID;
    var collection_id = process.env.COLLECTION_ID;
    var params = {query: query,
        //natural_language_query: query
        //filter: score>0.8,
        highlight: true,
        passages_count: 1,
        passages: true,
        return_fields: ['text'],
        count:1,
        return: 'text'
        //aggregation:
        //'[term(enriched_text.entities.text).term(enriched_text.sentiment.document.label),' +
        //'term(enriched_text.categories.label).term(enriched_text.sentiment.document.label),' +
        //'term(enriched_text.concepts.text).term(enriched_text.sentiment.document.label),' +
        //'term(enriched_text.keywords.text).term(enriched_text.sentiment.document.label),' +
        //'term(enriched_text.entities.type).term(enriched_text.sentiment.document.label)]'
    }
    discovery.query({
      environment_id: environment_id,
      collection_id: collection_id,
      configuration_id: process.env.DISCOVERY_CONFIGURATION_ID,
      query : params
    }, function(error, response) {
        if (error) {
          reject(error);
        } else {
          if (response.results == null) {
            console.log("The call to the Discovery service is complete, but he has not returned any replies. Check the format of the data injected into the Discovery service.");
            reject(error);
          } else {
            console.log(response.results[0].text);
            resolve(response.results[0].text);
          }
        }
    });
  });
}
module.exports = sendToDiscovery;

Could you help me please ?

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants