kodexa.assistant
Support for setting up and defining assistants that you can use in Kodexa
Submodules
Package Contents
Classes
An assistant is a rich-API to allow you to work with a reactive content store or with an end user |
|
The Assistant Context provides a way to interact with additional services and capabilities |
|
An assistant response allows you to provide the response from an assistant to a specific |
|
The wrapper for a pipeline that they assistant will request to be executed |
- class kodexa.assistant.Assistant
An assistant is a rich-API to allow you to work with a reactive content store or with an end user that is working with set of content
- process_event(event: kodexa.model.objects.BaseEvent, context: AssistantContext) AssistantResponse
The assistant will need to examine the event to determine if it wants to respond
The event will focus on a specific content object (that will be stored and available). Based on the metadata from the content object the assistant can then return a response which can include zero or more pipelines that it wishes to execute.
This pipelines will be run asynchronously and the result of the pipelines might well return as another event for the assistant
- Parameters
event – BaseEvent: the event being provided to the assistant
context – AssistantContext: the context for the assistant
- Returns
the response to the event
- Return type
- class kodexa.assistant.AssistantContext(metadata: AssistantMetadata, path_to_kodexa_metadata: str = 'kodexa.yml', stores=None, content_provider=None, extension_pack_util=None)
The Assistant Context provides a way to interact with additional services and capabilities while processing an event
- get_content(content_object: kodexa.model.ContentObject)
Puts a content object using the content provider
- Parameters
content_object – Content Object to put
- put_content(content_object: kodexa.model.ContentObject, content)
Puts the content object and its content based through the content provider
- Parameters
content_object – The content object
content – the content
- get_step(step: str, options=None)
Returns an instance of a step that is packaged in the same extension pack as the assistant, this allows you to build pipelines when you don’t know the owning organization
- Parameters
step (str) – The step name (ie. pdf-parser)
options – A dictionary of the options to create the step
- Returns
The step
- get_store(event: ContentEvent) kodexa.platform.client.DocumentStoreEndpoint
Get a document store for the event (based on the document family ID)
- Parameters
event – ContentEvent:
- Returns
The instance of the document store
- class kodexa.assistant.AssistantResponse(pipelines: List[AssistantPipeline] = None, text: Optional[str] = None, available_intents=None, output_document: kodexa.model.Document = None)
An assistant response allows you to provide the response from an assistant to a specific event.
- pipelines
The list of pipelines that you wish to have executed against the content object from the event
- text
The text that will be provided back to the user from the assistant
- available_intents
Any available intentions that the assistant will further respond to
- output_document
The output document, if the assistant has directly created one
- class kodexa.assistant.AssistantPipeline(pipeline, description=None, write_back_to_store: bool = False, data_store: Optional[kodexa.model.objects.Store] = None, taxonomies: Optional[List[kodexa.model.objects.Taxonomy]] = None, labels_to_apply: Optional[List[str]] = None)
The wrapper for a pipeline that they assistant will request to be executed
- pipeline
The pipeline to execute
- description
Optional description for the pipeline
- write_back_to_store
Should the document be written back to the store from which it was read
- data_store
Optionally the datastore that we want to extract the labelled content to
- taxonomies
Optionally a list of the taxonomies to use when extracting the labels
- labels_to_apply
Optionally a list of the labels to apply to the document when complete