Python#

Installation#

NGC currently hosts the Riva API Python wheel. You will need to provide an NGC API key to retrieve it. The key can be provided either through the variable NGC_API_KEY or as a configuration file (which is automatically generated by running ngc config set).

To access the Riva Quick Start package from NGC, run:

Data Center#

ngc registry resource download-version "nvidia/riva/riva_quickstart:2.3.0"
cd riva_quickstart_v2.3.0

Embedded#

ngc registry resource download-version "nvidia/riva/riva_quickstart_arm64:2.3.0"
cd riva_quickstart_arm64_v2.3.0

Install the Python Wheel#

pip install riva_api-2.3.0-py3-none-any.whl

Python Example#

The following steps show how you can integrate Riva AI Services into your own application using Python as an example. Full API documentation for all services and message types can be found in gRPC & Protocol Buffers.

With the Python bindings successfully installed, integrate the Riva services in your application. For example, to classify the intent of a query, add:

# required imports
import grpc
import riva_api.riva_nlp_pb2 as rnlp

# establish connection to Riva server and initialize client
channel = grpc.insecure_channel('localhost:50051')
server = rnlp.RivaLanguageUnderstandingStub(channel)

# make request
req = rnlp.AnalyzeIntentRequest(query="How is the weather today in New England")
resp = server.AnalyzeIntent(req)

print(resp.intent.class_name)