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 search/cloud-function/python #861

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

Conversation

zeroasterisk
Copy link
Contributor

This is a long awaited update of a now closed PR #314. (blast from the past)

Ready:

  • This should be very easy to deploy and use locally, based on Cloud Functions as a standardization
  • There is minimal response simplification based on the search configuration, which should help people get started and
  • There are unit tests which mock the APIs
  • There are integration tests which do very basic functionality validation, calling the API (more in the future)

Future:

  • Right now this is python only, but I intend to make the same abstraction for a few other languages (polyglot FTW)
  • Creation of private integration tests based on this framework validating combinations of features
    • Summarization + Unstructured data + Chunk mode
    • Summarization + Structured data
    • Summarization + Blended data
  • There's no UX today but we could consider adding one
  • There's a placeholder config to do Generation based on Vertex Search retrieval via GEMINI or GENERATE_GROUNDED_ANSWERS, which might be added to the python client before creating variants (ref
    go/vertex-ai-search-retrieval-gemini-generate)

zeroasterisk and others added 10 commits July 10, 2024 20:50
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [flowbite](https://flowbite.com)
([source](https://togithub.com/themesberg/flowbite)) | [`^1.8.1` ->
`^2.0.0`](https://renovatebot.com/diffs/npm/flowbite/1.8.1/2.3.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/flowbite/2.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/flowbite/2.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/flowbite/1.8.1/2.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/flowbite/1.8.1/2.3.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>themesberg/flowbite (flowbite)</summary>

###
[`v2.3.0`](https://togithub.com/themesberg/flowbite/releases/tag/v2.3.0)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v2.2.1...v2.3.0)

- added new [copy to
clipboard](https://flowbite.com/docs/components/clipboard/) component
and examples
-   added new JavaScript tab to the documentation examples
-   update dependency to Tailwind CSS v3.4.1
-   fixed carousel component behavior when there’s only one image
-   added new data attribute to set active and inactive classes for tabs
-   Ruby on Rails integration fix for turbo load
-   minor bug fixes and improvements

###
[`v2.2.1`](https://togithub.com/themesberg/flowbite/releases/tag/v2.2.1)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v2.2.0...v2.2.1)

- relased new [phone number
input](https://flowbite.com/docs/forms/phone-input/) component
- relased new [chat
bubble](https://flowbite.com/docs/components/chat-bubble/) component
- updated `z-index` of the datepicker to allow usage with modals and
drawers

###
[`v2.2.0`](https://togithub.com/themesberg/flowbite/releases/tag/v2.2.0)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v2.1.1...v2.2.0)

- released new [number
input](https://flowbite.com/docs/forms/number-input/) component examples
-   created a new `InputCounter` object class in the Flowbite JS

###
[`v2.1.1`](https://togithub.com/themesberg/flowbite/releases/tag/v2.1.1)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v2.1.0...v2.1.1)

- fix the `InstanceOptions` and `EventListenerInstance` type exports for
TypeScript

###
[`v2.1.0`](https://togithub.com/themesberg/flowbite/releases/tag/v2.1.0)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v2.0.0...v2.1.0)

This update adds [full RTL
support](https://flowbite.com/docs/customize/rtl/) to all of the UI
components from Flowbite and also provides and update to the Instance
Manager API which now allows you to set custom id's as the 4th parameter
of each object class.

-   updated to Tailwind CSS `v3.3.5`
-   added full RTL support to all UI components
-   updated the JS API and Instance Manager to allow setting custom id's
-   added new vertical tabs component example
-   added three next modal component examples
-   fixed responsive wrapping issues for the table components
- uses Tailwind CSS v3.0 classes for background opacity fixing
[themesberg/flowbite#565
-   other minor bug fixes and improvements

Breaking changes:

- `data-modal-toggle` alone won't initialise the modal anymore, you need
to use `data-modal-target` for that

###
[`v2.0.0`](https://togithub.com/themesberg/flowbite/releases/tag/v2.0.0)

[Compare
Source](https://togithub.com/themesberg/flowbite/compare/v1.8.1...v2.0.0)

This update introduces a new instance manager feature that allows you
manage all of the interactive components from a single place. This is
useful if you want to programmatically show or hide a modal, popover, or
tooltip. This also works if you use the data attributes interface.

This change introduces a few breaking changes to the JavaScript API when
creating objects:

- new `$carouselEl` HTML element when creating a `Carousel` object as
the first parameter
- new `$accordion` HTML element when creating a `Accordion` object as
the first parameter
- new `$tabsEl` HTML element when creating a `Tabs` object as the first
parameter

The breaking changes do not apply to the data attributes interface, only
for objects created programmatically via JavaScript.

Learn more about the new [JavaScript API on the
docs](https://flowbite.com/docs/getting-started/javascript/).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/GoogleCloudPlatform/generative-ai).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMjEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjMyMS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: Holt Skinner <[email protected]>
add root level README

the goal is for a polyglot set of examples in multiple languages
- Split functionality:
- main.py does Cloud Functions
- vertex_search_client.py does Vertex AI search
- implemented .env configuration for settings
- add unit test_vertex_search_client (mocked)
- add integration test_integration_vertex_search_client (only 1 for now)

Tested and working.
@zeroasterisk zeroasterisk requested a review from a team as a code owner July 11, 2024 01:07
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024

This comment has been minimized.

@zeroasterisk zeroasterisk changed the title Add search/cloud-function/python (repeat of #314) Add search/cloud-function/python Jul 11, 2024
@zeroasterisk zeroasterisk changed the title Add search/cloud-function/python feat: Add search/cloud-function/python Jul 11, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024

This comment has been minimized.

@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024

This comment has been minimized.

@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 11, 2024
Alan Blount added 2 commits July 16, 2024 23:46
Moved content to README from file comment.

Added docblocks to all functions and classes in main.py and vertex_search_client.py
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
Alan Blount added 2 commits July 17, 2024 01:54
The flexible enums were just complicated enough that they could be more trouble than they are worth - added a test file.
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
Alan Blount added 2 commits July 17, 2024 10:40
Enums are better, but this is already a pretty complicated example and I thought this would make it simpler.

Also switched to a typed config object vs class properties on VertexSearchClient
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2024
@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 23, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 23, 2024
Copy link
Collaborator

@holtskinner holtskinner left a comment

Choose a reason for hiding this comment

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

I like this overall. Tbh, a lot of what has been written here could be a good basis for a handwritten SDK

[Your RAG powered by Google Search](https://cloud.google.com/blog/products/ai-machine-learning/rags-powered-by-google-search-technology-part-1)).

If you want even more control see
[Vertex AI APIs for building search and RAG experiences](https://cloud.google.com/generative-ai-app-builder/docs/builder-apis),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[Vertex AI APIs for building search and RAG experiences](https://cloud.google.com/generative-ai-app-builder/docs/builder-apis),
[Vertex AI Search Component APIs](https://cloud.google.com/generative-ai-app-builder/docs/builder-apis),

Comment on lines +94 to +100
```mermaid
flowchart LR
A[fa:fa-search Vertex Search AI] --> B(Google Cloud Function)
B --> C[My App Server]
C -->|One| D[fa:fa-laptop web]
C -->|Two| E[fa:fa-mobile mobile]
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is so neat! I've never seen this text based flowchart used in GitHub markdown.

quality the better the agent response based on your source data.

For more on agents, check out
[Agent Builder Use Cases](https://cloud.google.com/products/agent-builder?hl=en#common-uses)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[Agent Builder Use Cases](https://cloud.google.com/products/agent-builder?hl=en#common-uses)
[Vertex AI Agent Builder Use Cases](https://cloud.google.com/products/agent-builder?hl=en#common-uses)

If you require more extensive customization, consider using an orchestration
framework like [LangChain](https://www.langchain.com/).

**Take a look at other implementations in [search/cloud-functions/](../)**.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure this is needed yet



@functions_framework.http
def vertex_search(request: Request) -> Tuple[str, int, Dict[str, str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Can this use consistent naming?

Suggested change
def vertex_search(request: Request) -> Tuple[str, int, Dict[str, str]]:
def vertex_ai_search(request: Request) -> Tuple[str, int, Dict[str, str]]:

from typing import Generator

import pytest
from vertex_search_client import VertexSearchClient, VertexSearchConfig
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Can this consistently be called "Vertex AI Search"?

Comment on lines +91 to +92
self.client = self._create_client()
self.serving_config = self._get_serving_config()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to bring these out into separate methods? They're only used the one time

@holtskinner
Copy link
Collaborator

Just fix the remaining lint errors or add ignores when appropriate, then this can merge.

@github-actions github-actions bot added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 31, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 31, 2024
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.

None yet

3 participants