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

Add canonical textgen samples #196

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Add canonical textgen samples #196

merged 2 commits into from
Jul 3, 2024

Conversation

hsubox76
Copy link
Collaborator

@hsubox76 hsubox76 commented Jul 2, 2024

This is part of a larger project to convert samples to a standard format across all languages that can be used in devsite.

See internal doc: https://docs.google.com/spreadsheets/d/10X--DI0YPL3QfEMObe387rYg0t4-kuv33yKn2TIal7E/edit?resourcekey=0-kfy1Ry4YAZh6O4DltLjV9w&gid=0#gid=0

This PR addresses the first file ("text_generation") described in that doc which includes 9 examples. The code to be used in docs is delineated with [START] and [END] region tags marked with the canonical name for that sample.

Media files were taken from the live docs site (https://ai.google.dev/gemini-api/docs/vision?lang=node#technical-details-video) when available and from the Python repo when not available (e.g., audio sample): https://github.com/google-gemini/generative-ai-python/tree/main/third_party

I will delete and replace existing samples files in future PRs as the new samples for those cases are written.

@hsubox76 hsubox76 marked this pull request as ready for review July 2, 2024 20:31
@hsubox76 hsubox76 requested a review from DellaBitta July 2, 2024 20:32
@@ -0,0 +1,258 @@
/**
* @license
* Copyright 2023 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since these are new files I think they should have 2024 Copyrights.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


const result = await model.generateContentStream([prompt, imagePart]);

// print text as it comes in
Copy link
Collaborator

@DellaBitta DellaBitta Jul 2, 2024

Choose a reason for hiding this comment

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

Add a period. I think this repeats in a few places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@hsubox76
Copy link
Collaborator Author

hsubox76 commented Jul 3, 2024

Made some more changes after doing live tests:

  1. Removed web/ dir - doesn't seem like it's staying up to date, should be easy enough for a web developer to consume Node examples.
  2. Use a mediaPath path for all media in the samples.
  3. Upload video files for inference instead of trying to pass them inline.

@hsubox76 hsubox76 merged commit e23e99a into main Jul 3, 2024
8 checks passed
@hsubox76 hsubox76 deleted the ch-samples-textgen branch July 3, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants