Skip to main content

@nuclia/core / Exports / WritableKnowledgeBox

Class: WritableKnowledgeBox

Extends KnowledgeBox with all the write operations.

Hierarchy

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new WritableKnowledgeBox(nuclia, account, data)

Parameters

NameType
nucliaINuclia
accountstring
dataIKnowledgeBoxCreation

Inherited from

KnowledgeBox.constructor

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:124

Properties

accountId

accountId: string

Inherited from

KnowledgeBox.accountId

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:74


admin

Optional admin: boolean

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

Implementation of

IWritableKnowledgeBox.admin

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:843


allowed_origins

Optional allowed_origins: null | string[]

Implementation of

IWritableKnowledgeBox.allowed_origins

Inherited from

KnowledgeBox.allowed_origins

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:28


contrib

Optional contrib: boolean

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

Implementation of

IWritableKnowledgeBox.contrib

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:845


description

Optional description: string

Implementation of

IWritableKnowledgeBox.description

Inherited from

KnowledgeBox.description

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:25


external_index_provider

Optional external_index_provider: "pinecone"

Implementation of

IWritableKnowledgeBox.external_index_provider

Inherited from

KnowledgeBox.external_index_provider

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:73


hidden_resources_enabled

Optional hidden_resources_enabled: boolean

Implementation of

IWritableKnowledgeBox.hidden_resources_enabled

Inherited from

KnowledgeBox.hidden_resources_enabled

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:30


hidden_resources_hide_on_creation

Optional hidden_resources_hide_on_creation: boolean

Implementation of

IWritableKnowledgeBox.hidden_resources_hide_on_creation

Inherited from

KnowledgeBox.hidden_resources_hide_on_creation

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:31


id

id: string

Implementation of

IWritableKnowledgeBox.id

Inherited from

KnowledgeBox.id

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:21


nuclia

Protected nuclia: INuclia

Inherited from

KnowledgeBox.nuclia

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:75


search_configs

Optional search_configs: Object

Index signature

▪ [key: string]: any

Implementation of

IWritableKnowledgeBox.search_configs

Inherited from

KnowledgeBox.search_configs

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:29


slug

slug: string

Implementation of

IWritableKnowledgeBox.slug

Inherited from

KnowledgeBox.slug

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:22


state

Optional state: KBStates

Implementation of

IWritableKnowledgeBox.state

Inherited from

KnowledgeBox.state

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:24


title

title: string

Implementation of

IWritableKnowledgeBox.title

Inherited from

KnowledgeBox.title

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:23


uuid

Optional uuid: string

Implementation of

IWritableKnowledgeBox.uuid

Inherited from

KnowledgeBox.uuid

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:27


zone

zone: string

Implementation of

IWritableKnowledgeBox.zone

Inherited from

KnowledgeBox.zone

Defined in

libs/sdk-core/src/lib/db/kb/kb.models.ts:26

Accessors

activityMonitor

get activityMonitor(): ActivityMonitor

Returns

ActivityMonitor

Implementation of

IWritableKnowledgeBox.activityMonitor

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:869


fullpath

get fullpath(): string

The Knowledge Box fullpath on the regional API.

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

Returns

string

Implementation of

IWritableKnowledgeBox.fullpath

Inherited from

KnowledgeBox.fullpath

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:120


path

get path(): string

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

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:111


taskManager

get taskManager(): TaskManager

Entry point to task manager

Returns

TaskManager

Implementation of

IWritableKnowledgeBox.taskManager

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:853


training

get training(): Training

Returns

Training

Deprecated

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:863

Methods

ask

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

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

NameType
querystring
context?ContextEntry[]
features?Features[]
options?ChatOptions

Returns

Observable<IErrorResponse | Answer>

Implementation of

IWritableKnowledgeBox.ask

Inherited from

KnowledgeBox.ask

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:285

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

Parameters

NameType
querystring
context?ContextEntry[]
features?Features[]
options?ChatOptions
callback?(answer: IErrorResponse | Answer) => void

Returns

Observable<null>

Implementation of

IWritableKnowledgeBox.ask

Inherited from

KnowledgeBox.ask

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:291


batchUpload

batchUpload(files): Observable<UploadStatus>

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

NameType
filesFileList | File[] | FileWithMetadata[]

Returns

Observable<UploadStatus>

Implementation of

IWritableKnowledgeBox.batchUpload

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1062


catalog

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

Parameters

NameType
querystring
options?SearchOptions

Returns

Observable<Results | IErrorResponse>

Implementation of

IWritableKnowledgeBox.catalog

Inherited from

KnowledgeBox.catalog

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:583


counters

counters(): Observable<Counters>

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

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:607


createAgenticRAGPipeline

createAgenticRAGPipeline(steps): Pipeline

Parameters

NameType
stepsSteps

Returns

Pipeline

Implementation of

IWritableKnowledgeBox.createAgenticRAGPipeline

Inherited from

KnowledgeBox.createAgenticRAGPipeline

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:263


createKey

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

Parameters

NameType
saIdstring
expiresstring

Returns

Observable<{ token: string }>

Implementation of

IWritableKnowledgeBox.createKey

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1081


createKeyForService

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

Parameters

NameType
dataServiceAccountCreation
expiresstring

Returns

Observable<{ token: string }>

Implementation of

IWritableKnowledgeBox.createKeyForService

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1093


createLinkResource

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

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

NameTypeDefault value
linkLinkFieldundefined
metadata?UserMetadataundefined
synchronousbooleantrue
origin?Originundefined

Returns

Observable<{ uuid: string }>

Implementation of

IWritableKnowledgeBox.createLinkResource

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:992


createOrUpdateResource

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

Creates a resource or updates it if it already exists

Parameters

NameTypeDefault value
dataICreateResourceundefined
synchronousbooleantrue

Returns

Observable<void | { uuid: string }>

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1022


createResource

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

Creates and indexes a new resource in the Knowledge Box.

Parameters

NameTypeDefault value
resourceICreateResourceundefined
synchronousbooleantrue

Returns

Observable<{ uuid: string }>

Implementation of

IWritableKnowledgeBox.createResource

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:964


createServiceAccount

createServiceAccount(data): Observable<void>

Parameters

NameType
dataServiceAccountCreation

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.createServiceAccount

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1071


delete

delete(): Observable<void>

Deletes the Knowledge Box.

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.delete

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:894


deleteAllSynonyms

deleteAllSynonyms(): Observable<void>

Returns

Observable<void>

Deprecated

Implementation of

IWritableKnowledgeBox.deleteAllSynonyms

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:959


deleteInvite

deleteInvite(email): Observable<void>

Parameters

NameType
emailstring

Returns

Observable<void>

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1137


deleteKey

deleteKey(saId, saKeyId): Observable<void>

Parameters

NameType
saIdstring
saKeyIdstring

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.deleteKey

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1110


deleteLabelSet

deleteLabelSet(setId): Observable<void>

Deletes a label set.

Parameters

NameType
setIdstring

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.deleteLabelSet

Defined in

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


deleteServiceAccount

deleteServiceAccount(saId): Observable<void>

Parameters

NameType
saIdstring

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.deleteServiceAccount

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1076


feedback

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

Parameters

NameTypeDefault value
answerIdstringundefined
goodbooleanundefined
feedbackstring''
text_block_id?stringundefined

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.feedback

Inherited from

KnowledgeBox.feedback

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:596


find

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

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

NameTypeDefault value
querystringundefined
featuresFeatures[][]
options?SearchOptionsundefined

Returns

Observable<FindResults | IErrorResponse>

Implementation of

IWritableKnowledgeBox.find

Inherited from

KnowledgeBox.find

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:325


generate

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

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

NameTypeDefault value
questionstringundefined
contextstring[][]

Returns

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

Implementation of

IWritableKnowledgeBox.generate

Inherited from

KnowledgeBox.generate

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:425


generateJSON

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

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

NameTypeDefault value
questionstringundefined
json_schemaobjectundefined
contextstring[][]

Returns

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

Implementation of

IWritableKnowledgeBox.generateJSON

Inherited from

KnowledgeBox.generateJSON

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:485


generateRandomQuestionAboutResource

generateRandomQuestionAboutResource(resource): Observable<string>

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

NameType
resourceResource

Returns

Observable<string>

Implementation of

IWritableKnowledgeBox.generateRandomQuestionAboutResource

Inherited from

KnowledgeBox.generateRandomQuestionAboutResource

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:557


getConfiguration

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

Returns

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

Implementation of

IWritableKnowledgeBox.getConfiguration

Inherited from

KnowledgeBox.getConfiguration

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:669


getEntities

getEntities(): Observable<Entities>

Returns all the NER families defined in the Knowledge Box.

Returns

Observable<Entities>

Implementation of

IWritableKnowledgeBox.getEntities

Inherited from

KnowledgeBox.getEntities

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:137


getEntitiesGroup

getEntitiesGroup(groupId): Observable<EntitiesGroup>

Returns the NER family with the given id.

Parameters

NameType
groupIdstring

Returns

Observable<EntitiesGroup>

Implementation of

IWritableKnowledgeBox.getEntitiesGroup

Inherited from

KnowledgeBox.getEntitiesGroup

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:142


getFullResource

getFullResource(uuid): Observable<Resource>

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

Parameters

NameType
uuidstring

Returns

Observable<Resource>

Implementation of

IWritableKnowledgeBox.getFullResource

Inherited from

KnowledgeBox.getFullResource

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:187


getFullResourceBySlug

getFullResourceBySlug(slug): Observable<Resource>

Parameters

NameType
slugstring

Returns

Observable<Resource>

Implementation of

IWritableKnowledgeBox.getFullResourceBySlug

Inherited from

KnowledgeBox.getFullResourceBySlug

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:213


getInvites

getInvites(): Observable<KbInvite[]>

Returns

Observable<KbInvite[]>

Inherited from

KnowledgeBox.getInvites

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:688


getKbEndpointAndZone

Protected getKbEndpointAndZone(): Object

Returns

Object

NameType
endpointstring
zoneundefined | string

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:899


getLabels

getLabels(): Observable<LabelSets>

Returns all the labels defined in the Knowledge Box.

Returns

Observable<LabelSets>

Implementation of

IWritableKnowledgeBox.getLabels

Inherited from

KnowledgeBox.getLabels

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:151


getLearningSchema

getLearningSchema(): Observable<LearningConfigurations>

Returns

Observable<LearningConfigurations>

Implementation of

IWritableKnowledgeBox.getLearningSchema

Inherited from

KnowledgeBox.getLearningSchema

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:673


getResource

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

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

NameTypeDefault value
uuidstringundefined
showResourceProperties[]undefined
extractedExtractedDataTypes[][]

Returns

Observable<Resource>

Implementation of

IWritableKnowledgeBox.getResource

Inherited from

KnowledgeBox.getResource

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:176


getResourceBySlug

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

Parameters

NameTypeDefault value
slugstringundefined
showResourceProperties[]undefined
extractedExtractedDataTypes[][]

Returns

Observable<Resource>

Implementation of

IWritableKnowledgeBox.getResourceBySlug

Inherited from

KnowledgeBox.getResourceBySlug

Defined in

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


getResourceFromData

getResourceFromData(data): Resource

Parameters

NameType
dataIResource

Returns

Resource

Inherited from

KnowledgeBox.getResourceFromData

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:259


getServiceAccounts

getServiceAccounts(): Observable<ServiceAccount[]>

Returns

Observable<ServiceAccount[]>

Implementation of

IWritableKnowledgeBox.getServiceAccounts

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1066


getSynonyms

getSynonyms(): Observable<Synonyms>

Returns

Observable<Synonyms>

Implementation of

IWritableKnowledgeBox.getSynonyms

Inherited from

KnowledgeBox.getSynonyms

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:146


getTempToken

getTempToken(): Observable<string>

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()}`;

Returns

Observable<string>

Implementation of

IWritableKnowledgeBox.getTempToken

Inherited from

KnowledgeBox.getTempToken

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:639


getUsers

getUsers(): Observable<FullKbUser[]>

Returns

Observable<FullKbUser[]>

Implementation of

IWritableKnowledgeBox.getUsers

Inherited from

KnowledgeBox.getUsers

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:679


hasResource

hasResource(slug): Observable<boolean>

Checks if a resource exists for the given slug.

Parameters

NameType
slugstring

Returns

Observable<boolean>

Defined in

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


inviteToKb

inviteToKb(data): Observable<void>

Invite a user to the Knowledge Box

Parameters

NameType
dataInviteKbData

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.inviteToKb

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1132


listResources

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

Lists all the resources stored in the Knowledge Box.

Parameters

NameType
page?number
size?number

Returns

Observable<ResourceList>

Implementation of

IWritableKnowledgeBox.listResources

Inherited from

KnowledgeBox.listResources

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:612


listenToAllNotifications

listenToAllNotifications(): Observable<NotificationMessage[]>

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

Returns

Observable<NotificationMessage[]>

Implementation of

IWritableKnowledgeBox.listenToAllNotifications

Inherited from

KnowledgeBox.listenToAllNotifications

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:700


listenToProcessingNotifications

listenToProcessingNotifications(): Observable<ResourceBaseNotification[]>

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

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:779


listenToResourceOperationNotifications

listenToResourceOperationNotifications(): Observable<ResourceOperationNotification[]>

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

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:724


modify

modify(data): Observable<void>

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

NameType
dataPartial<IKnowledgeBox>

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.modify

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:888


processingStatus

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

Parameters

NameType
cursor?string
scheduled?boolean
limit?number

Returns

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

Implementation of

IWritableKnowledgeBox.processingStatus

Inherited from

KnowledgeBox.processingStatus

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:821


publish

publish(published): Observable<void>

Publishes or unpublishes the Knowledge Box.

Parameters

NameType
publishedboolean

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.publish

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:914


rephrase

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

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

NameType
questionstring
user_context?string[]
rephrase_prompt?string

Returns

Observable<string>

Implementation of

IWritableKnowledgeBox.rephrase

Inherited from

KnowledgeBox.rephrase

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:535


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

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

NameTypeDefault value
querystringundefined
featuresFeatures[][]
options?SearchOptionsundefined

Returns

Observable<Results | IErrorResponse>

Implementation of

IWritableKnowledgeBox.search

Inherited from

KnowledgeBox.search

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:347


setConfiguration

setConfiguration(config): Observable<void>

Parameters

NameType
configObject

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.setConfiguration

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1115


setLabelSet

setLabelSet(setId, labelSet): Observable<void>

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

NameType
setIdstring
labelSetLabelSet

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.setLabelSet

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:939


setSynonyms

setSynonyms(synonyms): Observable<void>

Parameters

NameType
synonymsSynonyms

Returns

Observable<void>

Deprecated

Implementation of

IWritableKnowledgeBox.setSynonyms

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:952


stopListeningToNotifications

stopListeningToNotifications(): void

Stop listening the notifications sent by the Knowledge Box.

Returns

void

Implementation of

IWritableKnowledgeBox.stopListeningToNotifications

Inherited from

KnowledgeBox.stopListeningToNotifications

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:711


suggest

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

Suggests paragraphs based on the given query.

Parameters

NameTypeDefault value
querystringundefined
inTitleOnlybooleanfalse
featuresSuggestionFeatures[][]

Returns

Observable<Suggestions | IErrorResponse>

Implementation of

IWritableKnowledgeBox.suggest

Inherited from

KnowledgeBox.suggest

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:588


summarize

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

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

NameType
ressourceIdsstring[]
user_prompt?string
generative_model?string

Returns

Observable<string>

Implementation of

IWritableKnowledgeBox.summarize

Inherited from

KnowledgeBox.summarize

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:373


tokens

tokens(text): Observable<SentenceToken[]>

Performs a tokenization of the given text.

Example:

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

Parameters

NameType
textstring

Returns

Observable<SentenceToken[]>

Implementation of

IWritableKnowledgeBox.tokens

Inherited from

KnowledgeBox.tokens

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:403


updateUsers

updateUsers(data): Observable<void>

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

NameType
dataKbUserPayload

Returns

Observable<void>

Implementation of

IWritableKnowledgeBox.updateUsers

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1123


upload

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

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

NameType
fileFile | FileWithMetadata
TUS?boolean
metadata?FileMetadata

Returns

Observable<UploadResponse>

Implementation of

IWritableKnowledgeBox.upload

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1048

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

Parameters

NameType
bufferArrayBuffer
TUS?boolean
metadata?FileMetadata

Returns

Observable<UploadResponse>

Implementation of

IWritableKnowledgeBox.upload

Defined in

libs/sdk-core/src/lib/db/kb/kb.ts:1049