Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Sample Code modified to modernized code and easy to understand #1175

Merged
merged 7 commits into from
May 24, 2023
Merged

Java Sample Code modified to modernized code and easy to understand #1175

merged 7 commits into from
May 24, 2023

Conversation

yoshioterada
Copy link
Member

This is the update pull request of
#1128

I closed the previous Pull Request #1128.

1 Modified getConfigValue()
1.1: local variable name from apiKey to propertyValue 1.2: Use NIO.2 libraries instead of old FileInputStream 1.3: modified Exception throw code

  1. Defined TEXT_TO_SUMMARIZE Instead of local variable definition, I defined static final field

  2. As a sample, I wrote non blocking code for Async operation Previously it was wrote as
    summarize.invokeAsync(TEXT_TO_SUMMARIZE).block() to subscribe()

  3. In order to show the result, I added following code to receive the result. try {
    TimeUnit.SECONDS.sleep(10);
    } catch (InterruptedException e) {
    LOGGER.warn("Interrupted : {}", e.getMessage());
    Thread.currentThread().interrupt();
    }

  4. Code Structure modified: I modified the code structure of both 'InlineFunctionExample.java' and 'InlineFunctionWithPreBuiltSkillExample.java' to be as similar as possible, making them easier to compare.

1 Modified getConfigValue()
1.1: local variable name from apiKey to propertyValue
1.2: Use NIO.2 libraries instead of old FileInputStream
1.3: modified Exception throw code

2. Defined TEXT_TO_SUMMARIZE
Instead of local variable definition, I defined static final field

3. As a sample, I wrote non blocking code for Async operation
Previously it was wrote as
summarize.invokeAsync(TEXT_TO_SUMMARIZE).block() to subscribe()

4. In order to show the result, I added following code to receive the result.
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
LOGGER.warn("Interrupted : {}", e.getMessage());
Thread.currentThread().interrupt();
}

5. Code Structure modified:
I modified the code structure of both 'InlineFunctionExample.java' and 'InlineFunctionWithPreBuiltSkillExample.java' to be as similar as possible, making them easier to compare.
Removed Invalid character
@lemillermicrosoft lemillermicrosoft added feature branch PR targeting a feature branch java Issue or PR regarding Java code labels May 23, 2023
Copy link
Member

@markwallace-microsoft markwallace-microsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Modified from sleep to CountDownLatch
Added countDown() to Error Status too
johnoliver
johnoliver previously approved these changes May 23, 2023
Added import for CountDownLatch and added try-catch statement
@markwallace-microsoft markwallace-microsoft merged commit 2223a8b into microsoft:experimental-java May 24, 2023
johnoliver pushed a commit to johnoliver/semantic-kernel that referenced this pull request Jun 5, 2024
…icrosoft#1175)

This is the update pull request of 
microsoft#1128

I closed the previous Pull Request microsoft#1128.

1 Modified getConfigValue()
1.1: local variable name from apiKey to propertyValue 1.2: Use NIO.2
libraries instead of old FileInputStream 1.3: modified Exception throw
code

2. Defined TEXT_TO_SUMMARIZE Instead of local variable definition, I
defined static final field

3. As a sample, I wrote non blocking code for Async operation Previously
it was wrote as
summarize.invokeAsync(TEXT_TO_SUMMARIZE).block() to subscribe()

4. In order to show the result, I added following code to receive the
result. try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
LOGGER.warn("Interrupted : {}", e.getMessage());
Thread.currentThread().interrupt();
}

5. Code Structure modified: I modified the code structure of both
'InlineFunctionExample.java' and
'InlineFunctionWithPreBuiltSkillExample.java' to be as similar as
possible, making them easier to compare.

---------

Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
johnoliver pushed a commit to johnoliver/semantic-kernel that referenced this pull request Jun 5, 2024
…icrosoft#1175)

This is the update pull request of 
microsoft#1128

I closed the previous Pull Request microsoft#1128.

1 Modified getConfigValue()
1.1: local variable name from apiKey to propertyValue 1.2: Use NIO.2
libraries instead of old FileInputStream 1.3: modified Exception throw
code

2. Defined TEXT_TO_SUMMARIZE Instead of local variable definition, I
defined static final field

3. As a sample, I wrote non blocking code for Async operation Previously
it was wrote as
summarize.invokeAsync(TEXT_TO_SUMMARIZE).block() to subscribe()

4. In order to show the result, I added following code to receive the
result. try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
LOGGER.warn("Interrupted : {}", e.getMessage());
Thread.currentThread().interrupt();
}

5. Code Structure modified: I modified the code structure of both
'InlineFunctionExample.java' and
'InlineFunctionWithPreBuiltSkillExample.java' to be as similar as
possible, making them easier to compare.

---------

Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature branch PR targeting a feature branch java Issue or PR regarding Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants