Session
@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
kb
string
data
Returns
Session
Inherited from
Properties
computedmetadata?
optionalcomputedmetadata?:ComputedMetadata
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:10
Implementation of
ISession.computedmetadata
Inherited from
created?
optionalcreated?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:14
Implementation of
ISession.created
Inherited from
data
data:
ResourceData={}
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:45
Implementation of
ISession.data
Inherited from
extra?
optionalextra?:ExtraMetadata
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:11
Implementation of
ISession.extra
Inherited from
fieldmetadata?
optionalfieldmetadata?:UserFieldMetadata[]
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:9
Implementation of
ISession.fieldmetadata
Inherited from
hidden?
optionalhidden?:boolean
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:20
Implementation of
ISession.hidden
Inherited from
icon?
optionalicon?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:6
Implementation of
ISession.icon
Inherited from
id
id:
string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:2
Implementation of
ISession.id
Inherited from
kb
kb:
string
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:183
Inherited from
last_account_seq?
optionallast_account_seq?:number
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:18
Implementation of
ISession.last_account_seq
Inherited from
last_seqid?
optionallast_seqid?:number
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:17
Implementation of
ISession.last_seqid
Inherited from
metadata?
optionalmetadata?:Metadata
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:7
Implementation of
ISession.metadata
Inherited from
modified?
optionalmodified?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:15
Implementation of
ISession.modified
Inherited from
origin?
optionalorigin?:Origin
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:12
Implementation of
ISession.origin
Inherited from
queue?
optionalqueue?:"private"|"shared"
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:19
Implementation of
ISession.queue
Inherited from
relations?
optionalrelations?:Relation[] |null
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:21
Implementation of
ISession.relations
Inherited from
security?
optionalsecurity?:Security
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:13
Implementation of
ISession.security
Inherited from
slug?
optionalslug?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:3
Implementation of
ISession.slug
Inherited from
summary?
optionalsummary?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:5
Implementation of
ISession.summary
Inherited from
thumbnail?
optionalthumbnail?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:16
Implementation of
ISession.thumbnail
Inherited from
title?
optionaltitle?:string
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:4
Implementation of
ISession.title
Inherited from
usermetadata?
optionalusermetadata?:UserMetadata
Defined in: libs/sdk-core/src/lib/db/resource/resource.models.ts:8
Implementation of
ISession.usermetadata
Inherited from
uuid
uuid:
string
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:184
Inherited from
Accessors
kbPath
Get Signature
get kbPath():
string
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:187
Returns
string
Inherited from
path
Get Signature
get path():
string
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:191
Returns
string
Inherited from
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
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?
features?
Features[]
options?
Returns
Observable<Answer | IErrorResponse>
Inherited from
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?
features?
Features[]
options?
callback?
(answer) => void
Returns
Observable<null>
Inherited from
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?
features?
Features[]
options?
Returns
Observable<Answer | IErrorResponse>
Inherited from
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?
features?
Features[]
options?
callback?
(answer) => void
Returns
Observable<null>
Inherited from
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
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
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
string
synchronous?
boolean = false
Returns
Observable<void>
Inherited from
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?
Returns
Observable<FindResults | IErrorResponse>
Inherited from
getClassifications()
getClassifications():
Classification[]
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:120
Returns
Inherited from
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
Inherited from
getField()
getField(
type,field,show?,extracted?,page?):Observable<ResourceField>
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:239
Parameters
type
field
string
show?
ResourceFieldProperties[] = ...
extracted?
ExtractedDataTypes[] = ...
page?
number | "last" | undefined
Returns
Observable<ResourceField>
Inherited from
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
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
getFiles()
getFiles():
CloudLink[]
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:85
Returns the files contained in the resource.
Returns
Inherited from
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
getParagraphText()
getParagraphText(
fieldType,fieldId,paragraph,split?):string
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:161
Parameters
fieldType
fieldId
string
paragraph
split?
string
Returns
string
Inherited from
getPositionedNamedEntities()
getPositionedNamedEntities(
fieldType,fieldId):PositionedNER[]
Defined in: libs/sdk-core/src/lib/db/resource/resource.ts:137
Parameters
fieldType
keyof ResourceData
fieldId
string
Returns
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
fieldId
string
sentence
split?
string
Returns
string
Inherited from
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
Inherited from
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
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
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
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
search()
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?
Returns
Observable<IErrorResponse | Results>
Inherited from
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
string
data
FileField | LinkField | TextField | ConversationField
Returns
Observable<void>
Inherited from
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
Returns
Observable<void>
Inherited from
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?
Returns
Observable<UploadResponse>
Inherited from
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?
Returns
Observable<UploadResponse>