Python
import os
from scale_gp import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
response = client.knowledge_bases.artifacts.chunks.put(
chunk_id="chunk_id",
knowledge_base_id="knowledge_base_id",
artifact_id="artifact_id",
chunk_position=0,
text="text",
)
print(response.id)package main
import (
"context"
"fmt"
"github.com/stainless-sdks/sgp-go"
"github.com/stainless-sdks/sgp-go/option"
)
func main() {
client := sgp.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.KnowledgeBases.Artifacts.Chunks.Put(
context.TODO(),
"knowledge_base_id",
"artifact_id",
"chunk_id",
sgp.KnowledgeBaseArtifactChunkPutParams{
ChunkPosition: sgp.F(int64(0)),
Text: sgp.F("text"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
curl --request PUT \
--url https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "<string>",
"chunk_position": 123,
"metadata": {}
}
'const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', chunk_position: 123, metadata: {}})
};
fetch('https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}', 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.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'chunk_position' => 123,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.put("https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"chunk_position\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"chunk_position\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"text": "<string>",
"artifact_id": "<string>",
"chunk_position": 123,
"metadata": {},
"user_supplied_metadata": {},
"status_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Knowledge Bases
Update Single Chunk data for local artifact
PUT
/
v4
/
knowledge-bases
/
{knowledge_base_id}
/
artifacts
/
{artifact_id}
/
chunks
/
{chunk_id}
Python
import os
from scale_gp import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
response = client.knowledge_bases.artifacts.chunks.put(
chunk_id="chunk_id",
knowledge_base_id="knowledge_base_id",
artifact_id="artifact_id",
chunk_position=0,
text="text",
)
print(response.id)package main
import (
"context"
"fmt"
"github.com/stainless-sdks/sgp-go"
"github.com/stainless-sdks/sgp-go/option"
)
func main() {
client := sgp.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.KnowledgeBases.Artifacts.Chunks.Put(
context.TODO(),
"knowledge_base_id",
"artifact_id",
"chunk_id",
sgp.KnowledgeBaseArtifactChunkPutParams{
ChunkPosition: sgp.F(int64(0)),
Text: sgp.F("text"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
curl --request PUT \
--url https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "<string>",
"chunk_position": 123,
"metadata": {}
}
'const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', chunk_position: 123, metadata: {}})
};
fetch('https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}', 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.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'chunk_position' => 123,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.put("https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"chunk_position\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks/{chunk_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"chunk_position\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"text": "<string>",
"artifact_id": "<string>",
"chunk_position": 123,
"metadata": {},
"user_supplied_metadata": {},
"status_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Headers
Body
application/json
Response
Successful Response
The id of the chunk
The text of the chunk as stored in the database
The id of the artifact
Chunk position
Status of the chunk. If Failed or Pending, its possible that the chunk does not reflect in OpenSearch
Available options:
Pending, Completed, Failed Metadata of the chunk which is stored in OpenSearch
Metadata of the chunk which is stored in the database only provided via custom chunking.
Status reason of the chunk. May be successful
Date and time of chunk creation
⌘I

