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

Update google params transform #91

Merged
merged 9 commits into from
Jan 14, 2025
Merged

Update google params transform #91

merged 9 commits into from
Jan 14, 2025

Conversation

roodboi
Copy link
Contributor

@roodboi roodboi commented Jan 13, 2025

Important

Enhances Google Gemini API support in llm-polyglot with grounding, safety settings, session management, and updates documentation and tests.

  • Behavior:
    • Enhanced Google Gemini API support in llm-polyglot with grounding, safety settings, session management, and more.
    • Removed unsupported additionalProperties from function parameters in Gemini requests.
  • Documentation:
    • Updated google.mdx and README.md to reflect new features and usage examples.
  • Code:
    • Modified index.ts in src/providers/google to handle new features and clean schemas.
    • Updated index.js to reorder imports for documentation files.
  • Testing:
    • Added comprehensive tests in google.test.ts for new features like grounding and session management.

This description was created by Ellipsis for aa87da3. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
island-ai-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 3:42am

Copy link

changeset-bot bot commented Jan 13, 2025

🦋 Changeset detected

Latest commit: aa87da3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
llm-polyglot Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@roodboi roodboi changed the title Update params transform Update google params transform Jan 13, 2025
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on ff40a16 in 22 seconds

More details
  • Looked at 23 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. public-packages/llm-client/src/providers/google/index.ts:60
  • Draft comment:
    The change from 'additionalProperties' to '_additionalProperties' is not explained. Ensure '_additionalProperties' is correctly set elsewhere.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_PHK80DNdMOHACdt1


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 199439a in 1 minute and 38 seconds

More details
  • Looked at 63 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. public-packages/llm-client/src/providers/google/index.ts:59
  • Draft comment:
    The cleanSchema function does not handle nested additionalProperties within properties or items. Consider recursively cleaning these nested structures as well.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The code clearly shows recursive handling of nested structures through the cleanSchema function. When it encounters nested properties or items, it calls cleanSchema again which will remove additionalProperties at that level. The comment appears to be incorrect in its assessment.
    Could there be some edge cases or specific nested structures that the current implementation doesn't handle? The recursive approach seems sound but maybe there's something subtle I'm missing.
    No, the implementation is thorough - it handles both properties and items recursively, and the destructuring of additionalProperties happens at each level. The comment is simply incorrect.
    Delete this comment as it incorrectly claims the code doesn't handle nested structures, when it clearly does through recursive calls to cleanSchema.

Workflow ID: wflow_yhL0R1ODsm0KWDwm


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 2cb5349 in 50 seconds

More details
  • Looked at 1107 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. apps/www/.source/index.js:6
  • Draft comment:
    The reordering of import statements is purely organizational and does not affect functionality. Ensure this aligns with your project's style guidelines.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The import statements in the index.js file have been reordered, but the change seems to be purely organizational. This doesn't affect functionality but could improve readability.
2. public-packages/llm-client/src/providers/google/index.ts:160
  • Draft comment:
    The createGenerationConfig function correctly maps parameters from GoogleChatCompletionParams to GenerationConfig. This ensures proper configuration for chat sessions.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The createGenerationConfig function in index.ts is correctly mapping parameters from GoogleChatCompletionParams to GenerationConfig. This ensures that the configuration is properly set for the chat session.
3. public-packages/llm-client/src/providers/google/index.ts:178
  • Draft comment:
    The transformHistory function correctly filters out system messages and transforms the remaining messages into the required format for Google's API.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The transformHistory function in index.ts is correctly filtering out system messages and transforming the remaining messages into the required format. This is important for maintaining the correct chat history format for Google's API.
4. public-packages/llm-client/src/providers/google/index.ts:223
  • Draft comment:
    The getChatSession function effectively manages chat sessions, including caching and session reuse, which is crucial for performance and resource management.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The getChatSession function in index.ts is responsible for managing chat sessions, including caching and session reuse. This is crucial for performance and resource management.
5. public-packages/llm-client/src/providers/google/index.ts:292
  • Draft comment:
    The transformResponse function effectively converts API responses into a structured format, including grounding metadata and tool calls, which is essential for detailed responses.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The transformResponse function in index.ts is responsible for converting the API response into a format that includes grounding metadata and tool calls. This is essential for providing detailed and structured responses.

Workflow ID: wflow_IAIYu20YQlFWbgSM


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

* Gets system instructions from messages
*/
private getSystemInstructions(messages: GoogleChatCompletionParams["messages"]): string {
const systemMessages = messages.filter(message => message.role === "system")
Copy link
Collaborator

Choose a reason for hiding this comment

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

could use reduce to only use one pass for really long conversations but perf is prob negligible in the vast majority of cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah fair - this was actually just form before splitting things up a bit, but google does support system messages so next push will bring that in and remove this entirely

): ExtendedCompletionGoogle | ExtendedCompletionChunkGoogle {
const responseText = responseDataChunk.text()
const toolCalls =
responseDataChunk.candidates?.[0]?.content?.parts?.flatMap(part =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

worth null checking candidates?

let contentWithGrounding = responseText
let sources: Array<{ url: string; title: string }> = []

if (groundingMetadata) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥

id: `chatcmpl-${Math.random().toString(36).slice(2)}`,
object: stream ? "chat.completion.chunk" : "chat.completion",
created: Date.now(),
model: "gemini-pro",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe 1.0 pro is deprecated, but we should be using the dynamically passed model regardless no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeaha this was what was there - - we actualyl dont have the passed in params in this point so its hard coded, but yeah it should be the user provided param not this value

Copy link
Collaborator

Choose a reason for hiding this comment

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

😶‍🌫️ somehow that was missed on the original PR my b

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on dbaecbf in 45 seconds

More details
  • Looked at 819 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. public-packages/llm-client/src/providers/google/index.ts:176
  • Draft comment:
    message.content.toString() can be simplified to message.content since it's already a string.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The transformHistory function is mapping message.content to text using toString(). This is unnecessary since message.content is already a string. This can be simplified by removing toString().

Workflow ID: wflow_FZro9E5MUFDTMSdF


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on c58584a in 21 seconds

More details
  • Looked at 65 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. public-packages/llm-client/src/providers/google/index.ts:278
  • Draft comment:
    Update the comment to reflect the change in parameters from a boolean to GoogleChatCompletionParams.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR changes the parameter from a boolean to an object, which is a good change for extensibility. However, the comment on line 277 still refers to the old parameter type.
2. public-packages/llm-client/src/providers/google/index.ts:389
  • Draft comment:
    Update the comment to reflect the change in parameters from a boolean to GoogleChatCompletionParams.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR changes the parameter from a boolean to an object, which is a good change for extensibility. However, the comment on line 389 still refers to the old parameter type.

Workflow ID: wflow_deabnF2znfAyoH02


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 708ec64 in 39 seconds

More details
  • Looked at 31 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. public-packages/llm-client/src/types/index.ts:9
  • Draft comment:
    GoogleGenerativeAI is imported but not used. Consider removing it to clean up the code.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_OEH4SFW8yypM4Qy9


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

RollForReflex
RollForReflex previously approved these changes Jan 14, 2025
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4378126 in 20 seconds

More details
  • Looked at 11 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .changeset/afraid-rings-cough.md:5
  • Draft comment:
    The changeset description is too vague. Please provide a more detailed description of the changes made, including specific features or fixes implemented.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_DlcpVSx9ddJeb3ln


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on aa87da3 in 16 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. public-packages/llm-client/tests/google.test.ts:204
  • Draft comment:
    Removing the console.log statement is a good practice for cleaner test output and avoiding unnecessary logging.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The removal of the console.log statement is appropriate for production code, as it prevents unnecessary logging and potential exposure of sensitive information.

Workflow ID: wflow_jCOPJNUn6SEk1m6G


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@roodboi roodboi merged commit e2b591c into main Jan 14, 2025
4 checks passed
@roodboi roodboi deleted the update-params-transform branch January 14, 2025 03:42
@github-actions github-actions bot mentioned this pull request Jan 14, 2025
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