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

additional tools for visualization and knowledge graph #228

Merged
1 commit merged into from
Sep 19, 2024

Conversation

hasanp87
Copy link

Issue #, if available:

Description of changes:
2 additional tool examples

  1. Visualization with matplotlib after SQL query
  2. Query a knowledge graph in Amazon Neptune DB

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@mttanke mttanke left a comment

Choose a reason for hiding this comment

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

left some comments

"## Query Neptune Graph with SPARQL in Natural Language Using Function Calling\n",
"\n",
"This notebook will walk you through the steps to create a tool that can query Amazon Neptune database via SPARQL using function calling in Bedrock Converse API. The tool will be invoked when a user wants to get object litereal information from Amazon Neptune database for a specific object id. LLM(Large Language Model) will pass the required input parameter from the user's question the function *get_objectLiteral* and the fucntion will execute the SPARQL query to fetch the results. At the end LLM(Large Language Model) will give the final response to the user including the query results.\n",
"We will use the Human Disease Ontology as a dataset to load to Amazon Neptune https://www.ebi.ac.uk/ols4/ontologies/doid\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a pre-approved dataset? have you gotten the ticket to use the dataset?

Choose a reason for hiding this comment

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

Hi, it was opensource from this website: https://www.ebi.ac.uk/ols4/ontologies/doid. For which department should I open the ticket to get it approved?

Copy link
Author

Choose a reason for hiding this comment

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

The dataset is public available under https://creativecommons.org/publicdomain/zero/1.0/ , we can add this to README and I believe no further approvals are required @berilunay

"## Prerequisites\n",
"1.Please make sure that you complete all the prerequisites explained in this [link](https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load-data.html)\n",
"\n",
"2.In the security group of Neptune Database, allow TCP connections from the port 8182(default port of the instance) through the subnet CIDR range where the database instance resides.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

instructions to get this?

Choose a reason for hiding this comment

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

for which row 30?

"4.After the notebook is being created you can see it in the sagemaker console, under notebooks. The default IAM role of the notebook instance, by default, has list and read permissions for S3 in the policy. Edit the policy and add \"s3:PutObject\" in the actions and add your S3 bucket ARN in the Resources section of the IAM policy. In order to access Amazon Bedrock, attach *AmazonBedrockFullAccess* policy to the same role.\n",
"\n",
"After you complete all the steps you should have\n",
"* Amazon Neptune database instance (Follow [creating an new neptune DB cluster](https://docs.aws.amazon.com/neptune/latest/userguide/get-started-create-cluster.html) or create manually from the AWS Console). You need to set up the cluster within VPC!\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not possible to have those automated as a support file?

Choose a reason for hiding this comment

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

I can add a code for attaching adding those 2 policy via python if that works?

"cell_type": "markdown",
"id": "042cbf05",
"metadata": {},
"source": [
Copy link
Contributor

Choose a reason for hiding this comment

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

add the functions required to justify this

"id": "6476ae5f",
"metadata": {},
"source": [
"### After you create your S3 bucket add a folder named 'data'. You will download the Human disease ontology data into that folder in the cell below"
Copy link
Contributor

Choose a reason for hiding this comment

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

add step for creation of s3 bucket

},
{
"cell_type": "code",
"execution_count": 17,
Copy link
Contributor

Choose a reason for hiding this comment

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

clean up all cells execution

"cell_type": "code",
"execution_count": null,
"id": "6dd21f12-6f89-4735-baab-9f53204615fa",
"metadata": {},
Copy link
Contributor

Choose a reason for hiding this comment

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

add conclusions, expected outcomes and clean up steps

@@ -0,0 +1,76 @@
import boto3

bucket = 'bucketname' ### REPLACE WITH YOUR AMAZON S3 BUCKET
Copy link
Contributor

Choose a reason for hiding this comment

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

create bucket automatically and get this name from the resource created

bucket = 'bucketname' ### REPLACE WITH YOUR AMAZON S3 BUCKET

### Setup boto3 client for Athena
athena = boto3.client('athena', region_name='us-east-1')
Copy link
Contributor

Choose a reason for hiding this comment

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

make region a variable


### Insert synthetic example data
transactions_data = [
(1, 'Tom Hanks', '2023-01-01', 500.00),
Copy link
Contributor

Choose a reason for hiding this comment

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

is this data generated? do we have permissions to use it?

Choose a reason for hiding this comment

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

@rodzanto rodzanto closed this pull request by merging all changes into aws-samples:main in 3e0a2a7 Sep 19, 2024
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.

4 participants