- Newest
- Most votes
- Most comments
Certainly! I can provide you with an example of using the CreateDataSource API for a web crawler in Amazon Bedrock. The method you're looking for is indeed "create_data_source" when using the Boto3 client for Bedrock Agent.
Here's a Python code example using Boto3 to create a web crawler data source for an Amazon Bedrock knowledge base:
import boto3 client = boto3.client('bedrock-agent', region_name='us-east-1') knowledge_base_id = 'your-knowledge-base-id' response = client.create_data_source( knowledgeBaseId=knowledge_base_id, name='example', description='test description', dataSourceConfiguration={ 'type': 'WEB', 'webConfiguration': { 'sourceConfiguration': { 'urlConfiguration': { 'seedUrls': [ {'url': 'https://example.com/'} ] } }, 'crawlerConfiguration': { 'crawlerLimits': { 'rateLimit': 300 }, 'inclusionFilters': [ '.*products.*' ], 'exclusionFilters': [ '.*\.pdfCertainly! I can provide you with an example of using the CreateDataSource API for a web crawler in Amazon Bedrock. The method you're looking for is indeed "create_data_source" when using the Boto3 client for Bedrock Agent. Here's a Python code example using Boto3 to create a web crawler data source for an Amazon Bedrock knowledge base: ```python import boto3 client = boto3.client('bedrock-agent', region_name='us-east-1') knowledge_base_id = 'your-knowledge-base-id' response = client.create_data_source( knowledgeBaseId=knowledge_base_id, name='example', description='test description', dataSourceConfiguration={ 'type': 'WEB', 'webConfiguration': { 'sourceConfiguration': { 'urlConfiguration': { 'seedUrls': [ {'url': 'https://example.com/'} ] } }, 'crawlerConfiguration': { 'crawlerLimits': { 'rateLimit': 300 }, 'inclusionFilters': [ '.*products.*' ], 'exclusionFilters': [ '.*\.pdf$' ], 'scope': 'HOST_ONLY' } } } )
In this example, you'll need to replace 'your-knowledge-base-id' with your actual knowledge base ID. The code sets up a web crawler with a seed URL, rate limit, and inclusion/exclusion filters. You can customize these parameters based on your specific requirements.
Make sure you have the necessary permissions set up in your IAM role to use the Bedrock Agent API. Also, ensure that you're authorized to crawl the websites you're targeting and that you're respecting their robots.txt files.
This approach using Amazon Bedrock's built-in web crawler should provide better results than manually crawling with BeautifulSoup, as it's designed specifically for creating knowledge bases and integrates well with other Amazon Bedrock features.#39; ], 'scope': 'HOST_ONLY' } } } )
In this example, you'll need to replace 'your-knowledge-base-id' with your actual knowledge base ID. The code sets up a web crawler with a seed URL, rate limit, and inclusion/exclusion filters. You can customize these parameters based on your specific requirements.
Make sure you have the necessary permissions set up in your IAM role to use the Bedrock Agent API. Also, ensure that you're authorized to crawl the websites you're targeting and that you're respecting their robots.txt files.
This approach using Amazon Bedrock's built-in web crawler should provide better results than manually crawling with BeautifulSoup, as it's designed specifically for creating knowledge bases and integrates well with other Amazon Bedrock features.
**Sources**
[Implement web crawling in Amazon Bedrock Knowledge Bases | AWS Machine Learning Blog](https://aws.amazon.com/blogs/machine-learning/implement-web-crawling-in-knowledge-bases-for-amazon-bedrock/)
answered 2 years ago
Relevant content
asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 7 months ago
