アプリケーションを使用する

Reasoning Engine をクエリするには、まず Reasoning Engine のインスタンスが必要です。Reasoning Engine の新しいインスタンスを作成するか、既存のインスタンスを取得します。このセクションの残りの部分では、インスタンスが remote_app であると仮定しています。

次のコマンドは、remote_app オブジェクトのオペレーションに対応するスキーマのリストを JSON 形式で提供します。

remote_app.operation_schemas()

スキーマのリストの例を次に示します。

[
    {
        'description': 'Retrieves the exchange rate between two currencies on a specified date.\n'
        '\n'
        'Uses the Frankfurter API (http://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': [],
        },
    }
]

Reasoning Engine をクエリするには、.query() メソッドを使用します。曖昧さを避けるため、各引数を引数名で指定します。

Vertex AI SDK for Python

次のコマンドは、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

次のコマンドは、Reasoning Engine クエリの例です。

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
http://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?"
  }
}'

クエリのレスポンスは、ローカル アプリケーション テストの出力に似た文字列になります。

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

次のステップ