microsoft / genaiscript

Automatable GenAI Scripting
https://microsoft.github.io/genaiscript/
MIT License
2.02k stars 116 forks source link

Add basic support for Google AI models #868

Closed pelikhan closed 1 week ago

pelikhan commented 1 week ago

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](https://github.com/microsoft/genaiscript/actions/runs/11878458205)
github-actions[bot] commented 1 week ago

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 :rocket:

generated by pr-review

github-actions[bot] commented 1 week ago

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

github-actions[bot] commented 1 week ago

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:

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

generated by github-agent

github-actions[bot] commented 1 week ago

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