Я использую Dialogflow v1 на Android, но я хочу использовать V2 , потому что он предоставляет больше возможностей и потому что V1 будет устарелым 23 октября,2019. Однако я не могу интегрировать API V2 в мои коды .Вот код V1 :
private void initChatbot() {
final AIConfiguration config = new AIConfiguration("Here put Client access token",
AIConfiguration.SupportedLanguages.English,
AIConfiguration.RecognitionEngine.System);
aiDataService = new AIDataService(this, config);
customAIServiceContext = AIServiceContextBuilder.buildFromSessionId(uuid);// helps to create new session whenever app restarts
aiRequest = new AIRequest();
}
Вот код V2 :
private void initV2Chatbot() {
try {
InputStream stream = getResources().openRawResource(R.raw.test_agent_credentials);
GoogleCredentials credentials = GoogleCredentials.fromStream(stream);
String projectId = ((ServiceAccountCredentials)credentials).getProjectId();
SessionsSettings.Builder settingsBuilder = SessionsSettings.newBuilder();
SessionsSettings sessionsSettings = settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build();
sessionsClient = SessionsClient.create(sessionsSettings);
session = SessionName.of(projectId, uuid);
} catch (Exception e) {
e.printStackTrace();
}
}
Когда я написал этот код для V2 получил эту ошибку:
error: cannot find symbol variable test_agent_credentials
Я на самом деле не знаю, что такое test_agent_credentials и почему я должен его использовать.Кто-нибудь может сказать мне, где я должен поместить свой console.cloud.google Идентификатор ключа интеграции Dialogflow?
Вот Gradle:
apply plugin: 'com.android.application'
android {
buildToolsVersion "28.0.3"
compileSdkVersion 28
defaultConfig {
applicationId "com.tyagiabhinav.dialogflowchat"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
repositories {
mavenCentral()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// Java V2
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.apis:google-api-services-oauth2:v1-rev145-1.25.0'
// Dialogflow SDK dependencies
implementation 'ai.api:sdk:2.0.7@aar'
implementation 'ai.api:libai:1.6.12'
// Java V2
implementation 'com.google.cloud:google-cloud-dialogflow:0.67.0-alpha'
// for Remote Procedure Call to avoid "No functional channel service provider found" error while creating SessionsClient
implementation 'io.grpc:grpc-okhttp:1.15.1'
}