Conversation
Summary of ChangesHello @huangjeff5, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a comprehensive proposal for the Genkit Python SDK's public API surface, aiming to enhance its Pythonic nature, consistency, and developer experience for the beta release. It addresses existing friction points by clearly segmenting the API for app developers and plugin authors, standardizing conventions, and streamlining configuration and streaming mechanisms. The changes are designed to improve usability, type safety, and maintainability across the SDK. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive and well-thought-out proposal for a new Python SDK API design. The changes, presented in several detailed markdown documents, aim to create a more Pythonic, consistent, and user-friendly interface. The proposals for keyword-only arguments, distinct entry points for different user personas, a simplified streaming API, and dual sync/async clients are excellent improvements. My review focuses on ensuring the documentation is consistent and accurate, and I've identified a few minor areas for clarification and correction within the proposal documents.
py/docs/python_beta_api_proposal.md
Outdated
| class MessageWrapper: # wraps Message, doesn't extend it | ||
| def __init__(self, message: Message): ... | ||
| @property | ||
| def text(self) -> str: ... | ||
| @property | ||
| def tool_requests(self) -> list[ToolRequestPart]: ... | ||
| ``` | ||
|
|
||
| Key distinction: | ||
| - `GenerateResponseWrapper` **extends** `GenerateResponse` (inheritance). Aliasing it as `GenerateResponse` publicly is safe — construction is compatible. | ||
| - `MessageWrapper` **wraps** `Message` (composition). Its constructor takes a `Message` instance, not raw fields. Aliasing it as `Message` would break `Message(role="user", content=[...])`. |
There was a problem hiding this comment.
The description of MessageWrapper appears to be inconsistent. The document states that it uses composition and "doesn't extend" Message. However, the provided source code in py/packages/genkit/src/genkit/blocks/model.py shows class MessageWrapper(Message):, which is inheritance. This is a key detail for developers, as it affects type hinting and usage. Please update the documentation to accurately reflect that MessageWrapper extends Message.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
py/docs/python_beta_api_proposal.md
Outdated
|
|
||
| This is the one genuinely open question in the public API surface. It's covered in depth as a design decision in [PYTHON_API_REVIEW.md, section 5](./PYTHON_API_REVIEW.md). | ||
|
|
||
| Summary: `Output[T]` carries generic type information for typed responses (`ai.generate(output=Output(MyModel))` → `GenerateResponse[MyModel]`). The alternative is inline kwargs (`output_schema=MyModel`), which loses the generic typing. A tech lead challenged the naming — "Input of what? Output of what?" — arguing the names are too generic. |
There was a problem hiding this comment.
already decided; doing inline kwargs, we can still parametrize types
py/docs/python_beta_api_proposal.md
Outdated
| def __init__(self, schema: type[T], format: str = "json", ...): ... | ||
| ``` | ||
|
|
||
| `Input[T]` and `Output[T]` exist so that `generate()` and `prompt()` can carry generic type information — `ai.generate(output=Output(MyModel))` returns `GenerateResponse[MyModel]` with typed `.output`. |
There was a problem hiding this comment.
remove Layer 3 stuff, noisy
No description provided.