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

fix(deps): update dependencies to use google/genai #1021

Merged
merged 1 commit into from
Apr 10, 2025

Conversation

lacolaco
Copy link
Collaborator

This pull request includes significant changes to the tools/translator/translate.ts file and a dependency update in the package.json file. The primary focus is on updating the Google Generative AI library and refactoring the translation logic to accommodate this update.

Dependency update:

  • package.json: Updated the dependency from @google/generative-ai to @google/genai and changed the version to ^0.8.0.

Refactoring translation logic:

  • tools/translator/translate.ts: Replaced imports of GoogleGenerativeAI and GoogleAIFileManager with GoogleGenAI. Updated the class properties and constructor to use the new GoogleGenAI client.
  • tools/translator/translate.ts: Removed the detailed model configuration and chat session setup from the translate method. Instead, used the GoogleGenAI client to generate content directly.
  • tools/translator/translate.ts: Simplified the translation prompt and adjusted the response handling to accommodate the new API. Added a fallback for cases where no response is received.
  • tools/translator/translate.ts: Removed redundant input format instructions from the translation prompt.

@lacolaco lacolaco requested a review from Copilot April 10, 2025 14:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • package.json: Language not supported

await setTimeout(3000);
});

if (response.text) {
Copy link
Preview

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

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

The conditional check on response.text may inadvertently treat a valid empty string as a missing response. Consider explicitly checking for undefined or null to distinguish an empty but valid response from an error.

Suggested change
if (response.text) {
if (response.text !== undefined && response.text !== null) {

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@lacolaco lacolaco force-pushed the migrate-to-google-genai branch from 0bd43ba to c6cf9c5 Compare April 10, 2025 14:38
@lacolaco lacolaco force-pushed the migrate-to-google-genai branch from c6cf9c5 to 733cc3a Compare April 10, 2025 14:45
@lacolaco lacolaco merged commit 6940a9f into angular:main Apr 10, 2025
5 checks passed
@lacolaco lacolaco deleted the migrate-to-google-genai branch April 10, 2025 15:05
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.

1 participant