IBM / watson-discovery-sdu-with-assistant

Build a Node.js chatbot that uses Watson services and webhooks to query an owner's manual
https://developer.ibm.com/learningpaths/get-started-watson-discovery/smart-document-understanding-search-skill/
Apache License 2.0
21 stars 35 forks source link

How can I filter my result in Watson Asssitant #29

Closed SAKET03 closed 4 years ago

SAKET03 commented 4 years ago

Sir, I followed the steps at last the part the response is very clutterd which is given by the Watson Assistant. How can I filter only the content I require. Also, I wanted to ask how to deploy the assistant as the part shown in the code is difficult to Understand.

rhagarty commented 4 years ago

Hello @SAKET03. I would like to help, but I need more details about the specific issue(s) you are running into.

SAKET03 commented 4 years ago

Thank you Sir for your reply,

1) For the first issue this the example: {"matching_results":250,"passages":[{"document_id":"a90d4c485e4966310a7673d1eef221b7_249","end_offset":79007,"field":"answer","passage_score":12.362444307374497,"passage_text":"SEVEN Depending on what platform(s) you are aiming at, there are several. Some of them haven’t been ported to Python 3 yet. At least Tkinter and Qt are known to be Python 3-compatible.","start_offset":78823}],"results":[{"answer":["Here’s a very brief summary of what started it all, written by Guido van Rossum: I had extensive experience with implementing an interpreted language in the ABC group at CWI, and from working with this group I had learned a lot about language design. This is the origin of many Python features, including the use of indentation for statement grouping and the inclusion of very-high-level data types (although the details are all different in Python)."],"extracted_metadata":{"author":["Guido van Rossum"," and the Python development team"],"file_type":"pdf","filename":"faq.pdf","sha1":"368eb895e40c61b7d69307fb158777c10b68f4fb","title":"Python Frequently Asked Questions"},"id":"a90d4c485e4966310a7673d1eef221b7_8","result_metadata":{"confidence":0.16554087774569667,"score":3.4048783000000005},"segment_metadata":{"id":"aef6fea5-f262-4e23-8ce8-05fdf53f0789","parent_id":"a90d4c485e4966310a7673d1eef221b7","total_segments":250}}],"retrieval_details":{"document_retrieval_strategy":"untrained"},"session_token":"1_OnekGUMJ5862hr03_MsHJNNZgJ"} This the response I am reciving from the Assistant. How can I just extract the field "answer" which is highlited

2) I want to understand how to deploy the final model with the UI that is shown in the video Annotation 2020-05-12 175446 and this picture

VKaddala commented 4 years ago

how to extract only answer from discovery result.

rhagarty commented 4 years ago

@SAKET03

let's do #2 first - for deploying, you just need to create your .env which points to your Assistant instance. Are you getting any console errors when you run 'npm start'? Or are you seeing any errors in the browser?

as for #1, your results do not include "webhook_result_1", which means that Discovery was not invoked to generate this response.

Did you use your own data file as input to Discovery? Are you seeing good results in the Assistant UI when first integrating with Discovery? (step 5 in README)

Regardless, you have return data that you can process. You will need to change "/src/main.js". Look at the function sendMessage() - this is where the returned data from Assistant is processed. If you look there you will see that I look for the data in a specific format, which does not match what you are showing above. I would un-comment out the lines 87-89 to print out the results, and then modify the code to handle it.

SAKET03 commented 4 years ago

Thank you sir for your reply, 1) Sir, the problem is I dont know how to deploy the assistant. I have been using node-red to integrate assistant and to deploy it. The UI which you have shown is far more impressive. Can you write steps to achive the final output from the last step in the video. Sir, I have achived till here Annotation 2020-05-14 164956 and it is replying the same as above. If you can give the steps it would be a great help.

rhagarty commented 4 years ago

@SAKET03 the deployment steps are all covered in the README of this github repo.

Step 6 is adding the Assistant credentials and skill ID to your .env file.

Step 7 is running 'npm install' and 'npm start' to run the server, which listens on port 3000.

Have you created a .env file?

SAKET03 commented 4 years ago

Sir, I have obtained the .env file but I didnt understand the nmp install and npm start as when I write them in my command prompt it shows is dosent exsist. Also, how would this step create the UI of the Assistant

rhagarty commented 4 years ago

@SAKET03 the UI running is a node app, so you need to install npm and node. Once installed, you run npm install to pull down all of the dependencies, and then run npm start to run the node app, which starts the server. And yes, the app contains the UI that talks to the Assistant.

To recap: 1) clone this github repo to your local machine 2) cd to the root directory 3) install npm and node 4) create and set your .env file 5) run npm install 6) run npm start 7) point browser at localhost:3000

SAKET03 commented 4 years ago

Thank you Sir, You have helped me alot, my project was completed successfully.