Skip to main content

Session

@nuclia/core


@nuclia/core / Session

Class: Session

Defined in: libs/sdk-core/src/lib/db/retrieval-agent/session.ts:17

Extends ReadableSession and implements all the write operations.

Extends​

Implements​

Constructors​

Constructor​

new Session(nuclia, kb, data): Session

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:198

Parameters​

nuclia​

INuclia

kb​

string

data​

IResource

Returns​

Session

Inherited from​

Resource.constructor

Properties​

computedmetadata?​

optional computedmetadata?: ComputedMetadata

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:10

Implementation of​

ISession.computedmetadata

Inherited from​

Resource.computedmetadata


created?​

optional created?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:14

Implementation of​

ISession.created

Inherited from​

Resource.created


data​

data: ResourceData = {}

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

Implementation of​

ISession.data

Inherited from​

Resource.data


extra?​

optional extra?: ExtraMetadata

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:11

Implementation of​

ISession.extra

Inherited from​

Resource.extra


fieldmetadata?​

optional fieldmetadata?: UserFieldMetadata[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:9

Implementation of​

ISession.fieldmetadata

Inherited from​

Resource.fieldmetadata


hidden?​

optional hidden?: boolean

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:20

Implementation of​

ISession.hidden

Inherited from​

Resource.hidden


icon?​

optional icon?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:6

Implementation of​

ISession.icon

Inherited from​

Resource.icon


id​

id: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:2

Implementation of​

ISession.id

Inherited from​

Resource.id


kb​

kb: string

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

Inherited from​

Resource.kb


last_account_seq?​

optional last_account_seq?: number

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:18

Implementation of​

ISession.last_account_seq

Inherited from​

Resource.last_account_seq


last_seqid?​

optional last_seqid?: number

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:17

Implementation of​

ISession.last_seqid

Inherited from​

Resource.last_seqid


metadata?​

optional metadata?: Metadata

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:7

Implementation of​

ISession.metadata

Inherited from​

Resource.metadata


modified?​

optional modified?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:15

Implementation of​

ISession.modified

Inherited from​

Resource.modified


origin?​

optional origin?: Origin

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:12

Implementation of​

ISession.origin

Inherited from​

Resource.origin


queue?​

optional queue?: "private" | "shared"

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:19

Implementation of​

ISession.queue

Inherited from​

Resource.queue


relations?​

optional relations?: Relation[] | null

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:21

Implementation of​

ISession.relations

Inherited from​

Resource.relations


security?​

optional security?: Security

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:13

Implementation of​

ISession.security

Inherited from​

Resource.security


slug?​

optional slug?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:3

Implementation of​

ISession.slug

Inherited from​

Resource.slug


summary?​

optional summary?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:5

Implementation of​

ISession.summary

Inherited from​

Resource.summary


thumbnail?​

optional thumbnail?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:16

Implementation of​

ISession.thumbnail

Inherited from​

Resource.thumbnail


title?​

optional title?: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:4

Implementation of​

ISession.title

Inherited from​

Resource.title


usermetadata?​

optional usermetadata?: UserMetadata

Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:8

Implementation of​

ISession.usermetadata

Inherited from​

Resource.usermetadata


uuid​

uuid: string

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:184

Inherited from​

Resource.uuid

Accessors​

kbPath​

Get Signature​

get kbPath(): string

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:187

Returns​

string

Inherited from​

Resource.kbPath


path​

Get Signature​

get path(): string

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

Returns​

string

Inherited from​

Resource.path

Methods​

appendMessages()​

appendMessages(field, messages): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:305

Appends messages to a conversation field

Parameters​

field​

string

messages​

Message[]

Returns​

Observable<void>

Inherited from​

Resource.appendMessages


ask()​

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:372

Retrieves a generative answer for the given query based on the results of a search operation performed on the resource.

Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

Returns​

Observable<Answer | IErrorResponse>

Inherited from​

Resource.ask

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:378

Retrieves a generative answer for the given query based on the results of a search operation performed on the resource.

Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

callback?​

(answer) => void

Returns​

Observable<null>

Inherited from​

Resource.ask


askToResource()​

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:404

Retrieves a generative answer for the given query using the entire resource as context (the resource's text might be shorten if too large).

Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

Returns​

Observable<Answer | IErrorResponse>

Inherited from​

Resource.askToResource

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:410

Retrieves a generative answer for the given query using the entire resource as context (the resource's text might be shorten if too large).

Parameters​
query​

string

context?​

ContextEntry[]

features?​

Features[]

options?​

ChatOptions

callback?​

(answer) => void

Returns​

Observable<null>

Inherited from​

Resource.askToResource


batchUpload()​

batchUpload(files): Observable<UploadStatus>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:339

Uploads a list of files in the resource. It automatically creates a new field for each file (named according to the filename). It uses the TUS protocol to upload the files.

Parameters​

files​

FileList | File[]

Returns​

Observable<UploadStatus>

Inherited from​

Resource.batchUpload


delete()​

delete(synchronous?): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:228

Deletes the resource.

Parameters​

synchronous?​

boolean = true

Returns​

Observable<void>

Inherited from​

Resource.delete


deleteField()​

deleteField(type, field, synchronous?): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:268

Deletes the field with the given type and id.

Parameters​

type​

FIELD_TYPE

field​

string

synchronous?​

boolean = false

Returns​

Observable<void>

Inherited from​

Resource.deleteField


find()​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:353

Performs a find operation in the resource.

Parameters​

query​

string

features?​

ResourceFeatures[] = []

options?​

SearchOptions

Returns​

Observable<FindResults | IErrorResponse>

Inherited from​

Resource.find


getClassifications()​

getClassifications(): Classification[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:120

Returns​

Classification[]

Inherited from​

Resource.getClassifications


getExtractedSummaries()​

getExtractedSummaries(): string[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:71

Returns the summaries generated by Nuclia for every resource fields.

Returns​

string[]

Inherited from​

Resource.getExtractedSummaries


getExtractedTexts()​

getExtractedTexts(): ExtractedText[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:78

Returns the texts generated by Nuclia for every resource fields.

Returns​

ExtractedText[]

Inherited from​

Resource.getExtractedTexts


getField()​

getField(type, field, show?, extracted?, page?): Observable<ResourceField>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:239

Parameters​

type​

FIELD_TYPE

field​

string

show?​

ResourceFieldProperties[] = ...

extracted?​

ExtractedDataTypes[] = ...

page?​

number | "last" | undefined

Returns​

Observable<ResourceField>

Inherited from​

Resource.getField


getFieldData()​

getFieldData<T>(type, fieldId): T | undefined

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:65

Type Parameters​

T​

T = IFieldData

Parameters​

type​

keyof ResourceData

fieldId​

string

Returns​

T | undefined

Inherited from​

Resource.getFieldData


getFields()​

getFields<T>(types?): T[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:56

Type Parameters​

T​

T = IFieldData

Parameters​

types?​

keyof ResourceData[] = ...

Returns​

T[]

Inherited from​

Resource.getFields


getFiles()​

getFiles(): CloudLink[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:85

Returns the files contained in the resource.

Returns​

CloudLink[]

Inherited from​

Resource.getFiles


getNamedEntities()​

getNamedEntities(): object

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:100

Returns the entities extracted from the resource.

Returns​

object

Inherited from​

Resource.getNamedEntities


getParagraphText()​

getParagraphText(fieldType, fieldId, paragraph, split?): string

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:161

Parameters​

fieldType​

FIELD_TYPE

fieldId​

string

paragraph​

Paragraph

split?​

string

Returns​

string

Inherited from​

Resource.getParagraphText


getPositionedNamedEntities()​

getPositionedNamedEntities(fieldType, fieldId): PositionedNER[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:137

Parameters​

fieldType​

keyof ResourceData

fieldId​

string

Returns​

PositionedNER[]

Inherited from​

Resource.getPositionedNamedEntities


getSentenceText()​

getSentenceText(fieldType, fieldId, sentence, split?): string

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:165

Parameters​

fieldType​

FIELD_TYPE

fieldId​

string

sentence​

Sentence

split?​

string

Returns​

string

Inherited from​

Resource.getSentenceText


getThumbnails()​

getThumbnails(): CloudLink[]

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:92

Returns the thumbnails generated by Nuclia for every resource fields.

Returns​

CloudLink[]

Inherited from​

Resource.getThumbnails


getThumbnailsUrl()​

getThumbnailsUrl(): Observable<string[]>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:259

Returns the thumbnails generated by Nuclia for every resource fields as blob: URLs.

Returns​

Observable<string[]>

Inherited from​

Resource.getThumbnailsUrl


modify()​

modify(data, synchronous?): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:221

Modifies the resource attributes.

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(
switchMap((knowledgeBox) => knowledgeBox.getResource('my-resource')),
switchMap((resource) => resource.modify({ description: 'new description' })),
)
.subscribe(() => {
console.log('resource modified');
});

Parameters​

data​

Partial<ICreateResource>

synchronous?​

boolean = true

Returns​

Observable<void>

Inherited from​

Resource.modify


reprocess()​

reprocess(): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:233

Triggers a resource reprocessing.

Returns​

Observable<void>

Inherited from​

Resource.reprocess


runTasks()​

runTasks(agent_ids?): Observable<TaskResults>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:437

Run tasks on the resource and return the results (the results are not stored within the resource).

Parameters​

agent_ids?​

string[]

Returns​

Observable<TaskResults>

Inherited from​

Resource.runTasks


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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:344

Performs a search operation in the resource (similar as find() but results are not nested).

Parameters​

query​

string

features?​

ResourceFeatures[] = []

options?​

SearchOptions

Returns​

Observable<IErrorResponse | Results>

Inherited from​

Resource.search


setField()​

setField(type, field, data): Observable<void>

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

Adds or updates a field in the resource.

Example:

nuclia.db
.getKnowledgeBox('my-account', 'my-kb')
.pipe(
switchMap((knowledgeBox) =>
knowledgeBox.getResource('my-resource').pipe(
switchMap((resource) =>
resource.setField(FIELD_TYPE.text, 'my-field', {
body: '*my text*',
format: 'MARKDOWN',
}),
),
),
),
)
.subscribe(() => {
console.log('field added');
});

Parameters​

type​

FIELD_TYPE

field​

string

data​

FileField | LinkField | TextField | ConversationField

Returns​

Observable<void>

Inherited from​

Resource.setField


setLabels()​

setLabels(fieldId, fieldType, paragraphId, labels): Observable<void>

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:428

Parameters​

fieldId​

string

fieldType​

string

paragraphId​

string

labels​

Classification[]

Returns​

Observable<void>

Inherited from​

Resource.setLabels


upload()​

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:325

Uploads a file in the resource. The field will be stored in the indicated field.

Example:

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

string

file​

File

TUS?​

boolean

metadata?​

FileMetadata

Returns​

Observable<UploadResponse>

Inherited from​

Resource.upload

Call Signature​

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

Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:326

Uploads a file in the resource. The field will be stored in the indicated field.

Example:

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

string

buffer​

ArrayBuffer

TUS?​

boolean

metadata?​

FileMetadata

Returns​

Observable<UploadResponse>

Inherited from​

Resource.upload