Nuclia Understanding
Nuclia automatically indexes your unstructured data from any internal and external source, providing optimized search results and generative answers. It can handle video and audio transcription, image content extraction, and document parsing.
The Nuclia Understanding API
supports the processing of unstructured data, including text, web pages, documents, and audio/video contents. It extracts all texts wherever it is (using speech-to-text or OCR when needed), it identifies entities, it also extracts metadata, embedded files (like images in a PDF), and web links. It also provides a summary of the content.
To use the Nuclia Understanding API
, you need to have a Nuclia
account. You can create one for free at https://nuclia.cloud, and then create a NUA key.
%pip install --upgrade --quiet protobuf
%pip install --upgrade --quiet nucliadb-protos
import os
os.environ["NUCLIA_ZONE"] = "<YOUR_ZONE>" # e.g. europe-1
os.environ["NUCLIA_NUA_KEY"] = "<YOUR_API_KEY>"
from langchain_community.tools.nuclia import NucliaUnderstandingAPI
nua = NucliaUnderstandingAPI(enable_ml=False)
You can push files to the Nuclia Understanding API using the push
action. As the processing is done asynchronously, the results might be returned in a different order than the files were pushed. That is why you need to provide an id
to match the results with the corresponding file.
nua.run({"action": "push", "id": "1", "path": "./report.docx"})
nua.run({"action": "push", "id": "2", "path": "./interview.mp4"})
You can now call the pull
action in a loop until you get the JSON-formatted result.
import time
pending = True
data = None
while pending:
time.sleep(15)
data = nua.run({"action": "pull", "id": "1", "path": None})
if data:
print(data)
pending = False
else:
print("waiting...")
You can also do it in one step in async
mode, you only need to do a push, and it will wait until the results are pulled:
import asyncio
async def process():
data = await nua.arun(
{"action": "push", "id": "1", "path": "./talk.mp4", "text": None}
)
print(data)
asyncio.run(process())