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

feat: add metadata field in _GenerativeModels class methods to pass the metadata down the method chain. #3491

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

vi3k6i5
Copy link

@vi3k6i5 vi3k6i5 commented Mar 21, 2024

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Get the necessary approvals
  • Once the last commit on the PR has been approved, add the "ready to pull" label to the Pull Request

Fixes #3490

Copy link

google-cla bot commented Mar 21, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: vertex-ai Issues related to the googleapis/python-aiplatform API. labels Mar 21, 2024
@vi3k6i5 vi3k6i5 force-pushed the feat/extra_header branch from af5f786 to ca963f6 Compare March 24, 2024 20:23
@sasha-gitg sasha-gitg added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 25, 2024
@sasha-gitg
Copy link
Member

@vi3k6i5 Thank you for the contribution! Please update/add unit tests.

@sasha-gitg sasha-gitg added do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Mar 27, 2024
@vi3k6i5
Copy link
Author

vi3k6i5 commented Apr 1, 2024

@sasha-gitg Can you help with the Presubmits, the PRs are in waiting state for Presubmits to finish for last 5 days. Any idea, how to resolve that ?

gcf-owl-bot bot and others added 17 commits April 1, 2024 16:53
--
da82c4a by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

feat: add function_calling_config to ToolConfig
feat: add tool_config to GenerateContentRequest

PiperOrigin-RevId: 617966568

Source-Link: googleapis/googleapis@02cf73b

Source-Link: https://github.com/googleapis/googleapis-gen/commit/9cc372f4eb562456dd6e1731a0d10919b478c839
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWNjMzcyZjRlYjU2MjQ1NmRkNmUxNzMxYTBkMTA5MTliNDc4YzgzOSJ9

--
91b6199 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

--
b8531a1 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

chore: Update gapic-generator-python to v1.16.1

PiperOrigin-RevId: 618243632

Source-Link: googleapis/googleapis@078a38b

Source-Link: https://github.com/googleapis/googleapis-gen/commit/7af768c3f8ce58994482350f7401173329950a31
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2FmNzY4YzNmOGNlNTg5OTQ0ODIzNTBmNzQwMTE3MzMyOTk1MGEzMSJ9

--
9499f80 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

--
9b6313a by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

feat: Add Optimized feature store proto
feat: Add data_key field in feature online store service
feat: Add dedicated_serving_endpoint
feat: Add index_config field

PiperOrigin-RevId: 618280080

Source-Link: googleapis/googleapis@d81d0b9

Source-Link: https://github.com/googleapis/googleapis-gen/commit/a96b4d818e3d157e6f529616ad7b147d3f8aa387
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTk2YjRkODE4ZTNkMTU3ZTZmNTI5NjE2YWQ3YjE0N2QzZjhhYTM4NyJ9

--
9f8e913 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>:

🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

COPYBARA_INTEGRATE_REVIEW=googleapis#3493 from googleapis:owl-bot-copy 9f8e913
PiperOrigin-RevId: 618911337
…n using pre-built container

PiperOrigin-RevId: 619575247
PiperOrigin-RevId: 619580451
…on support for Imagen 2

Changelog:
Changed the following parameters internally:

  - `editConfig` to `editConfigV6`
  - `segmentationClasses` to `classes`
  - `safetyFilterLevel` to `safetySetting`

PiperOrigin-RevId: 619620158
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
--
ccbbe38 by release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>:

chore(main): release 1.45.0

COPYBARA_INTEGRATE_REVIEW=googleapis#3443 from googleapis:release-please--branches--main ccbbe38
PiperOrigin-RevId: 619994937
…nt parameters

Changed flags:

`maskMode` is it's own struct in the API, encapsulating `maskType` and `classes`

`maskMode` can only be set (even to an empty value) if two conditions are satisfied:
- `mask` is None
- `editMode` is not `product-image`
The logic now reflects this

PiperOrigin-RevId: 620092866
PiperOrigin-RevId: 620105958
The Automatic Function Calling (AFC) feature automates the function calling handling.
AFC reduces manual user steps when using Function Calling.
AFC makes it easy to use native functions (e.g. Python) with the Function Calling feature.
AFC makes it possible for the user to instruct the SDK to let the model call the user-provided functions automatically.

AFC can be enabled when starting a chat.

Usage:
```python
from vertexai.preview.generative_models import GenerativeModel, FunctionCallingConfig, FunctionDeclaration, Tool

def get_current_weather(location: str, unit: str = "centigrade"):
    """Gets weather in the specified location.

    Args:
        location: The location for which to get the weather.
        unit: Optional. Temperature unit. Can be Centigrade or Fahrenheit. Defaults to Centigrade.

    Returns:
        The weather information as a dict.
    """
    # Add actual implementation.
    return dict(
        location=location,
        unit=unit,
        weather="Super nice, but maybe a bit hot.",
    )

get_current_weather_declaration = FunctionDeclaration.from_func(get_current_weather)

weather_tool = Tool([get_current_weather_declaration])

fc_model = GenerativeModel("gemini-pro", tools=[weather_tool])
afc_responder = AutomaticFunctionCallingResponder(
    # Optional:
    max_number_of_automatic_function_calls=5,
)
chat = model.start_chat(responder=afc_responder)

fc_chat.send_message("What is the weather like in Boston?")
```

PiperOrigin-RevId: 620189258
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 1, 2024
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Apr 1, 2024
@sasha-gitg sasha-gitg added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 24, 2024
@josealvarez97
Copy link

josealvarez97 commented May 30, 2024

@vi3k6i5 @sasha-gitg will this be merged into the Python SDK?

In the JavAscript SDK, currently it's possible to send headers and modify other request options (like the baseUrl) this way:

const model = googleGenAIClient.getGenerativeModel(
				{ model: "gemini-pro" },
				{
					customHeaders: {
						"x-param": "<PARAMETER>",
					},
					baseUrl: env.PROXY_URL,
					
				}
			);

I wonder why a similar functionality was not added to the Python SDK

It almost feels like it was close to be considered, but it was not finished.

See these links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API. kokoro:force-run Add this label to force Kokoro to re-run the tests. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to pass metadata from GenerativeModel.generate_content and Chat:send_message
8 participants