Utilizza l'applicazione

Per eseguire query su un Motore di ragionamento, devi prima avere un'istanza di Motore ragionamento. Puoi creare una nuova istanza oppure ottieni un'istanza esistente di un Motore di ragionamento. Il resto della sezione presuppone che tu abbia un'istanza di tipo remote_app.

Il comando seguente fornisce un elenco di schemi in Formato JSON che corrispondono alle operazioni del sistema Oggetto remote_app:

remote_app.operation_schemas()

Di seguito è riportato un esempio di elenco di schemi:

[
    {
        'description': 'Retrieves the exchange rate between two currencies on a specified date.\n'
        '\n'
        'Uses the Frankfurter API (https://api.frankfurter.app/) to obtain exchange rate data.\n'
        '\n'
        'Args:\n'
        '    currency_from: The base currency (3-letter currency code).\n'
        '        Defaults to "USD" (US Dollar).\n'
        '    currency_to: The target currency (3-letter currency code).\n'
        '        Defaults to "EUR" (Euro).\n'
        '    currency_date: The date for which to retrieve the exchange rate.\n'
        '        Defaults to "latest" for the most recent exchange rate data.\n'
        '        Can be specified in YYYY-MM-DD format for historical rates.\n'
        '\n'
        'Returns:\n'
        '    dict: A dictionary containing the exchange rate information.\n'
        '        Example: {"amount": 1.0, "base": "USD", "date": "2023-11-24",\n'
        '            "rates": {"EUR": 0.95534}}',
        'name': 'LangchainApp_query',
        'parameters': {
            'type': 'object',
            'properties': {
                'currency_from': {'type': 'string'},
                'currency_to': {'type': 'string'},
                'currency_date': {'type': 'string'},
            },
            'required': [],
        },
    }
]

Per eseguire query su Reasoning Engine, usa il metodo .query(). Per evitare ambiguità, specificare ogni argomento dal nome dell'argomento.

SDK Vertex AI per Python

Il comando seguente è un esempio di query di Reasoning Engine:

remote_app = reasoning_engines.ReasoningEngine("projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID")

response = remote_app.query(input="What is the exchange rate from US dollars to Swedish currency?")

REST

Il comando seguente è un esempio di query di Reasoning Engine:

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/reasoningEngines/REASONING_ENGINE_ID:query -d '{
  "input": {
    "input": "What is the exchange rate from US dollars to Swedish currency?"
  }
}'

La risposta alla query è una stringa simile all'output di un test di un'applicazione locale:

{"input": "What is the exchange rate from US dollars to Swedish currency?",
 # ...
 "output": "For 1 US dollar you will get 10.7345 Swedish Krona."}

Passaggi successivi