Skip to main content

Upload contents

All examples assume you authenticated and defined a default Knowledge Box.

In case you want to overwrite or define a one time knowledgebox you should add on any command/function the url and api_key parameter.

Upload a file in a KnowledgeBox

Push a file to a Knowledge Box:

nuclia kb upload file --path=FILE_PATH
from nuclia import sdk
upload = sdk.NucliaUpload()
upload.file(path=FILE_PATH)

Upload a file in an existing resource

In case you want to upload a file inside a resource you can use:

nuclia kb upload file --path=FILE_PATH  --rid=RESOURCE_ID --field=FIELD_ID

In case that FIELD_ID is not defined filename will be used

Upload a remote file in a Knowledge Box

Streaming a file to a Knowledge Box from an external URL its easy as:

nuclia kb upload remote --origin=REMOTE_FILE_URL

Interpret tables in a file

When uploading a file, you can ask Nuclia to interpret tables in the file:

nuclia kb upload file --path=FILE_PATH --interpretTables
from nuclia import sdk
upload = sdk.NucliaUpload()
upload.file(path=FILE_PATH, interpretTables=True)

Upload a remote file in an existing resource

In case you want to stream a file inside a resource you can use:

nuclia kb upload remote --origin=REMOTE_FILE_URL --rid=RESOURCE_ID --field=FIELD_ID

In case that FIELD_ID is not defined filename will be used

Upload a text in a Knowledge Box

Push a text to a Knowledge Box:

nuclia kb upload text --path=FILE_PATH
from nuclia import sdk
upload = sdk.NucliaUpload()
upload.text(FILE_PATH)

Pass the text from standard input:

echo "This is a message" | nuclia kb upload text --stdin

Set a specific format (default is PLAIN):

nuclia kb upload text --path=FILE_PATH --format=MARKDOWN

Define a slug for the resource:

nuclia kb upload text --path=FILE_PATH --slug=SLUG

Pass origin or extra metadata:

nuclia kb upload text --path=FILE_PATH --origin='{"url":"https://somwhere.com"}' --extra='{"metadata":{"whatever":42}}'

Upload a web page in a Knowledge Box

Push a link to a Knowledge Box:

nuclia kb upload link --uri=THE_URI
from nuclia import sdk
upload = sdk.NucliaUpload()
upload.link(uri=THE_URI)

You can narrow down the indexed content by providing a CSS selector:

nuclia kb upload link --uri=THE_URI --selector="CSS_SELECTOR"

Upload a conversation

First, you need to provide a JSON file containing the conversation messages following this format:

[
{
"who": "ORIGIN_UUID",
"to": ["DESTINATION_UUID"],
"ident": "UNIQUE_IDENTIFIER",
"timestamp": "MESSAGE_DATETIME",
"content": {
"text": "MESSAGE",
"format": "MESSAGE_TYPE"
}
}
]
  • ORIGIN_UUID: Identification of the user who sent the message
  • DESTINATION_UUID: Identification of the users who received the message
  • UNIQUE_IDENTIFIER: Identification of the message, needs to be unique in the conversation
  • MESSAGE_DATETIME: Message date time in ISO format
  • MESSAGE_TYPE: Format of the message: 0 for PLAIN or 1 for HTML or MARKDOWN or RST

Example

Then, you can upload it with:

  • CLI:

    nuclia kb upload conversation --path=FILE
  • SDK:

    from nuclia import sdk
    upload = sdk.NucliaUpload()
    upload.conversation(path=FILE)