Skip to main content

IntelligenceService API

Intelligence Service is responsible with providing DataSapien's patented three tier on-edge intelligence approach. Intelligence Service allows access to:

  • Rules - these are first level of intelligence and static in nature
  • ML Models - conventional probabilistic models designed to work in a specific field
  • AI Models - Generative AI Models designed to work in a wide range of fields

To access IntelligenceService functions; get its instance from DataSapien object: DataSapien.getIntelligenceService().

Functions (JavaScript)

Public functions
Promise <boolean>
IntelligenceService.isModelFilesDownloaded(
name: string
)

Checks whether model files for the given model name are already downloaded.

Parameters

  • name : String – Model name (Orchestrator → Managed AI Models → Programmatic name)
Promise <void>
IntelligenceService.loadModel(
name: string,
modelParams?: ModelParams
)

Loads the specified model into memory with optional parameters.

Parameters

  • name : String – Model name (Orchestrator → Managed AI Models → Programmatic name)
  • modelParams?: ModelParams — Optional model configuration.
Promise <void>
IntelligenceService.unloadModel()

Unloads the currently loaded model and releases memory.

Parameters

  • None.

Promise <void>
IntelligenceService.downloadModelFiles(
name: string,
onProgress: (progress: number) => void
)

Downloads model files and optionally reports progress.

Parameters

  • name : String – Model name (Orchestrator → Managed AI Models → Programmatic name)
  • onProgress: (number) → void — progress callback.
Promise <void>
IntelligenceService.deleteModelFiles(
name: string
)

Deletes all downloaded local files for the given model.

Parameters

  • name : String – Model name (Orchestrator → Managed AI Models → Programmatic name)
Promise <string>
IntelligenceService.invokeModel(
name: string,
prompts: Prompt[],
inferenceParams?: InferenceParams,
onStream?: (chunk: string) => void
)

Sends prompts to the model and returns the generated output.

Parameters

  • name : String – Model name (Orchestrator → Managed AI Models → Programmatic name)
  • prompts: Prompt[] — Array of messages.
  • inferenceParams?: InferenceParams — Optional inference settings.
  • onStream?: (string) → void — Optional partial-output stream callback.
Promise <Prompt | null>
IntelligenceService.getMeDataPrompt()

Returns a generated Prompt object derived from MeData.

Parameters

  • None.

Promise <void>
IntelligenceService.syncRules()

Synchronizes rule definitions with the Orchestrator.

Parameters

  • None.
Promise <Rule[]>
IntelligenceService.getRules()

Returns all stored rules.

Parameters

  • None.
Promise <Rule | null>
IntelligenceService.getRule(
name: string
)

Retrieves a rule by its name.

Parameters

  • name: string — Rule name.
Promise <Rule | null>
IntelligenceService.runRule(
name: string
)

Evaluates a rule and returns its updated state.

Parameters

  • name: string — Rule name.
Promise <Rule[]>
IntelligenceService.runRules(
onlyOnInit: boolean
)

Evaluates multiple rules at once.

Parameters

  • onlyOnInit: boolean — If true, only initialization rules run.
Promise <void>
IntelligenceService.syncManagedAIModels()

Synchronizes the list of managed AI models with the Orchestrator.

Parameters

  • None.
Promise <ManagedAIModel[]>
IntelligenceService.getManagedAIModels()

Retrieves all managed AI models stored locally.

Parameters

  • None.
Promise <ManagedAIModel | null>
IntelligenceService.getManagedAIModel(
name: string
)

Retrieves a specific managed AI model by name.

Parameters

  • name: string — Model name (Orchestrator → Managed AI Models → Programmatic name).

Classes (JavaScript)

InferenceParams (JavaScript)

{
temperature?: number;
maxTokens?: number;
}

ModelParams (JavaScript)

{
nCtx?: number;
nBatchSize?: number;
nThreads?: number;
nGpuLayers?: number;
}

ManagedAIModel (JavaScript)

{
id: string;
name: string;
text: string;
vendor?: string | null;
description?: string | null;
downloadUrl: string;
imageUrl?: string | null;
multimodal?: boolean | null;
mmProjDownloadUrl?: string | null;
}

Rule (JavaScript)

{
id: string;
name: string;
text: string;
description?: string | null;
trigger: string;
condition: Filter;
action: Action;
}

Action (JavaScript)

{
type: string;
config?: ActionConfig | null;
}

ActionConfig (JavaScript)

{
id: string;
script?: Script | null;
event?: string | null;
title?: string | null;
message?: string | null;
}

Criteria (JavaScript)

{
field: string;
criteriaOperator: string;
value: string;
}

Filter (JavaScript)

{
type?: string | null;
filters?: Filter[] | null;
filter?: Filter | null;
criteria?: Criteria | null;
}

Prompt (JavaScript)

{
role: Role;
content: string;
attachment?: string | null;
}