Add a URL source to a knowledge base
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json-patch+json'},
body: JSON.stringify({
type: 'url',
url: '<string>',
pageLimit: 123,
includePaths: ['<string>'],
excludePaths: ['<string>'],
recrawlIntervalHours: 123,
crawlerName: '<string>'
})
};
fetch('https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json-patch+json' \
--data '
{
"type": "url",
"url": "<string>",
"pageLimit": 123,
"includePaths": [
"<string>"
],
"excludePaths": [
"<string>"
],
"recrawlIntervalHours": 123,
"crawlerName": "<string>"
}
'import requests
url = "https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources"
payload = {
"type": "url",
"url": "<string>",
"pageLimit": 123,
"includePaths": ["<string>"],
"excludePaths": ["<string>"],
"recrawlIntervalHours": 123,
"crawlerName": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json-patch+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"knowledgeBaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "url",
"url": "<string>",
"scope": "section",
"pageLimit": 123,
"includePaths": [
"<string>"
],
"excludePaths": [
"<string>"
],
"pageCount": 123,
"createdAt": "2023-11-07T05:31:56Z",
"recrawlIntervalHours": 123,
"crawlerName": "<string>",
"nextRunAt": "2023-11-07T05:31:56Z",
"lastRun": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"trigger": "initial",
"counts": {
"discovered": 123,
"fetched": 123,
"unchanged": 123,
"failed": 123,
"removed": 123,
"covered": 123
},
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"error": "<string>",
"errorCode": "not_configured",
"warning": "<string>"
}
}{
"errors": {},
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>"
}Add a URL source to a knowledge base
Crawls the pages of a URL into the knowledge base and queues the first crawl at once. Each page becomes one
Markdown document that starts with "# <title>" and "Source: <url>"; its URL is stored on the document,
and its metadata holds urlSourceId. Re-crawls skip unchanged pages, update changed ones, add new ones and delete the documents of
pages that are gone; when a crawl finds fewer than half as many pages as the previous one, nothing is removed
and lastRun.warning says why. Within a knowledge base a page is held by one URL source only. robots.txt is
respected.
POST
/
api
/
v1
/
rag
/
kb
/
{kbId}
/
sources
Add a URL source to a knowledge base
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json-patch+json'},
body: JSON.stringify({
type: 'url',
url: '<string>',
pageLimit: 123,
includePaths: ['<string>'],
excludePaths: ['<string>'],
recrawlIntervalHours: 123,
crawlerName: '<string>'
})
};
fetch('https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json-patch+json' \
--data '
{
"type": "url",
"url": "<string>",
"pageLimit": 123,
"includePaths": [
"<string>"
],
"excludePaths": [
"<string>"
],
"recrawlIntervalHours": 123,
"crawlerName": "<string>"
}
'import requests
url = "https://blackbox.dasha.ai/api/v1/rag/kb/{kbId}/sources"
payload = {
"type": "url",
"url": "<string>",
"pageLimit": 123,
"includePaths": ["<string>"],
"excludePaths": ["<string>"],
"recrawlIntervalHours": 123,
"crawlerName": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json-patch+json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"knowledgeBaseId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "url",
"url": "<string>",
"scope": "section",
"pageLimit": 123,
"includePaths": [
"<string>"
],
"excludePaths": [
"<string>"
],
"pageCount": 123,
"createdAt": "2023-11-07T05:31:56Z",
"recrawlIntervalHours": 123,
"crawlerName": "<string>",
"nextRunAt": "2023-11-07T05:31:56Z",
"lastRun": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "queued",
"trigger": "initial",
"counts": {
"discovered": 123,
"fetched": 123,
"unchanged": 123,
"failed": 123,
"removed": 123,
"covered": 123
},
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z",
"error": "<string>",
"errorCode": "not_configured",
"warning": "<string>"
}
}{
"errors": {},
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>"
}Body
application/json-patch+jsonapplication/jsontext/jsonapplication/*+json
The source
Response
Created
Was this page helpful?