是否有可能创建传递聊天机器人模型的意图,使用Java的API从Java对话到AZURE机器人服务,]

问题描述 投票:0回答:1
    下面的代码用于创建意图并将其传递给Google。
  1. 我想使用Java + Azure bot平台实现相同的目的
  2. 我想建立一个框架,使用户能够传递意图以聊天显示在天蓝色的模型。
  3. 该框架将在Java中创建。
  4. 目前,我正在POC上工作,我将在其中将如下所示的意图传递给Azure。
  5. 如果可能的话,我想在天蓝色中也有与Google或Amazon相同的API。
  6. import com.google.api.gax.paging.Page; import com.google.auth.oauth2.ComputeEngineCredentials; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.dialogflow.v2.Intent; import com.google.cloud.dialogflow.v2.Intent.Message; import com.google.cloud.dialogflow.v2.Intent.Message.Text; import com.google.cloud.dialogflow.v2.IntentsClient; import com.google.cloud.dialogflow.v2.ProjectAgentName; import com.google.cloud.storage.Bucket; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; import com.google.common.collect.Lists; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; public class SankalpGCPChatBot { public static void main(String[] args) { List<String> trainingPhrasesParts = new ArrayList<>(); List<String> messageTexts = new ArrayList<>(); trainingPhrasesParts.add("What is your name?"); messageTexts.add("My name is Sankalp Bot."); String displayName = "SankalpTestIntent"; String projectId = "newagent-257c8"; try { createIntent(displayName, projectId, trainingPhrasesParts, messageTexts); } catch (Exception e) { e.printStackTrace(); } } static void authCompute() { GoogleCredentials credentials = ComputeEngineCredentials.create(); Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService(); System.out.println("Buckets:"); Page<Bucket> buckets = storage.list(); for (Bucket bucket : buckets.iterateAll()) { System.out.println(bucket.toString()); } } static void authImplicit() { Storage storage = StorageOptions.getDefaultInstance().getService(); System.out.println("Buckets:"); Page<Bucket> buckets = storage.list(); for (Bucket bucket : buckets.iterateAll()) { System.out.println(bucket.toString()); } } static void authExplicit(String jsonPath) throws IOException { GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath)) .createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform")); Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService(); System.out.println("Buckets:"); Page<Bucket> buckets = storage.list(); for (Bucket bucket : buckets.iterateAll()) { System.out.println(bucket.toString()); } } public static Intent createIntent( String displayName, String projectId, List<String> trainingPhrasesParts, List<String> messageTexts) throws Exception { try (IntentsClient intentsClient = IntentsClient.create()) { ProjectAgentName parent = ProjectAgentName.of(projectId); List<Intent.TrainingPhrase> trainingPhrases = new ArrayList<>(); for (String trainingPhrase : trainingPhrasesParts) { trainingPhrases.add( Intent.TrainingPhrase.newBuilder().addParts( Intent.TrainingPhrase.Part.newBuilder().setText(trainingPhrase).build()) .build()); } Message message = Message.newBuilder() .setText( Text.newBuilder() .addAllText(messageTexts).build() ).build(); Intent intent = Intent.newBuilder() .setDisplayName(displayName) .addMessages(message) .addAllTrainingPhrases(trainingPhrases) .build(); Intent response = intentsClient.createIntent(parent, intent); System.out.format("Intent created: %s\n", response); return response; } } }
下面的代码用于创建意图并将其传递给Google。我想使用java + azure bot平台实现相同的目标,我希望在该框架中用户能够将意图传递给聊天模型...
java azure chatbot luis azure-bot-service
1个回答
0
投票
截至此答案,Microsoft Bot Framework的Java版本当前处于预览状态(并且正在积极工作中)。您可以通过监视Github上的Botbuilder-Java存储库来跟踪更改。
© www.soinside.com 2019 - 2024. All rights reserved.