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

new Dialogflow scenario for explainability #16

Merged
merged 9 commits into from
Aug 27, 2023
Merged

new Dialogflow scenario for explainability #16

merged 9 commits into from
Aug 27, 2023

Conversation

muskan-k
Copy link
Collaborator

@muskan-k muskan-k commented Jul 31, 2023

COMPLETED
new intent to get explanation of previous answer
request jsons for existing and new intents

#14

Copy link
Member

@anbo-de anbo-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it looks nice. Please consider the review comments to improve the maintainability of your code.

def getComponents():
global qanaryComponents
global qanaryComponentNames
response = urllib.request.urlopen('http://demos.swe.htwk-leipzig.de:40111/components').read().decode()
response = urllib.request.urlopen(
'http://pie.qanary.net:8000/components').read().decode()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace the hard-coded URL by a constant initialized at the beginning of the Python file.

There should be something like:

from decouple import config # required: pip install python-decouple 
QANARY_COMPONENTS_ENDPOINT = config('QANARY_COMPONENTS_ENDPOINT')

Then create a file .env for your local environment containing:

QANARY_COMPONENTS_ENDPOINT="http://demos.swe.htwk-leipzig.de:40111/components"

see https://simpleisbetterthancomplex.com/2015/11/26/package-of-the-week-python-decouple.html

Copy link
Collaborator Author

@muskan-k muskan-k Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anbo-de what you are reviewing is an outdated file. If you could please notice the "outdated" label on the file you've left your reviews on. These are old changes. As part of the fix for issue - #17, a .env file was created and all the URLs were added there and the changes were made in all the other files where the constant were imported from .env files. If you could please see the Files tab in this PR, you will be able to find the latest updated file and you will not find direct URLs that you have just reviewed and commented to. Please let me know if you can find it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultComponents = ["NED-DBpediaSpotlight", "SparqlExecuter",
"OpenTapiocaNED", "BirthDataQueryBuilder", "WikidataQueryExecuter"]
profileComponents = []
vizURL = "https://dbpedia-rdf-viz.herokuapp.com/visualize/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please externalize value as described for components.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return result['results']['bindings'][0]['answer']['value']


def getAnswerFromQanary(graphId):
endpointUrl = 'http://demos.swe.htwk-leipzig.de:40111/sparql'
endpointUrl = 'http://pie.qanary.net:8000/sparql'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please externalize value as described for components.py.

return result['results']['bindings'][0]['answer']['value']


def getAnswerFromQanary(graphId):
endpointUrl = 'http://demos.swe.htwk-leipzig.de:40111/sparql'
endpointUrl = 'http://pie.qanary.net:8000/sparql'
output = "No answer available."
query = """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: better to use format() for inserting the graphId into the query.

params = {
"question": lastKbquestion[sessionId],
"componentlist[]": show
}
response = requests.post(
'http://demos.swe.htwk-leipzig.de:40111/startquestionansweringwithtextquestion', params)
'http://pie.qanary.net:8000/startquestionansweringwithtextquestion', params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please externalize value as described for components.py.

# lastGraphIdOfSession = None
explanation = "Sorry, there was no previously asked question in this session."
# if lastGraphIdOfSession is not None:
endpointUrl = 'http://pie.qanary.net:8000/sparql'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please externalize value as described for components.py.

@muskan-k muskan-k merged commit e2065e9 into main Aug 27, 2023
2 checks passed
@muskan-k muskan-k deleted the feature/14 branch August 27, 2023 15:02
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

Successfully merging this pull request may close these issues.

2 participants