Skip to main content

WritableKnowledgeBox

@nuclia/core


@nuclia/core / WritableKnowledgeBox

Class: WritableKnowledgeBox

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1011

Extends KnowledgeBox with all the write operations.

Extends​

Extended by​

Implements​

Constructors​

Constructor​

new WritableKnowledgeBox(nuclia, account, data): WritableKnowledgeBox

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:154

Parameters​

nuclia​

INuclia

account​

string

data​

IKnowledgeBoxBase | IKnowledgeBoxStandalone

Returns​

WritableKnowledgeBox

Inherited from​

KnowledgeBox.constructor

Properties​

accountId​

accountId: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:104

Inherited from​

KnowledgeBox.accountId


admin?​

optional admin?: boolean

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1013

True if the current user is an administrator of the Knowledge Box.

Implementation of​

IWritableKnowledgeBox.admin


allowed_ip_addresses?​

optional allowed_ip_addresses?: string[] | null

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:40

Implementation of​

IWritableKnowledgeBox.allowed_ip_addresses

Inherited from​

KnowledgeBox.allowed_ip_addresses


allowed_origins?​

optional allowed_origins?: string[] | null

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:39

Implementation of​

IWritableKnowledgeBox.allowed_origins

Inherited from​

KnowledgeBox.allowed_origins


contrib?​

optional contrib?: boolean

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1015

True if the current user is a contributor of the Knowledge Box.

Implementation of​

IWritableKnowledgeBox.contrib


created?​

optional created?: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:38

Implementation of​

IWritableKnowledgeBox.created

Inherited from​

KnowledgeBox.created


description?​

optional description?: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:36

Implementation of​

IWritableKnowledgeBox.description

Inherited from​

KnowledgeBox.description


enforce_security?​

optional enforce_security?: boolean

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:44

Implementation of​

IWritableKnowledgeBox.enforce_security

Inherited from​

KnowledgeBox.enforce_security


external_index_provider?​

optional external_index_provider?: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:45

Implementation of​

IWritableKnowledgeBox.external_index_provider

Inherited from​

KnowledgeBox.external_index_provider


hidden_resources_enabled?​

optional hidden_resources_enabled?: boolean

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:42

Implementation of​

IWritableKnowledgeBox.hidden_resources_enabled

Inherited from​

KnowledgeBox.hidden_resources_enabled


hidden_resources_hide_on_creation?​

optional hidden_resources_hide_on_creation?: boolean

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:43

Implementation of​

IWritableKnowledgeBox.hidden_resources_hide_on_creation

Inherited from​

KnowledgeBox.hidden_resources_hide_on_creation


id​

id: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:32

Implementation of​

IWritableKnowledgeBox.id

Inherited from​

KnowledgeBox.id


nuclia​

protected nuclia: INuclia

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:105

Inherited from​

KnowledgeBox.nuclia


search_configs?​

optional search_configs?: object

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:41

Index Signature​

[key: string]: any

Implementation of​

IWritableKnowledgeBox.search_configs

Inherited from​

KnowledgeBox.search_configs


slug​

slug: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:33

Implementation of​

IWritableKnowledgeBox.slug

Inherited from​

KnowledgeBox.slug


state?​

optional state?: KBStates

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:35

Implementation of​

IWritableKnowledgeBox.state

Inherited from​

KnowledgeBox.state


title​

title: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:34

Implementation of​

IWritableKnowledgeBox.title

Inherited from​

KnowledgeBox.title


zone​

zone: string

Defined in: libs/sdk-core/src/lib/db/kb/kb.models.ts:37

Implementation of​

IWritableKnowledgeBox.zone

Inherited from​

KnowledgeBox.zone

Accessors​

activityMonitor​

Get Signature​

get activityMonitor(): ActivityMonitor

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1041

Returns​

ActivityMonitor

Implementation of​

IWritableKnowledgeBox.activityMonitor


fullpath​

Get Signature​

get fullpath(): string

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:150

The Knowledge Box fullpath on the regional API.

Example: https://europe-1.dp.progress.cloud/api/v1/kb/3cce4a71-9cb9-4fda-beee-8a1512616bf0

Returns​

string

Implementation of​

IWritableKnowledgeBox.fullpath

Inherited from​

KnowledgeBox.fullpath


path​

Get Signature​

get path(): string

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:141

The Knowledge Box path on the regional API.

Example: /v1/kb/3cce4a71-9cb9-4fda-beee-8a1512616bf0

Returns​

string

Implementation of​

IWritableKnowledgeBox.path

Inherited from​

KnowledgeBox.path


syncManager​

Get Signature​

get syncManager(): ISyncManager

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1029

Returns​

ISyncManager

Implementation of​

IWritableKnowledgeBox.syncManager


taskManager​

Get Signature​

get taskManager(): TaskManager

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1024

Entry point to task manager

Returns​

TaskManager

Implementation of​

IWritableKnowledgeBox.taskManager


training​

Get Signature​

get training(): Training

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1037

Deprecated​
Returns​

Training

Methods​

addVectorset()​

addVectorset(model): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1306

Add an embedding model to the Knowledge box

Parameters​

model​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.addVectorset


ask()​

Call Signature​

ask(query, context?, features?, options?): Observable<Answer | IErrorResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:374

Retrieves a generative answer for the given query.

The generative answer is a text that is generated chunk by chunk by the language model. It is retrieved through a readable HTTP stream, so the chat() method returns an Observable emitting a value each time a new chunk is available. The incomplete attribute of the emitted value indicates if the asnwer is complete or not.

Example:

 nuclia.knowledgeBox
.ask('where does the Little Prince live')
.pipe(filter((answer) => !answer.incomplete))
.subscribe((answer) => {
console.log(answer.text);
});
Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

Returns​

Observable<Answer | IErrorResponse>

Implementation of​

IWritableKnowledgeBox.ask

Inherited from​

KnowledgeBox.ask

Call Signature​

ask(query, context?, features?, options?, callback?): Observable<null>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:380

Retrieves a generative answer for the given query.

The generative answer is a text that is generated chunk by chunk by the language model. It is retrieved through a readable HTTP stream, so the chat() method returns an Observable emitting a value each time a new chunk is available. The incomplete attribute of the emitted value indicates if the asnwer is complete or not.

Example:

 nuclia.knowledgeBox
.ask('where does the Little Prince live')
.pipe(filter((answer) => !answer.incomplete))
.subscribe((answer) => {
console.log(answer.text);
});
Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

callback?​

(answer) => void

Returns​

Observable<null>

Implementation of​

IWritableKnowledgeBox.ask

Inherited from​

KnowledgeBox.ask


askViaWS()​

askViaWS(agenticConfigId, question, keepOpen?, searchConfiguration?, groups?, chatHistory?): Observable<IErrorResponse | AragResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:958

Asks a question using an agentic pipeline (Rephrase → SmartAgent → Summarize) over WebSocket.

Requires an agentic_config_id that has been created via createAgenticConfig(). Set keepOpen: true to keep the connection open for follow-up questions.

Parameters​

agenticConfigId​

string

question​

string

keepOpen?​

boolean = false

searchConfiguration?​

string

groups?​

string[]

chatHistory?​

HistoryEntry[]

Returns​

Observable<IErrorResponse | AragResponse>

Implementation of​

IWritableKnowledgeBox.askViaWS

Inherited from​

KnowledgeBox.askViaWS


batchUpload()​

batchUpload(files): Observable<UploadStatus>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1218

Uploads a list of files to the Knowledge Box. It automatically creates a new resource for each file and uses the TUS protocol to upload the files.

Parameters​

files​

FileList | File[] | FileWithMetadata[]

Returns​

Observable<UploadStatus>

Implementation of​

IWritableKnowledgeBox.batchUpload


catalog()​

catalog(query, options?): Observable<IErrorResponse | Results>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:652

Parameters​

query​

string | CatalogQuery

options?​

CatalogOptions

Returns​

Observable<IErrorResponse | Results>

Implementation of​

IWritableKnowledgeBox.catalog

Inherited from​

KnowledgeBox.catalog


counters()​

counters(): Observable<Counters>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:677

Returns totals for each kind of contents stored in the Knowledge Box (resources, fields, paragraphs, vectors)

Returns​

Observable<Counters>

Implementation of​

IWritableKnowledgeBox.counters

Inherited from​

KnowledgeBox.counters


createAgenticConfig()​

createAgenticConfig(id, config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1346

Parameters​

id​

string

config​

AgenticConfig

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createAgenticConfig


createAgenticRAGPipeline()​

createAgenticRAGPipeline(steps): Pipeline

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:352

Parameters​

steps​

Steps

Returns​

Pipeline

Implementation of​

IWritableKnowledgeBox.createAgenticRAGPipeline

Inherited from​

KnowledgeBox.createAgenticRAGPipeline


createAgenticSource()​

createAgenticSource(id, source): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1358

Parameters​

id​

string

source​

AgenticSource

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createAgenticSource


createExtractStrategy()​

createExtractStrategy(config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1318

Parameters​

config​

ExtractConfig

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createExtractStrategy


createKey()​

createKey(saId, expires): Observable<{ token: string; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1237

Parameters​

saId​

string

expires​

string

Returns​

Observable<{ token: string; }>

Implementation of​

IWritableKnowledgeBox.createKey


createKeyForService()​

createKeyForService(data, expires): Observable<{ token: string; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1249

Parameters​

data​

ServiceAccountCreation

expires​

string

Returns​

Observable<{ token: string; }>

Implementation of​

IWritableKnowledgeBox.createKeyForService


createKVSchema()​

createKVSchema(schema): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1371

Creates a new KV schema in the Knowledge Box.

Parameters​

schema​

KVSchema

Returns​

Observable<void>


createLinkResource()​

createLinkResource(link, metadata?, synchronous?, origin?, slug?): Observable<{ uuid: string; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1147

Creates a new link resource in the Knowledge Box more easily than using createResource.

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(
switchMap((knowledgeBox) =>
knowledgeBox.createLinkResource(
{
uri: 'https://en.wikipedia.org/wiki/Hedy_Lamarr',
},
{ classifications: [{ labelset: 'Genius', label: 'Inventor' }] },
),
),
)
.subscribe(() => {
console.log('resource created');
});

Parameters​

LinkField

metadata?​

UserMetadata

synchronous?​

boolean = true

origin?​

Origin

slug?​

string

Returns​

Observable<{ uuid: string; }>

Implementation of​

IWritableKnowledgeBox.createLinkResource


createOrUpdateResource()​

createOrUpdateResource(data, synchronous?): Observable<void | { uuid: string; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1178

Creates a resource or updates it if it already exists

Parameters​

data​

ICreateResource

synchronous?​

boolean = true

Returns​

Observable<void | { uuid: string; }>


createResource()​

createResource(resource, synchronous?): Observable<{ uuid: string; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1119

Creates and indexes a new resource in the Knowledge Box.

Parameters​

resource​

ICreateResource

synchronous?​

boolean = true

Returns​

Observable<{ uuid: string; }>

Implementation of​

IWritableKnowledgeBox.createResource


createSearchConfig()​

createSearchConfig(id, config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1334

Parameters​

id​

string

config​

SearchConfig

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createSearchConfig


createServiceAccount()​

createServiceAccount(data): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1227

Parameters​

data​

ServiceAccountCreation

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createServiceAccount


createSplitStrategy()​

createSplitStrategy(strategy): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1326

Parameters​

strategy​

SplitStrategy

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.createSplitStrategy


delete()​

delete(): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1064

Deletes the Knowledge Box.

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.delete


deleteAgenticConfig()​

deleteAgenticConfig(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1354

Parameters​

id​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteAgenticConfig


deleteAgenticSource()​

deleteAgenticSource(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1366

Parameters​

id​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteAgenticSource


deleteExtractStrategy()​

deleteExtractStrategy(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1322

Parameters​

id​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteExtractStrategy


deleteInvite()​

deleteInvite(email): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1296

Parameters​

email​

string

Returns​

Observable<void>


deleteKey()​

deleteKey(saId, saKeyId): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1266

Parameters​

saId​

string

saKeyId​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteKey


deleteKVSchema()​

deleteKVSchema(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1381

Deletes a KV schema from the Knowledge Box.

Parameters​

id​

string

Returns​

Observable<void>


deleteLabelSet()​

deleteLabelSet(setId): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1114

Deletes a label set.

Parameters​

setId​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteLabelSet


deleteProcessingHook()​

deleteProcessingHook(): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1389

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteProcessingHook


deleteSearchConfig()​

deleteSearchConfig(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1342

Parameters​

id​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteSearchConfig


deleteServiceAccount()​

deleteServiceAccount(saId): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1232

Parameters​

saId​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteServiceAccount


deleteSplitStrategy()​

deleteSplitStrategy(id): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1330

Parameters​

id​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.deleteSplitStrategy


feedback()​

feedback(answerId, good, feedback?, text_block_id?): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:666

Parameters​

answerId​

string

good​

boolean

feedback?​

string = ''

text_block_id?​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.feedback

Inherited from​

KnowledgeBox.feedback


find()​

find(query, features?, options?): Observable<FindResults | IErrorResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:414

Performs a find operation in the Knowledge Box, which is the recommended way to search for results.

Example:

nuclia.knowledgeBox
.find('where does the Little Prince live')
.subscribe((searchResult) => {
console.log('search result', searchResult);
});

Parameters​

query​

string

features?​

Features[] = []

options?​

SearchOptions

Returns​

Observable<FindResults | IErrorResponse>

Implementation of​

IWritableKnowledgeBox.find

Inherited from​

KnowledgeBox.find


generate()​

generate(question, context?): Observable<{ answer: string; cannotAnswer: boolean; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:536

Performs a question answering operation based on a given context.

Example:

nuclia.knowledgeBox
.generate('Who is Eric from Toronto?', [
'Eric is a taxi driver',
'Eric was born in France',
'Eric lives in Toronto',
]))
.subscribe(({ answer }) => {
console.log('answer', answer);
});

Parameters​

question​

string

context?​

string[] = []

Returns​

Observable<{ answer: string; cannotAnswer: boolean; }>

Implementation of​

IWritableKnowledgeBox.generate

Inherited from​

KnowledgeBox.generate


generateJSON()​

generateJSON(question, json_schema, context?): Observable<{ answer: object; success: boolean; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:580

Performs a question answering operation using a JSON schema.

Example:

nuclia.knowledgeBox
.generateJSON(
'Who is Eric from Toronto?',
{
name: 'info',
parameters: {
properties: {
location: {
title: 'Location',
description: 'The location of the person',
type: 'string',
},
name: {
title: 'Name',
description: 'The name of the person',
type: 'string',
},
},
required: ['name', 'location'],
},
},
[
'Eric is a taxi driver',
'Eric was born in France',
'Eric lives in Toronto',
],
)).subscribe((answer) => {
console.log('location', answer.answer.location);
});

Parameters​

question​

string

json_schema​

object

context?​

string[] = []

Returns​

Observable<{ answer: object; success: boolean; }>

Implementation of​

IWritableKnowledgeBox.generateJSON

Inherited from​

KnowledgeBox.generateJSON


generateRandomQuestionAboutResource()​

generateRandomQuestionAboutResource(resource): Observable<string>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:626

Generates a random question about the given resource. It picks an entities relation from the extracted metadata and generates a question about it. It returns an empty string if no question can be generated. Example:

 nuclia.knowledgeBox
.getResource('09a94719a6444c5a9689394f6ed9baf6', [ResourceProperties.EXTRACTED], [ExtractedDataTypes.METADATA])
.pipe(
switchMap((resource) => knowledgeBox.generateRandomQuestionAboutResource(resource)),
)
.subscribe((question) => {
console.log('question', question);
});

Parameters​

resource​

Resource

Returns​

Observable<string>

Implementation of​

IWritableKnowledgeBox.generateRandomQuestionAboutResource

Inherited from​

KnowledgeBox.generateRandomQuestionAboutResource


getAgenticConfig()​

getAgenticConfig(id): Observable<AgenticConfig>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:932

Parameters​

id​

string

Returns​

Observable<AgenticConfig>

Implementation of​

IWritableKnowledgeBox.getAgenticConfig

Inherited from​

KnowledgeBox.getAgenticConfig


getAgenticConfigsSchema()​

getAgenticConfigsSchema(): Observable<LearningConfigurationSchema>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:940

Returns​

Observable<LearningConfigurationSchema>

Inherited from​

KnowledgeBox.getAgenticConfigsSchema


getAgenticSource()​

getAgenticSource(id): Observable<AgenticSource>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:944

Parameters​

id​

string

Returns​

Observable<AgenticSource>

Implementation of​

IWritableKnowledgeBox.getAgenticSource

Inherited from​

KnowledgeBox.getAgenticSource


getConfiguration()​

getConfiguration(): Observable<{[id: string]: any; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:740

Returns​

Observable<{[id: string]: any; }>

Implementation of​

IWritableKnowledgeBox.getConfiguration

Inherited from​

KnowledgeBox.getConfiguration


getEntities()​

getEntities(): Observable<Entities>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:173

Returns all the NER families defined in the Knowledge Box.

Returns​

Observable<Entities>

Implementation of​

IWritableKnowledgeBox.getEntities

Inherited from​

KnowledgeBox.getEntities


getEntitiesGroup()​

getEntitiesGroup(groupId): Observable<EntitiesGroup>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:178

Returns the NER family with the given id.

Parameters​

groupId​

string

Returns​

Observable<EntitiesGroup>

Implementation of​

IWritableKnowledgeBox.getEntitiesGroup

Inherited from​

KnowledgeBox.getEntitiesGroup


getExtractStrategies()​

getExtractStrategies(): Observable<ExtractStrategies>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:916

Returns​

Observable<ExtractStrategies>

Implementation of​

IWritableKnowledgeBox.getExtractStrategies

Inherited from​

KnowledgeBox.getExtractStrategies


getFacets()​

getFacets(facets): Observable<FacetsResult>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:205

Get the total amount of matches in the Knowledge Box for specific criteria (facets) passed in argument

Parameters​

facets​

string[]

List of facets to request

Returns​

Observable<FacetsResult>

An observable containing an object where each key is a string and maps to an object containing values and their corresponding counts.

Implementation of​

IWritableKnowledgeBox.getFacets

Inherited from​

KnowledgeBox.getFacets


getFullResource()​

getFullResource(uuid): Observable<Resource>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:264

Retrieves a resource from the Knowledge Box with all its attached metadata and content.

Parameters​

uuid​

string

Returns​

Observable<Resource>

Implementation of​

IWritableKnowledgeBox.getFullResource

Inherited from​

KnowledgeBox.getFullResource


getFullResourceBySlug()​

getFullResourceBySlug(slug): Observable<Resource>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:296

Parameters​

slug​

string

Returns​

Observable<Resource>

Implementation of​

IWritableKnowledgeBox.getFullResourceBySlug

Inherited from​

KnowledgeBox.getFullResourceBySlug


getGenerativeProviders()​

getGenerativeProviders(): Observable<GenerativeProviders>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:750

Returns​

Observable<GenerativeProviders>

Implementation of​

IWritableKnowledgeBox.getGenerativeProviders

Inherited from​

KnowledgeBox.getGenerativeProviders


getInvites()​

getInvites(): Observable<KbInvite[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:765

Returns​

Observable<KbInvite[]>

Inherited from​

KnowledgeBox.getInvites


getKbEndpointAndZone()​

protected getKbEndpointAndZone(): object

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1069

Returns​

object

endpoint​

endpoint: string

zone​

zone: string | undefined


getKVSchema()​

getKVSchema(id): Observable<KVSchema>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:196

Returns the KV schema with the given id.

Parameters​

id​

string

Returns​

Observable<KVSchema>

Inherited from​

KnowledgeBox.getKVSchema


getKVSchemas()​

getKVSchemas(): Observable<KBKVSchemas>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:191

Returns all the KV schemas defined in the Knowledge Box.

Returns​

Observable<KBKVSchemas>

Inherited from​

KnowledgeBox.getKVSchemas


getLabels()​

getLabels(): Observable<LabelSets>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:183

Returns all the labels defined in the Knowledge Box.

Returns​

Observable<LabelSets>

Implementation of​

IWritableKnowledgeBox.getLabels

Inherited from​

KnowledgeBox.getLabels


getLearningSchema()​

getLearningSchema(): Observable<LearningConfigurations>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:744

Returns​

Observable<LearningConfigurations>

Implementation of​

IWritableKnowledgeBox.getLearningSchema

Inherited from​

KnowledgeBox.getLearningSchema


getProcessingHook()​

getProcessingHook(): Observable<ProcessingHook | undefined>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1003

Returns​

Observable<ProcessingHook | undefined>

Implementation of​

IWritableKnowledgeBox.getProcessingHook

Inherited from​

KnowledgeBox.getProcessingHook


getResource()​

getResource(uuid, show?, extracted?): Observable<Resource>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:253

Retrieves a resource from the Knowledge Box.

  • show defines which properties are returned. Default retrieves only the basic metadata.
  • extracted defines which extracted data are returned. It is ignored if ResourceProperties.EXTRACTED is not in the returned properties. Default is an empty array.

Example:

nuclia.db
.getKnowledgeBox()
.pipe(switchMap((knowledgeBox) => knowledgeBox.getResource('09a94719a6444c5a9689394f6ed9baf6')))
.subscribe((resource) => {
console.log('resource', resource);
});

Parameters​

uuid​

string

show?​

ResourceProperties[] = ...

extracted?​

ExtractedDataTypes[] = []

Returns​

Observable<Resource>

Implementation of​

IWritableKnowledgeBox.getResource

Inherited from​

KnowledgeBox.getResource


getResourceBySlug()​

getResourceBySlug(slug, show?, extracted?): Observable<Resource>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:288

Parameters​

slug​

string

show?​

ResourceProperties[] = ...

extracted?​

ExtractedDataTypes[] = []

Returns​

Observable<Resource>

Implementation of​

IWritableKnowledgeBox.getResourceBySlug

Inherited from​

KnowledgeBox.getResourceBySlug


getResourceFromData()​

getResourceFromData(data): Resource

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:348

Parameters​

data​

IResource

Returns​

Resource

Inherited from​

KnowledgeBox.getResourceFromData


getSearchConfig()​

getSearchConfig(id): Observable<SearchConfig>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:924

Parameters​

id​

string

Returns​

Observable<SearchConfig>

Implementation of​

IWritableKnowledgeBox.getSearchConfig

Inherited from​

KnowledgeBox.getSearchConfig


getSearchConfigs()​

getSearchConfigs(): Observable<SearchConfigs>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:928

Returns​

Observable<SearchConfigs>

Implementation of​

IWritableKnowledgeBox.getSearchConfigs

Inherited from​

KnowledgeBox.getSearchConfigs


getServiceAccounts()​

getServiceAccounts(): Observable<ServiceAccount[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1222

Returns​

Observable<ServiceAccount[]>

Implementation of​

IWritableKnowledgeBox.getServiceAccounts


getSplitStrategies()​

getSplitStrategies(): Observable<SplitStrategies>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:920

Returns​

Observable<SplitStrategies>

Implementation of​

IWritableKnowledgeBox.getSplitStrategies

Inherited from​

KnowledgeBox.getSplitStrategies


getTempToken()​

getTempToken(payload?, ignoreExpiration?): Observable<string>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:713

Returns an ephemeral token. Requires account id and zone to be set in the Nuclia options (except when working with a local NucliaDB instance).

This is useful when displaying a clickable link to a file in a private Knowledge Box (the token will authorize the request even though there are no authentication headers).

Example:

const downloadLink = `${nuclia.rest.getFullpath(filePath)}?eph-token=${nuclia.knowledgeBox.getTempToken()}`;

Parameters​

payload?​

any

Optional payload to provide extra data for the token generation

ignoreExpiration?​

boolean = false

Optional By default, a temp token is valid for 5min and the same token returned if this method is called several times during this time. Passing ignoreExpiration flag to true will ignore this expiration delay and will always return a new token.

Returns​

Observable<string>

Implementation of​

IWritableKnowledgeBox.getTempToken

Inherited from​

KnowledgeBox.getTempToken


getUsers()​

getUsers(): Observable<FullKbUser[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:756

Returns​

Observable<FullKbUser[]>

Implementation of​

IWritableKnowledgeBox.getUsers

Inherited from​

KnowledgeBox.getUsers


hasResource()​

hasResource(slug): Observable<boolean>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1168

Checks if a resource exists for the given slug.

Parameters​

slug​

string

Returns​

Observable<boolean>


inviteToKb()​

inviteToKb(data): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1288

Invite a user to the Knowledge Box

Parameters​

data​

InviteKbData

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.inviteToKb


listAgenticConfigs()​

listAgenticConfigs(): Observable<AgenticConfigs>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:936

Returns​

Observable<AgenticConfigs>

Implementation of​

IWritableKnowledgeBox.listAgenticConfigs

Inherited from​

KnowledgeBox.listAgenticConfigs


listAgenticSources()​

listAgenticSources(): Observable<AgenticSources>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:948

Returns​

Observable<AgenticSources>

Implementation of​

IWritableKnowledgeBox.listAgenticSources

Inherited from​

KnowledgeBox.listAgenticSources


listenToAllNotifications()​

listenToAllNotifications(): Observable<NotificationMessage[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:777

Start listening to all the notifications sent by the Knowledge Box.

Returns​

Observable<NotificationMessage[]>

Implementation of​

IWritableKnowledgeBox.listenToAllNotifications

Inherited from​

KnowledgeBox.listenToAllNotifications


listenToProcessingNotifications()​

listenToProcessingNotifications(): Observable<ResourceBaseNotification[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:856

Start listening to the Knowledge Box notifications, and returns the list of notifications for resources which have processing completed (either successfully or not). Notifications are sent anytime processing is completed, and processing is done anytime the resource is created or modified (like when a summary is added to the resource for example).

Returns​

Observable<ResourceBaseNotification[]>

Implementation of​

IWritableKnowledgeBox.listenToProcessingNotifications

Inherited from​

KnowledgeBox.listenToProcessingNotifications


listenToResourceOperationNotifications()​

listenToResourceOperationNotifications(): Observable<ResourceOperationNotification[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:801

Start listening to the Knowledge Box notifications, and returns the list of notifications corresponding to the different operations affecting the resources: created, modified, deleted. The notification contains the resource id, title, a timestamp and a flag indicating if the operation was successful or not.

Returns​

Observable<ResourceOperationNotification[]>

Implementation of​

IWritableKnowledgeBox.listenToResourceOperationNotifications

Inherited from​

KnowledgeBox.listenToResourceOperationNotifications


listResources()​

listResources(page?, size?): Observable<ResourceList>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:682

Lists all the resources stored in the Knowledge Box.

Parameters​

page?​

number

size?​

number

Returns​

Observable<ResourceList>

Implementation of​

IWritableKnowledgeBox.listResources

Inherited from​

KnowledgeBox.listResources


modify()​

modify(data): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1058

Modifies the Knowledge Box properties.

Example:

nuclia.db.getKnowledgeBox("my-account", "my-kb").pipe(
switchMap((knowledgeBox) => knowledgeBox.modify({title: "My new title"}),
).subscribe(() => {
console.log("knowledge box modified");
});

Parameters​

data​

Partial<IKnowledgeBox>

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.modify


predictAnswer()​

predictAnswer(question, options?, synchronous?): Observable<Answer | IErrorResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:512

Performs a question answering operation

Example:

nuclia.knowledgeBox
.predictAnswer('Who is Eric from Toronto?'))
.subscribe((answer) => {
if (answer.type !== 'error') {
console.log('answer', answer.text);
}
});

Parameters​

question​

string

options?​

PredictAnswerOptions

synchronous?​

boolean = true

Returns​

Observable<Answer | IErrorResponse>

Implementation of​

IWritableKnowledgeBox.predictAnswer

Inherited from​

KnowledgeBox.predictAnswer


processingStatus()​

processingStatus(cursor?, scheduled?, limit?): Observable<{ cursor: string; results: ProcessingStatus[]; }>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:898

Parameters​

cursor?​

string

scheduled?​

boolean

limit?​

number

Returns​

Observable<{ cursor: string; results: ProcessingStatus[]; }>

Implementation of​

IWritableKnowledgeBox.processingStatus

Inherited from​

KnowledgeBox.processingStatus


publish()​

publish(published): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1084

Publishes or unpublishes the Knowledge Box.

Parameters​

published​

boolean

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.publish


removeVectorset()​

removeVectorset(model): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1314

Remove an embedding model from the Knowledge box

Parameters​

model​

string

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.removeVectorset


rephrase()​

rephrase(question, user_context?, rephrase_prompt?): Observable<string>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:604

Performs a question rephrasing operation. It returns a rephrased question that can be used as input for the generate() method. Example:

nuclia.knowledgeBox
.rephrase('Eric lives Toronto')
.subscribe((rephrased) => {
console.log('rephrased', rephrased); // Where does Eric live?
});

Parameters​

question​

string

user_context?​

string[]

rephrase_prompt?​

string

Returns​

Observable<string>

Implementation of​

IWritableKnowledgeBox.rephrase

Inherited from​

KnowledgeBox.rephrase


search(query, features?, options?): Observable<IErrorResponse | Results>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:436

Performs a search operation in the knowledge box.

It is similar to find() but the results are not nested.

Example:

nuclia.knowledgeBox
.search('where does the Little Prince live', [Search.Features.KEYWORD])
.subscribe((searchResult) => {
console.log('search result', searchResult);
});

Parameters​

query​

string

features?​

Features[] = []

options?​

SearchOptions

Returns​

Observable<IErrorResponse | Results>

Implementation of​

IWritableKnowledgeBox.search

Inherited from​

KnowledgeBox.search


setConfiguration()​

setConfiguration(config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1271

Parameters​

config​

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.setConfiguration


setLabelSet()​

setLabelSet(setId, labelSet): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1109

Creates or updates a label set.

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(
switchMap((knowledgeBox) =>
knowledgeBox.setLabelSet('status', {
title: 'Status',
color: '#ff0000',
labels: [{ title: 'Major' }, { title: 'Minor' }, { title: 'Critical' }],
}),
),
)
.subscribe(() => {
console.log('label set set');
});

Parameters​

setId​

string

labelSet​

LabelSet

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.setLabelSet


stopListeningToNotifications()​

stopListeningToNotifications(): void

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:788

Stop listening the notifications sent by the Knowledge Box.

Returns​

void

Implementation of​

IWritableKnowledgeBox.stopListeningToNotifications

Inherited from​

KnowledgeBox.stopListeningToNotifications


suggest()​

suggest(query, inTitleOnly?, features?, options?): Observable<IErrorResponse | Suggestions>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:657

Suggests paragraphs based on the given query.

Parameters​

query​

string

inTitleOnly?​

boolean = false

features?​

SuggestionFeatures[] = []

options?​

SuggestOptions

Returns​

Observable<IErrorResponse | Suggestions>

Implementation of​

IWritableKnowledgeBox.suggest

Inherited from​

KnowledgeBox.suggest


summarize()​

summarize(ressourceIds, user_prompt?, generative_model?): Observable<string>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:462

Summarize resources.

It reads the resources text content and return a global summary about them and one summery per resource.

The optional user_prompt parameter allows you to specify a text that will be used to generate the summary, and must use the {text} placeholder to indicate where the resource text should be inserted (example: 'Make a one-line summary of the following text: {text}').

Example:

nuclia.knowledgeBox
.summarize(['09a94719a6444c5a9689394f6ed9baf6'])
.subscribe((summary) => {
console.log('Summary', summary);
});

Parameters​

ressourceIds​

string[]

user_prompt?​

string

generative_model?​

string

Returns​

Observable<string>

Implementation of​

IWritableKnowledgeBox.summarize

Inherited from​

KnowledgeBox.summarize


tokens()​

tokens(text): Observable<SentenceToken[]>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:492

Performs a tokenization of the given text.

Example:

nuclia.knowledgeBox
.tokens('Does James Joyce live in Dublin?')
.subscribe((tokens) => {
console.log('tokens', tokens);
});

Parameters​

text​

string

Returns​

Observable<SentenceToken[]>

Implementation of​

IWritableKnowledgeBox.tokens

Inherited from​

KnowledgeBox.tokens


updateAgenticConfig()​

updateAgenticConfig(id, config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1350

Parameters​

id​

string

config​

AgenticConfig

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.updateAgenticConfig


updateAgenticSource()​

updateAgenticSource(id, source): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1362

Parameters​

id​

string

source​

AgenticSource

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.updateAgenticSource


updateKVSchema()​

updateKVSchema(id, update): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1376

Updates an existing KV schema. Only description and fields can be changed; id is immutable.

Parameters​

id​

string

update​

UpdateKVSchema

Returns​

Observable<void>


updateProcessingHook()​

updateProcessingHook(data): Observable<ProcessingHook>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1385

Parameters​

data​

ProcessingHook

Returns​

Observable<ProcessingHook>

Implementation of​

IWritableKnowledgeBox.updateProcessingHook


updateSearchConfig()​

updateSearchConfig(id, config): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1338

Parameters​

id​

string

config​

SearchConfig

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.updateSearchConfig


updateUsers()​

updateUsers(data): Observable<void>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1279

Update the list of users of the Knowledge Box, providing the list of users (id and role) to add and/or update, and the list of user ids to delete.

Parameters​

data​

KbUserPayload

Returns​

Observable<void>

Implementation of​

IWritableKnowledgeBox.updateUsers


upload()​

Call Signature​

upload(file, TUS?, metadata?): Observable<UploadResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1204

Uploads a file to the Knowledge Box and automatically creates a new resource to store the file. The resource path is returned in the resource property of the UploadResult (and field provides the path to the FileField).

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(switchMap((knowledgeBox) => knowledgeBox.upload(fileInputElement.files[0])))
.subscribe(() => {
console.log('file uploaded');
});
Parameters​
file​

File | FileWithMetadata

TUS?​

boolean

metadata?​

FileMetadata

Returns​

Observable<UploadResponse>

Implementation of​

IWritableKnowledgeBox.upload

Call Signature​

upload(buffer, TUS?, metadata?): Observable<UploadResponse>

Defined in: libs/sdk-core/src/lib/db/kb/kb.ts:1205

Uploads a file to the Knowledge Box and automatically creates a new resource to store the file. The resource path is returned in the resource property of the UploadResult (and field provides the path to the FileField).

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(switchMap((knowledgeBox) => knowledgeBox.upload(fileInputElement.files[0])))
.subscribe(() => {
console.log('file uploaded');
});
Parameters​
buffer​

ArrayBuffer

TUS?​

boolean

metadata?​

FileMetadata

Returns​

Observable<UploadResponse>

Implementation of​

IWritableKnowledgeBox.upload