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

OCI Native Generative AI Example #264

Merged
merged 2 commits into from
May 30, 2024
Merged

OCI Native Generative AI Example #264

merged 2 commits into from
May 30, 2024

Conversation

bhoran
Copy link
Collaborator

@bhoran bhoran commented May 8, 2024

An example of using the OCI generative AI service, using the native image maven plugin

@bhoran bhoran requested a review from fniephaus May 8, 2024 14:57
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 8, 2024
@bhoran bhoran self-assigned this May 8, 2024
Copy link
Member

@fniephaus fniephaus left a comment

Choose a reason for hiding this comment

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

Thanks for the demo. LGTM so far, left a couple of minor comments. I'll approve when there's a workflow that tests the demo 😉

native-oci-generative-ai/README.md Show resolved Hide resolved
native-oci-generative-ai/README.md Outdated Show resolved Hide resolved

Edit the contents of [_GenerateTextExample.java_](./src/main/java/com/oracle/labs/GenerateTextExample.java) as follows:

1. Update the value of the static variable `CONFIG_PROFILE` with the name of your OCI profile name.
Copy link
Member

Choose a reason for hiding this comment

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

These could just be Java properties or environment variables, which can then be set at run-time (or frozen into the executable via build-time init if you insist)?

native-oci-generative-ai/pom.xml Outdated Show resolved Hide resolved
native-oci-generative-ai/pom.xml Show resolved Hide resolved
Comment on lines +116 to +113
.prompt(
"Generate a job description for a data visualization expert with the following three qualifications only:\n1) At least 5 years of data visualization expert\n2) A great eye for details\n3) Ability to create original visualizations")
Copy link
Member

Choose a reason for hiding this comment

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

Use a text block (and, unlike me, an IDE for formatting 😉)

Suggested change
.prompt(
"Generate a job description for a data visualization expert with the following three qualifications only:\n1) At least 5 years of data visualization expert\n2) A great eye for details\n3) Ability to create original visualizations")
.prompt("""
Generate a job description for a data visualization expert with the following three qualifications only:
1) At least 5 years of data visualization expert
2) A great eye for details
3) Ability to create original visualizations")
""")

Comment on lines +119 to +117
.temperature((double) 0.5)
.frequencyPenalty((double) 1)
.topP((double) 0.75)
Copy link
Member

Choose a reason for hiding this comment

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

Use double literals?

Suggested change
.temperature((double) 0.5)
.frequencyPenalty((double) 1)
.topP((double) 0.75)
.temperature(0.5d)
.frequencyPenalty(1.0d)
.topP(0.75d)

.generateTextDetails(generateTextDetails)
.build();
GenerateTextResponse generateTextResponse = generativeAiInferenceClient.generateText(generateTextRequest);
System.out.println(generateTextResponse.toString());
Copy link
Member

Choose a reason for hiding this comment

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

This should just do the right thing, even if generateTextResponse can ever be null (not sure it can):

Suggested change
System.out.println(generateTextResponse.toString());
System.out.println(generateTextResponse);

olyagpl
olyagpl previously approved these changes May 10, 2024
@bhoran
Copy link
Collaborator Author

bhoran commented May 10, 2024

@fniephaus -- I've created the workflow and it passes.
I haven't updated the source as you suggested because I want it to closely match the source that is produced by https://docs.oracle.com/iaas/Content/generative-ai/use-playground-generate.htm.

fniephaus
fniephaus previously approved these changes May 10, 2024
Copy link
Member

@fniephaus fniephaus left a comment

Choose a reason for hiding this comment

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

LGTM

- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21.0.2'
Copy link
Member

Choose a reason for hiding this comment

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

Can we also test this against latest-ea to ensure updates don't break the demo? Also, the latest JDK 21 release is 21.0.3.

native-oci-generative-ai/pom.xml Outdated Show resolved Hide resolved
native-oci-generative-ai/pom.xml Show resolved Hide resolved
@fniephaus
Copy link
Member

I've created the workflow and it passes.
I haven't updated the source as you suggested because I want it to closely match the source that is produced by https://docs.oracle.com/iaas/Content/generative-ai/use-playground-generate.htm.

@bhoran great, thanks! and yes, that makes sense.

Co-Authored-By: Fabio Niephaus <fabio.niephaus@oracle.com>
@olyagpl olyagpl self-requested a review May 29, 2024 16:58
olyagpl
olyagpl previously approved these changes May 29, 2024
Co-authored-by: Fabio Niephaus <fabio.niephaus@oracle.com>
Copy link
Member

@fniephaus fniephaus left a comment

Choose a reason for hiding this comment

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

LGTM

@bhoran bhoran merged commit 6228f81 into master May 30, 2024
3 checks passed
@bhoran bhoran deleted the bh/generative-ai branch May 30, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants