Skip to content

Commit

Permalink
samples: updated legacy field (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-loved-dreamer authored and Shabirmean committed Nov 15, 2022
1 parent b66ded7 commit ae30e45
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ static void detectIntentStream(String projectId, String audioFilePath, String se
System.out.format(
"Detected Intent: %s (confidence: %f)\n",
queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence());
System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText());
System.out.format(
"Fulfillment Text: '%s'\n",
queryResult.getFulfillmentMessagesCount() > 0
? queryResult.getFulfillmentMessages(0).getText()
: "Triggered Default Fallback Intent");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ public class DetectIntentWithLocation {

// DialogFlow API Detect Intent sample with text inputs.
public static Map<String, QueryResult> detectIntentWithLocation(
String projectId, String locationId, List<String> texts, String sessionId,
String projectId,
String locationId,
List<String> texts,
String sessionId,
String languageCode)
throws IOException, ApiException {
SessionsSettings sessionsSettings = SessionsSettings.newBuilder()
.setEndpoint(locationId + "-dialogflow.googleapis.com:443").build();
SessionsSettings sessionsSettings =
SessionsSettings.newBuilder()
.setEndpoint(locationId + "-dialogflow.googleapis.com:443")
.build();
Map<String, QueryResult> queryResults = Maps.newHashMap();
// Instantiates a client
try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
// Set the session name using the projectId (my-project-id), locationId and sessionId (UUID)
SessionName session = SessionName
.ofProjectLocationSessionName(projectId, locationId, sessionId);
SessionName session =
SessionName.ofProjectLocationSessionName(projectId, locationId, sessionId);
System.out.println("Session Path: " + session.toString());

// Detect intents for each text input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public void tearDown() throws IOException {
System.setOut(null);
}

@Rule
public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
@Rule public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);

@Test
public void testCreateDocument() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}.
*/
/** Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}. */
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class DetectIntentWithSentimentAndTextToSpeechIT {
Expand Down Expand Up @@ -78,8 +76,8 @@ public void testDetectIntentTexts() throws Exception {
@Test
public void testDetectIntentTextsWithLocation() throws Exception {
Map<String, com.google.cloud.dialogflow.v2beta1.QueryResult> queryResults =
DetectIntentWithLocation
.detectIntentWithLocation(PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE);
DetectIntentWithLocation.detectIntentWithLocation(
PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE);
com.google.cloud.dialogflow.v2beta1.QueryResult finalResult =
queryResults.get(TEXTS.get(TEXTS.size() - 1));
assertTrue(finalResult.getAllRequiredParamsPresent());
Expand Down

0 comments on commit ae30e45

Please sign in to comment.