Python API

Installation

  1. NGC currently hosts the Jarvis 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).

    Retrieve the Jarvis resources from NGC and enter the directory.

    ngc registry resource download-version "nvidia/jarvis/jarvis_quickstart:1.0.0-b.2"
    cd jarvis_quickstart_v1.0.0-b.2
    
  2. Install the jarvis-speech Python wheel locally.

    pip install jarvis_api-1.0.0-b.2-py3-none-any.whl
    

Python Example

The following steps show how you can integrate Jarvis 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.

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

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    # required imports
    import grpc
    import jarvis_api.jarvis_nlp_pb2 as jnlp
    
    # establish connection to Jarvis server and initialize client
    channel = grpc.insecure_channel('localhost:50051')
    server = jnlp.JarvisNLPStub(channel)
    
    # make request
    req = jnlp.AnalyzeIntentRequest(query="How is the weather today in New England")
    resp = server.AnalyzeIntent(req)
    
    print(resp.intent.class_name)