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 basic support for Google AI models #868

Merged
merged 4 commits into from
Nov 17, 2024
Merged

Add basic support for Google AI models #868

merged 4 commits into from
Nov 17, 2024

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Nov 17, 2024

Introduce support for Google AI models, including configuration instructions and model pricing details. Update relevant functions and constants to accommodate the new provider.


  • 🚀 Google AI Models Integration: Added support for Google AI models through a new provider, enabling the use of various Gemini models (e.g., gemini-1.5-pro-002) and incorporating pricing and connection configurations for these models.
  • 🌟 Configuration Documentation Enhancement: Updated the documentation to include a new section about configuring Google AI models, detailing steps for obtaining API keys and setting up model identifiers.
  • 💡 Logprobs Handling: Adjusted the logic in executeChatSession to define logprobs more explicitly based on top_logprobs, ensuring proper usage conditions.
  • 💾 Caching Feature: Introduced a cache option vision_ask_image for vision models in the system scripts to potentially optimize performance.
  • 🏷️ User-Facing Type Extensions: Updated public API typings in prompt_template.d.ts to include the new Google AI models, making them accessible to end-users.
  • 💲 Cost Assessment: Enhanced cost calculation capabilities to include the Google AI models, allowing for more accurate cost tracking and rendering.

generated by pr-describe

Copy link

The changes in the pull request involve adding support for a new model provider, Google, across various files. The modifications ensure that the Google model provider is integrated into existing systems and is compatible with the current structure for handling different model providers. This includes updating constants, configurations, tool support, and costeable checks.

Overall, the changes seem to be well-integrated and consistent with the existing codebase structure, adding Google as a new model provider without disrupting the current functionality.

LGTM 🚀

generated by pr-review

Copy link

Investigator report

Summary of Root Cause

The failure in the GitHub Action run is due to a TypeScript error in the src/google.ts file. Specifically, the function starting at line 8 is expected to return a value but does not. This violates TypeScript's requirement that a function with a declared return type that is neither undefined, void, nor any must return a value.

Failing Code

// src/google.ts:8
8 ): Promise<LanguageModelInfo[]> {

Suggested Fix

Ensure that the function returns a Promise of LanguageModelInfo[]. I will provide a hypothetical patch based on typical fixes for such issues. You may need to adjust it according to the actual logic required.

--- a/src/google.ts
+++ b/src/google.ts
@@ -8,6 +8,7 @@
 ): Promise<LanguageModelInfo[]> {
   // Ensure the function body returns a Promise of LanguageModelInfo[]
+  return Promise.resolve([]);  // Placeholder return statement
 }

This patch adds a placeholder return Promise.resolve([]); to ensure that the function returns a Promise of the expected type. Please replace the placeholder with the actual logic required for your application.

generated by gai

Copy link

The information needed to perform the git diff between the failed run and the last successful run is missing. However, based on the available job log data, I will analyze the differences and potential root causes.

Analysis:

  1. Failed Run (ID: 11878475581):

    • Compiled TypeScript encountered a missing return value error in src/google.ts at line 8.
  2. Last Successful Run (ID: 11878458209):

    • Node version updated from v20 to v22.
    • No compilation errors noted.

Root Cause:

The failure was due to a TypeScript compilation error resulting from a missing return value in the src/google.ts file. The error did not occur in the previous successful run, suggesting that recent changes might have introduced this issue.

Suggested Patch:

To address this, ensure the function in src/google.ts has a proper return value:

// src/google.ts
function functionName(): ReturnType {
   // Implementation
   return value; // Ensure this return statement is correct
}

Report Summary:

  • Failed Run URL: Failed Run
  • Last Successful Run URL: Last Successful Run
  • Key Code Difference:
    • Introduced missing return statement in src/google.ts.
  • Patch:
    • Ensure functions in TypeScript files have appropriate return values to prevent compilation errors.

This analysis helps identify the issue, and applying the patch should rectify the problem.

generated by github-agent

Copy link

Detailed Report of the Build Failure

Summary of the Root Cause

The failure in the run with ID 11878475581 was due to a TypeScript compilation error in src/google.ts. The error message was:

src/google.ts:8:4 - error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.

This suggests that there was an oversight in ensuring that all code paths in a function return a value.

Code Diff Analysis

Unfortunately, the git diff command did not return any discernible code differences between the commits 87295cb05a028b4d40b62675df3e7bf4af409264 and 4a58f3479b8d4e6db934c4e6278b55d9e0c1bf47. This could mean that the file src/google.ts wasn't modified directly between these commits, or the diff was too large to be displayed.

Patch Proposal

To fix the TypeScript error, ensure that all functions in src/google.ts return a value as required by their declared types. Specifically, review the function starting on line 8 and ensure a return statement is present and correct.

HTML URLs to Relevant Information

This report synthesizes the failure's root cause and suggests a direct patch for resolution. Please ensure proper testing and validation after applying changes to avoid similar issues in future builds.

generated by github-one

if (!token) return undefined
if (token === PLACEHOLDER_API_KEY)
throw new Error("GOOGLE_API_KEY not configured")
const base = env.GOOGLE_API_BASE || GOOGLE_API_BASE

Choose a reason for hiding this comment

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

The base URL for the Google API is hardcoded. Consider making it configurable to enhance flexibility and adaptability.

generated by pr-review-commit hardcoded_url

@@ -163,12 +163,12 @@ export function traceFetchPost(
? "Bearer ***" // Mask Bearer tokens
: "***") // Mask other authorization headers
)
const cmd = `curl ${url} \\
const cmd = `curl "${url}" \\

Choose a reason for hiding this comment

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

The curl command is missing quotes around the URL, which could lead to issues if the URL contains special characters.

generated by pr-review-commit missing_quotes

@pelikhan pelikhan merged commit 0c51a90 into main Nov 17, 2024
10 checks passed
@pelikhan pelikhan deleted the googlegemini branch November 17, 2024 12:37
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