@nuclia/core / Exports / WritableKnowledgeBox
Class: WritableKnowledgeBox
Extends KnowledgeBox
with all the write operations.
Hierarchy
-
↳
WritableKnowledgeBox
Implements
Table of contents
Constructors
Properties
- accountId
- admin
- allowed_origins
- contrib
- description
- external_index_provider
- hidden_resources_enabled
- hidden_resources_hide_on_creation
- id
- nuclia
- search_configs
- slug
- state
- title
- uuid
- zone
Accessors
Methods
- ask
- batchUpload
- catalog
- counters
- createAgenticRAGPipeline
- createKey
- createKeyForService
- createLinkResource
- createOrUpdateResource
- createResource
- createServiceAccount
- delete
- deleteAllSynonyms
- deleteInvite
- deleteKey
- deleteLabelSet
- deleteServiceAccount
- feedback
- find
- generate
- generateJSON
- generateRandomQuestionAboutResource
- getConfiguration
- getEntities
- getEntitiesGroup
- getFullResource
- getFullResourceBySlug
- getInvites
- getKbEndpointAndZone
- getLabels
- getLearningSchema
- getResource
- getResourceBySlug
- getResourceFromData
- getServiceAccounts
- getSynonyms
- getTempToken
- getUsers
- hasResource
- inviteToKb
- listResources
- listenToAllNotifications
- listenToProcessingNotifications
- listenToResourceOperationNotifications
- modify
- processingStatus
- publish
- rephrase
- search
- setConfiguration
- setLabelSet
- setSynonyms
- stopListeningToNotifications
- suggest
- summarize
- tokens
- updateUsers
- upload
Constructors
constructor
• new WritableKnowledgeBox(nuclia
, account
, data
)
Parameters
Name | Type |
---|---|
nuclia | INuclia |
account | string |
data | IKnowledgeBoxCreation |
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:124
Properties
accountId
• accountId: string
Inherited from
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
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
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
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:845
description
• Optional
description: string
Implementation of
IWritableKnowledgeBox.description
Inherited from
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
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:21
nuclia
• Protected
nuclia: INuclia
Inherited from
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
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:29
slug
• slug: string
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:22
state
• Optional
state: KBStates
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:24
title
• title: string
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:23
uuid
• Optional
uuid: string
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:27
zone
• zone: string
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.models.ts:26
Accessors
activityMonitor
• get
activityMonitor(): ActivityMonitor
Returns
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
Implementation of
IWritableKnowledgeBox.taskManager
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:853
training
• get
training(): Training
Returns
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
Name | Type |
---|---|
query | string |
context? | ContextEntry [] |
features? | Features [] |
options? | ChatOptions |
Returns
Observable
<IErrorResponse
| Answer
>
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:285
▸ ask(query
, context?
, features?
, options?
, callback?
): Observable
<null
>
Parameters
Name | Type |
---|---|
query | string |
context? | ContextEntry [] |
features? | Features [] |
options? | ChatOptions |
callback? | (answer : IErrorResponse | Answer ) => void |
Returns
Observable
<null
>
Implementation of
Inherited from
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
Name | Type |
---|---|
files | FileList | 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
Name | Type |
---|---|
query | string |
options? | SearchOptions |
Returns
Observable
<Results
| IErrorResponse
>
Implementation of
Inherited from
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
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:607
createAgenticRAGPipeline
▸ createAgenticRAGPipeline(steps
): Pipeline
Parameters
Name | Type |
---|---|
steps | Steps |
Returns
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
Name | Type |
---|---|
saId | string |
expires | string |
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
Name | Type |
---|---|
data | ServiceAccountCreation |
expires | string |
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
Name | Type | Default value |
---|---|---|
link | LinkField | undefined |
metadata? | UserMetadata | undefined |
synchronous | boolean | true |
origin? | Origin | undefined |
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
Name | Type | Default value |
---|---|---|
data | ICreateResource | undefined |
synchronous | boolean | true |
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
Name | Type | Default value |
---|---|---|
resource | ICreateResource | undefined |
synchronous | boolean | true |
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
Name | Type |
---|---|
data | ServiceAccountCreation |
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
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
Name | Type |
---|---|
email | string |
Returns
Observable
<void
>
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:1137
deleteKey
▸ deleteKey(saId
, saKeyId
): Observable
<void
>
Parameters
Name | Type |
---|---|
saId | string |
saKeyId | string |
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
Name | Type |
---|---|
setId | string |
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
Name | Type |
---|---|
saId | string |
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
Name | Type | Default value |
---|---|---|
answerId | string | undefined |
good | boolean | undefined |
feedback | string | '' |
text_block_id? | string | undefined |
Returns
Observable
<void
>
Implementation of
IWritableKnowledgeBox.feedback
Inherited from
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
Name | Type | Default value |
---|---|---|
query | string | undefined |
features | Features [] | [] |
options? | SearchOptions | undefined |
Returns
Observable
<FindResults
| IErrorResponse
>
Implementation of
Inherited from
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
Name | Type | Default value |
---|---|---|
question | string | undefined |
context | string [] | [] |
Returns
Observable
<{ answer
: string
; cannotAnswer
: boolean
}>
Implementation of
IWritableKnowledgeBox.generate
Inherited from
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
Name | Type | Default value |
---|---|---|
question | string | undefined |
json_schema | object | undefined |
context | string [] | [] |
Returns
Observable
<{ answer
: object
; success
: boolean
}>
Implementation of
IWritableKnowledgeBox.generateJSON
Inherited from
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
Name | Type |
---|---|
resource | Resource |
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
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
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
Name | Type |
---|---|
groupId | string |
Returns
Observable
<EntitiesGroup
>
Implementation of
IWritableKnowledgeBox.getEntitiesGroup
Inherited from
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
Name | Type |
---|---|
uuid | string |
Returns
Observable
<Resource
>
Implementation of
IWritableKnowledgeBox.getFullResource
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:187
getFullResourceBySlug
▸ getFullResourceBySlug(slug
): Observable
<Resource
>
Parameters
Name | Type |
---|---|
slug | string |
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
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:688
getKbEndpointAndZone
▸ Protected
getKbEndpointAndZone(): Object
Returns
Object
Name | Type |
---|---|
endpoint | string |
zone | undefined | 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
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 ifResourceProperties.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
Name | Type | Default value |
---|---|---|
uuid | string | undefined |
show | ResourceProperties [] | undefined |
extracted | ExtractedDataTypes [] | [] |
Returns
Observable
<Resource
>
Implementation of
IWritableKnowledgeBox.getResource
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:176
getResourceBySlug
▸ getResourceBySlug(slug
, show?
, extracted?
): Observable
<Resource
>
Parameters
Name | Type | Default value |
---|---|---|
slug | string | undefined |
show | ResourceProperties [] | undefined |
extracted | ExtractedDataTypes [] | [] |
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
Name | Type |
---|---|
data | IResource |
Returns
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
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
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
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
Name | Type |
---|---|
slug | string |
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
Name | Type |
---|---|
data | InviteKbData |
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
Name | Type |
---|---|
page? | number |
size? | number |
Returns
Observable
<ResourceList
>
Implementation of
IWritableKnowledgeBox.listResources
Inherited from
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
Name | Type |
---|---|
data | Partial <IKnowledgeBox > |
Returns
Observable
<void
>
Implementation of
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:888
processingStatus
▸ processingStatus(cursor?
, scheduled?
, limit?
): Observable
<{ cursor
: string
; results
: ProcessingStatus
[] }>
Parameters
Name | Type |
---|---|
cursor? | string |
scheduled? | boolean |
limit? | number |
Returns
Observable
<{ cursor
: string
; results
: ProcessingStatus
[] }>
Implementation of
IWritableKnowledgeBox.processingStatus
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:821
publish
▸ publish(published
): Observable
<void
>
Publishes or unpublishes the Knowledge Box.
Parameters
Name | Type |
---|---|
published | boolean |
Returns
Observable
<void
>
Implementation of
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
Name | Type |
---|---|
question | string |
user_context? | string [] |
rephrase_prompt? | string |
Returns
Observable
<string
>
Implementation of
IWritableKnowledgeBox.rephrase
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:535
search
▸ 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
Name | Type | Default value |
---|---|---|
query | string | undefined |
features | Features [] | [] |
options? | SearchOptions | undefined |
Returns
Observable
<Results
| IErrorResponse
>
Implementation of
Inherited from
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:347
setConfiguration
▸ setConfiguration(config
): Observable
<void
>
Parameters
Name | Type |
---|---|
config | Object |
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
Name | Type |
---|---|
setId | string |
labelSet | LabelSet |
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
Name | Type |
---|---|
synonyms | Synonyms |
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
Name | Type | Default value |
---|---|---|
query | string | undefined |
inTitleOnly | boolean | false |
features | SuggestionFeatures [] | [] |
Returns
Observable
<Suggestions
| IErrorResponse
>
Implementation of
Inherited from
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
Name | Type |
---|---|
ressourceIds | string [] |
user_prompt? | string |
generative_model? | string |
Returns
Observable
<string
>
Implementation of
IWritableKnowledgeBox.summarize
Inherited from
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
Name | Type |
---|---|
text | string |
Returns
Observable
<SentenceToken
[]>
Implementation of
Inherited from
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
Name | Type |
---|---|
data | KbUserPayload |
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
Name | Type |
---|---|
file | File | FileWithMetadata |
TUS? | boolean |
metadata? | FileMetadata |
Returns
Observable
<UploadResponse
>
Implementation of
Defined in
libs/sdk-core/src/lib/db/kb/kb.ts:1048
▸ upload(buffer
, TUS?
, metadata?
): Observable
<UploadResponse
>
Parameters
Name | Type |
---|---|
buffer | ArrayBuffer |
TUS? | boolean |
metadata? | FileMetadata |
Returns
Observable
<UploadResponse
>