Split HTML Content into Chunks
curl --request POST \
--url https://api.trieve.ai/api/chunk/split \
--header 'Content-Type: application/json' \
--data '
{
"body_remove_strings": [
"Warning:",
"Note:"
],
"chunk_html": "",
"heading_remove_strings": [
"###",
"##",
"#"
]
}
'import requests
url = "https://api.trieve.ai/api/chunk/split"
payload = {
"body_remove_strings": ["Warning:", "Note:"],
"chunk_html": "",
"heading_remove_strings": ["###", "##", "#"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
body_remove_strings: ['Warning:', 'Note:'],
chunk_html: '',
heading_remove_strings: ['###', '##', '#']
})
};
fetch('https://api.trieve.ai/api/chunk/split', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trieve.ai/api/chunk/split",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'body_remove_strings' => [
'Warning:',
'Note:'
],
'chunk_html' => '',
'heading_remove_strings' => [
'###',
'##',
'#'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trieve.ai/api/chunk/split"
payload := strings.NewReader("{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trieve.ai/api/chunk/split")
.header("Content-Type", "application/json")
.body("{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trieve.ai/api/chunk/split")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"chunks": [
{
"body": "This is the body of the content",
"headings": [
"Title Heading",
"Sub Heading 1",
"Sub Sub Heading 1"
]
},
{
"body": "This is the body of the content",
"headings": [
"Title Heading",
"Sub Heading 1",
"Sub Sub Heading 2"
]
}
]
}{
"message": "Bad Request"
}Chunk
Split HTML Content into Chunks
This endpoint receives a single html string and splits it into chunks based on the headings and body content. The headings are split based on heading html tags. chunk_html has a maximum size of 256Kb.
POST
/
api
/
chunk
/
split
Split HTML Content into Chunks
curl --request POST \
--url https://api.trieve.ai/api/chunk/split \
--header 'Content-Type: application/json' \
--data '
{
"body_remove_strings": [
"Warning:",
"Note:"
],
"chunk_html": "",
"heading_remove_strings": [
"###",
"##",
"#"
]
}
'import requests
url = "https://api.trieve.ai/api/chunk/split"
payload = {
"body_remove_strings": ["Warning:", "Note:"],
"chunk_html": "",
"heading_remove_strings": ["###", "##", "#"]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
body_remove_strings: ['Warning:', 'Note:'],
chunk_html: '',
heading_remove_strings: ['###', '##', '#']
})
};
fetch('https://api.trieve.ai/api/chunk/split', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trieve.ai/api/chunk/split",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'body_remove_strings' => [
'Warning:',
'Note:'
],
'chunk_html' => '',
'heading_remove_strings' => [
'###',
'##',
'#'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trieve.ai/api/chunk/split"
payload := strings.NewReader("{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trieve.ai/api/chunk/split")
.header("Content-Type", "application/json")
.body("{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trieve.ai/api/chunk/split")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"body_remove_strings\": [\n \"Warning:\",\n \"Note:\"\n ],\n \"chunk_html\": \"\",\n \"heading_remove_strings\": [\n \"###\",\n \"##\",\n \"#\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"chunks": [
{
"body": "This is the body of the content",
"headings": [
"Title Heading",
"Sub Heading 1",
"Sub Sub Heading 1"
]
},
{
"body": "This is the body of the content",
"headings": [
"Title Heading",
"Sub Heading 1",
"Sub Sub Heading 2"
]
}
]
}{
"message": "Bad Request"
}Body
application/json
JSON request payload to perform RAG on some chunks (chunks)
Response
This will be a JSON response of the chunks split from the HTML content with the headings and body
Show child attributes
Show child attributes
Was this page helpful?
⌘I