애플리케이션 사용

Reasoning Engine을 쿼리하려면 먼저 Reasoning Engine의 인스턴스가 필요합니다. Reasoning Engine의 새 인스턴스를 만들거나 기존 인스턴스를 가져올 수 있습니다. 이 섹션의 나머지 부분에서는 remote_app 인스턴스가 있다고 가정합니다.

다음 명령어는 JSON 형식으로 remote_app 객체의 작업에 해당하는 스키마 목록을 제공합니다.

remote_app.operation_schemas()

다음은 스키마 목록의 예시입니다.

[{'description': 'Retrieves the exchange rate between two currencies on a specified date.\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). Defaults to "USD" (US Dollar).\n'
                 '            currency_to: The target currency (3-letter currency code). Defaults to "EUR" (Euro).\n'
                 '            currency_date: The date for which to retrieve the exchange rate. Defaults to "latest" for the most recent exchange rate data. 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", "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() 메서드를 사용합니다. 모호성을 피하기 위해 각 인수를 해당 인수 이름으로 지정합니다.

Python용 Vertex AI SDK

다음 명령어는 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" \
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?"
  }
}'

쿼리 응답은 로컬 애플리케이션 테스트 출력과 비슷한 문자열입니다.

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

다음 단계