ここでは、
GeneXusAI モジュールを使用するために必要な設定の資格情報を取得する方法について説明します。
注: セキュリティ上の理由から、資格情報を設定ファイルまたは環境変数に追加し、そこから値を読み取ることを推奨します。コードに資格情報を貼り付けないでください。
資格情報 (事前に登録済み) を使用して AI プロバイダーにログインします。
ログインすると、Developer Console にリダイレクトされます。次に、ダッシュボードから、目的の AI タスク用のリソースを新規に作成するか、有効にします (サービスは名前でフィルタできます)。この際には、通常、作成するサービスに応じて、リソースの
名前、
リージョン、その他の
一般設定の指定を求められます (必要な情報は、使用するプロバイダーによって異なります)。
Alibaba |
China East 2 (cn-shanghai) |
Amazon |
米国東部 (バージニア北部、us-east-1) |
Baidu |
Beijing |
Google |
N/A |
IBM |
米国南部 (ダラス、us-south) |
Microsoft |
'West US' (ただし、動画は例外で 'West US 2' を使用) |
MLKit |
N/A |
SAP |
'Frankfurt' (production/trial) |
Tencent |
N/A |
リージョンを適切に設定しないと、
GXAI5000 エラーが発生し、'
Authentication Failed' メッセージが返されます。
次の表に、GeneXusAI で各タスクを使用する際に必要になるサービス資格情報 (名前) を示します。詳細については、プロシージャーの説明を参照してください。
モジュール |
タスク |
|
Audio |
SpeechToText |
Alibaba |
智能语音交互 |
Id、Key、SecretKey |
Amazon |
Transcribe |
Key、SecretKey |
Baidu |
百度语音 |
Id、Key、SecretKey |
Google |
Cloud Speech |
Key |
IBM |
Speech To Text |
Key |
Microsoft |
Speech |
Key |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
语音识别 |
Id、Key |
|
TextToSpeech |
Alibaba |
智能语音交互 |
Id、Key、SecretKey |
Amazon |
Polly |
Key、SecretKey |
Baidu |
百度语音 |
Id、Key、SecretKey |
Google |
Cloud Speech |
Key |
IBM |
Text To Speech |
Key |
Microsoft |
Speech |
Key |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
音合成 |
Id、Key |
|
カスタム |
Check |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Training |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
|
Delete |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Training |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
|
Deploy |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Training |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
|
Evaluate |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Training |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
|
Predict |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Prediction |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
|
Train |
Alibaba |
N/A |
- |
Amazon |
N/A |
- |
Baidu |
N/A |
- |
Google |
AutoML サービスアカウント JSON |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Custom Vision Training |
Key |
MLKit |
ML Kit API |
- |
SAP |
Sandbox |
Key |
Tencent |
N/A |
- |
|
Image |
Classify |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Rekognition |
Key、SecretKey |
Baidu |
视觉技术 |
Id、Key、SecretKey |
Google |
Cloud Vision |
Key |
IBM |
Visual Recognition |
Key |
Microsoft |
Computer Vision |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
Sandbox |
Key |
Tencent |
多标签识别 |
Id、Key |
|
DetectFaces |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Rekognition |
Key、SecretKey |
Baidu |
视觉技术 |
Id、Key、SecretKey |
Google |
Cloud Vision |
Key |
IBM |
Visual Recognition
(2019 年 9 月 12 日以降は非推奨) |
Key |
Microsoft |
Computer Vision |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
Sandbox |
Key |
Tencent |
人脸检测与分析 |
Id、Key |
|
DetectObjects |
Alibaba |
N/A |
- |
Amazon |
Rekognition |
Key、SecretKey |
Baidu |
N/A |
- |
Google |
Cloud Vision |
Key |
IBM |
N/A |
- |
Microsoft |
Computer Vision |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
N/A |
- |
Tencent |
物体识别 |
Id、Key |
|
DetectScene |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Rekognition |
Key、SecretKey |
Baidu |
视觉技术 |
Id、Key、SecretKey |
Google |
Cloud Vision |
Key |
IBM |
N/A |
- |
Microsoft |
Computer vision |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
N/A |
- |
Tencent |
场景识别 |
Id、Key |
|
OCR |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Rekognition |
Key、SecretKey |
Baidu |
视觉技术 |
Id、Key、SecretKey |
Google |
Cloud Vision |
Key |
IBM |
Visual Recognition
(2019 年 9 月 12 日以降は非推奨) |
Key |
Microsoft |
Computer vision |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
Sandbox |
Key |
Tencent |
通用OCR |
Id、Key |
|
Text |
DetectLanguage |
Alibaba |
N/A |
- |
Amazon |
Comprehend |
Key、SecretKey |
Baidu |
通用翻译 |
Id、Key、SecretKey |
Google |
Cloud Translation |
Key |
IBM |
Language Translator |
Key |
Microsoft |
Translator Text |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
Sandbox |
Key |
Tencent |
语种识别 |
Id、Key |
|
ExtractEntitites |
Alibaba |
N/A |
- |
Amazon |
Comprehend |
Key、SecretKey |
Baidu |
自然语言 |
Id、Key、SecretKey |
Google |
Cloud Natural Language |
Key |
IBM |
Natural Language Understanding |
Key |
Microsoft |
Text Analytics |
Key |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
专有名词 |
Id、Key |
|
KeyPhrases |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Comprehend |
Key、SecretKey |
Baidu |
自然语言 |
Id、Key、SecretKey |
Google |
Cloud Natural
Language |
Key |
IBM |
Natural Language Understanding |
Key |
Microsoft |
Text Analytics |
Key |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
N/A |
- |
|
SentimentAnalysis |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Comprehend |
Key、SecretKey |
Baidu |
自然语言 |
Id、Key、SecretKey |
Google |
Cloud Natural Language |
Key |
IBM |
Natural Language Understanding |
Key |
Microsoft |
Text Analytics |
Key |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
专有名词 |
Id、Key |
|
Translate |
Alibaba |
用户 |
Key、SecretKey |
Amazon |
Translate |
Key、SecretKey |
Baidu |
通用翻译 |
Id、Key、SecretKey |
Google |
Cloud Translation |
Key |
IBM |
Language Translator |
Key |
Microsoft |
Translator Text |
Key |
MLKit |
ML Kit API |
Id、Key |
SAP |
Sandbox |
Key |
Tencent |
文本翻译 |
Id、Key |
|
Video |
Analyze |
Alibaba |
内容安全 |
Id、Key、SecretKey |
Amazon |
N/A |
- |
Baidu |
视频内容分析 |
Key、SecretKey |
Google |
Video Intelligence |
Key |
IBM |
N/A |
- |
Microsoft |
Video Indexer |
Key、Account |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
N/A |
- |
|
Process |
Alibaba |
内容安全 |
Id、Key、SecretKey |
Amazon |
N/A |
- |
Baidu |
视频内容分析 |
Key、SecretKey |
Google |
Video Intelligence |
Key |
IBM |
N/A |
- |
Microsoft |
Video Indexer |
Key、Account |
MLKit |
ML Kit API |
- |
SAP |
N/A |
- |
Tencent |
N/A |
- |
|
|
|
|
サービスの作成が完了すると、プロバイダーにより、必要な資格情報が表示されます。また、これらの資格情報はプロバイダーの Web ページの Resource Management セクション (または同様のセクション) に格納され、後で必要に応じて再取得したり、再生成したりできます。資格情報の値を取得したら、対応する
Provider.Property フィールドに正しく設定します。
たとえば、
API キーの場合は、コードを次のように記述します:
&provider = new()
&provider.Name = !"{your_environment_name}"
&provider.Type = ProviderType. [ Amazon|Baidu|Google|IBM|Microsoft|MLKit|SAP|Tencent ]
&providerProperty= new()
&providerProperty.key = GeneXusAI.Configuration.PropertyKey.Key
&providerProperty.Value = !"{your_api_key_value}" // LINE (*)
&provider.Properties.Add(&providerProperty)
「"{your_api_key_value}"」の値をコードに貼り付けないでください。ベストプラクティスは、設定ファイルまたは環境変数から値を読み取ることです。たとえば、次の構造で
provider.settings.json という JSON ファイルを作成します:
{
"name":"{your_provider_name}",
"key":"{your_api_key_value}"
}
次に、このファイルを File オブジェクトとしてナレッジベースに添付し、抽出プロパティを設定し (適切な場所にコピーするため)、次のように資格情報を読み取ります:
&settingFile.Source = !"path/to/provider.settings.json"
&jsonString = &file.ReadAllText() //構成ファイルを読み取り
&jsonProperties.FromJson(&jsonString) // JSON 構造をパース
&myApiKey = &jsonProperties.Get(!"key") // "{your_api_key_value}" の値を取得
最後に、
LINE (*) を次の文に置き換えます。
&providerProperty.Value = &myApiKey
AI タスクを実行できます。
- SAP Leonardo については、各 API サービスで [ Show API Key ] オプションを使用してサンドボックスキーを取得できます。このキーは、どのサービスを選択するかに関係なく同じになります。そのため、API キーはすべてのサービスで同じになることから、このドキュメントでは、どのサービスを使用する必要があるか (たとえば、GeneXusAI.Image.OCR タスクを使用する場合は Inference Service for Optical Character Recognition (OCR)) については特に指定されていません。
- MS Cognitive Services については、新しいリソースを作成する際に必ず West US を選択してください。ただし、Video モジュールを使用する場合は例外です。その場合は、次の手順に従ってください。
1) Video Indexer ポータルにログインします。
2) [ Azure への接続 ] ボタンをクリックします。
3.a) [ West US 2 ] を選択します。
3.b) 必要なリソースグループがまだない場合は新規に作成します。
3.c) [ 接続 ] ボタンをクリックします (このプロセスにはしばらく時間がかかる場合があります)。
4) 手順 (3) で作成したユーザーのアカウント ID を取得します。
5) 製品のオーソライズページに移動し、API の使用をオーソライズします。
6) ユーザープロファイルから API キーを取得します。
- IBM Watson を使用する場合は、新しいリソースを作成する際に必ず us-south リージョン (ダラス) を選択してください。ユーザー名/パスワードによる認証が可能なサービスは、下位互換性のために維持されます (新しいインスタンスではユーザー名/パスワードではなくキーが提供されます)。
- Google Cloud AI を使用する場合は、単一のプロジェクトを作成し、使用する各 API を有効にする必要があります。その後、 [ Credentials ] オプションで、有効にしたすべての API 用の API キーを作成できます。
このドキュメントは、
GeneXus 16 以降に適用されます。