Skip to main content

@nuclia/core / Exports / Agentic

Namespace: Agentic

Agentic RAG

The Agentic class allows to define a pipeline of actions to be executed in sequence. Each action can be of different types:

  • predict: ask a question to the LLM model and extract information in a JSON response
  • find: search for a set of results based on a query
  • ask: perform a Nuclia RAG call based on a query
  • web: fetch a web page and extract information based on CSS selectors
  • api: call an API and extract information based on a JSON path
  • user: wait for a user entry

Example:

  const agentic = nucliaApi.knowledgeBox.createAgenticRAGPipeline({
START: {
action: {
type: 'predict',
query: 'Does the following question refers to a specific reference document? QUESTION: "{{query}}"',
outputs: {
reference: {
type: 'string',
description: 'The name of the reference document if any, and just an empty string if none.',
},
},
},
next: [
{ stepId: 'finddoc', if: '`{{START.reference}}` !== ""' },
{ stepId: 'domain', if: '`{{START.reference}}` == ""' },
],
},
finddoc: {
action: {
type: 'find',
query: '{{START.reference}}',
features: [Search.Features.KEYWORD],
options: {
fields: ['a/title'],
},
},
next: [{ stepId: 'domain' }],
},
domain: {
action: {
type: 'predict',
query:
'What is the domain of the question among the following categories: "ART", "SCIENCE" ? QUESTION: "{{query}}"',
outputs: {
domain: { type: 'string', description: 'The domain of the question.' },
},
},
next: [{ stepId: 'answer' }],
},
answer: {
action: {
type: 'ask',
query: '{{query}}',
options: {
filters: ['/classification.labels/domain/{{domain.domain}}'],
resource_filters: ['{{finddoc.results.resources.[0].id}}'],
},
},
},
});
agentic
.run({
query,
})
.subscribe((res) => console.log(agentic.context));
agentic.status.subscribe((res) => console.log(res));
* ```

## Table of contents

### Classes

- [Pipeline](../classes/Agentic.Pipeline.md)

### Interfaces

- [APIAction](../interfaces/Agentic.APIAction.md)
- [AskAction](../interfaces/Agentic.AskAction.md)
- [Event](../interfaces/Agentic.Event.md)
- [FindAction](../interfaces/Agentic.FindAction.md)
- [Output](../interfaces/Agentic.Output.md)
- [OutputArray](../interfaces/Agentic.OutputArray.md)
- [PredictAction](../interfaces/Agentic.PredictAction.md)
- [Step](../interfaces/Agentic.Step.md)
- [UserEventAction](../interfaces/Agentic.UserEventAction.md)
- [WebAction](../interfaces/Agentic.WebAction.md)

### Type Aliases

- [Action](Agentic.md#action)
- [Steps](Agentic.md#steps)

## Type Aliases

### Action

Ƭ **Action**: [`PredictAction`](../interfaces/Agentic.PredictAction.md) \| [`FindAction`](../interfaces/Agentic.FindAction.md) \| [`AskAction`](../interfaces/Agentic.AskAction.md) \| [`WebAction`](../interfaces/Agentic.WebAction.md) \| [`APIAction`](../interfaces/Agentic.APIAction.md) \| [`UserEventAction`](../interfaces/Agentic.UserEventAction.md)

#### Defined in

[libs/sdk-core/src/lib/db/search/agentic.ts:134](https://github.com/nuclia/frontend/blob/0fc639c2/libs/sdk-core/src/lib/db/search/agentic.ts#L134)

___

### Steps

Ƭ **Steps**: `Object`

#### Index signature

▪ [stepId: `string`]: [`Step`](../interfaces/Agentic.Step.md)

#### Defined in

[libs/sdk-core/src/lib/db/search/agentic.ts:148](https://github.com/nuclia/frontend/blob/0fc639c2/libs/sdk-core/src/lib/db/search/agentic.ts#L148)