README
@nuclia/core • Docs
@nuclia/core / Agentic
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));
* ```
## Index
### Classes
- [Pipeline](classes/Pipeline.md)
### Interfaces
- [APIAction](interfaces/APIAction.md)
- [AskAction](interfaces/AskAction.md)
- [Event](interfaces/Event.md)
- [FindAction](interfaces/FindAction.md)
- [Output](interfaces/Output.md)
- [OutputArray](interfaces/OutputArray.md)
- [PredictAction](interfaces/PredictAction.md)
- [Step](interfaces/Step.md)
- [UserEventAction](interfaces/UserEventAction.md)
- [WebAction](interfaces/WebAction.md)
### Type Aliases
- [Action](type-aliases/Action.md)
- [Steps](type-aliases/Steps.md)