Skip to content

Commit

Permalink
Merge branch 'main' into inardini--batch-pipeline-rag
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner authored Sep 4, 2024
2 parents f599b62 + 749602d commit 81e8ea8
Show file tree
Hide file tree
Showing 97 changed files with 30,652 additions and 21,361 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/generative-ai/language/use-cases/prod-catalog-enrichment @slatawa @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/language/use-cases/sql-code-generation @rarsan @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/language/use-cases/sql-code-generation/sql_code_generation_langchain.ipynb @rarsan @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/search @holtskinner @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/search @agarwal22megha @holtskinner @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/search/retrieval-augmented-generation @holtskinner @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/speech/getting-started @inardini @GoogleCloudPlatform/generative-ai-devrel
/generative-ai/speech/use-cases/storytelling @holtskinner @GoogleCloudPlatform/generative-ai-devrel
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/spelling/advice.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ If items relate to a ...
File paths are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files.

`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
../tree/HEAD/README.md) (on whichever branch you're using).
`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude `README.md` (on whichever branch you're using).

* well-formed pattern.

Expand Down
17 changes: 17 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ANZ
APIENTRY
APSTUDIO
Adidas
Akihiro
Aniston
Arborio
Arepa
Expand Down Expand Up @@ -62,6 +63,7 @@ Firestore
Fishburne
Flatform
Flipkart
Fujita
GError
GFile
GObject
Expand All @@ -78,8 +80,13 @@ HIDPI
HMO
HREDRAW
HSA
HVDC
Hamamoto
Hamers
Hickson
Hida
Hikaru
Hisaki
Hmmm
Hogwarts
Hubmann
Expand All @@ -95,6 +102,7 @@ Kaelen
Kaggle
Kamradt
Kaufmanns
Kawagoe
Keanu
Khanh
Knopf
Expand All @@ -116,9 +124,12 @@ Maarten
Mahindra
Mamah
Mandiri
Masaru
Memegen
Mewgler
Mitani
Mosher
Mvar
NARI
NCCREATE
NDEBUG
Expand All @@ -127,6 +138,7 @@ NMT
NOMINMAX
NOZORDER
NVIDIA
Niitsuma
Noogler
OOTB
Oberst
Expand Down Expand Up @@ -187,6 +199,7 @@ Tbk
Tbl
Tencent
Testables
Tetsuo
Tianli
Topolino
Trapp
Expand All @@ -195,6 +208,7 @@ Tricyle
UDFs
USERDATA
Unimicron
Upserting
Urs
Uszkoreit
VFT
Expand All @@ -212,6 +226,7 @@ Wehn
Wnd
Womens
XXE
Yuzuru
Zijin
Zscaler
Zuercher
Expand Down Expand Up @@ -248,7 +263,9 @@ cmap
codebase
codebases
codelab
codelabs
colab
coldline
coloraxis
colorbar
colorway
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/spelling/line_forbidden.patterns
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,4 @@
\ban\s+(?![FHLMNRSX][A-Z0-9]+\b)(?!hour\b)(?!honest\b)([b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z]{1}\w*)

# Don't use Google internal links
((corp|prod).google.com|googleplex.com|https?://[0-9a-z][0-9a-z-]+/|(?:^|[^/.-])\b(?:go|b|cl|cr)/[a-z0-9_.-]+\b)
((corp|prod|sandbox).google.com|googleplex.com|https?://[0-9a-z][0-9a-z-]+/|(?:^|[^/.-])\b(?:go|b|cl|cr)/[a-z0-9_.-]+\b)
2 changes: 1 addition & 1 deletion .github/linters/.python-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MESSAGES CONTROL]
disable=E0401
disable=E0401,C0301
25 changes: 25 additions & 0 deletions .github/workflows/links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Links

on:
repository_dispatch:
workflow_dispatch:
schedule:
- cron: "00 18 * * *"

jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1

- name: Create Issue From File
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@v5
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
16 changes: 16 additions & 0 deletions .github/workflows/lychee-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check Links

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: lycheeverse/lychee-action@v1
- name: Comment Broken Links
uses: marocchino/sticky-pull-request-comment@v2
with:
path: lychee/out.md
84 changes: 84 additions & 0 deletions .github/workflows/notebook_linter/check_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""Check links in notebooks for accuracy."""

import os
import sys
from typing import Tuple
import urllib.parse

import nbformat

LINK_PREFIXES = {
"colab_link": "https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/",
"colab_enterprise_link": "https://console.cloud.google.com/vertex-ai/colab/import/",
"github_link": "https://github.com/GoogleCloudPlatform/generative-ai/blob/main/",
"workbench_link": "https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=",
}

RAW_URL_PREFIX = (
"https://raw.githubusercontent.com/GoogleCloudPlatform/generative-ai/main/"
)


def fix_markdown_links(
cell_source: str, relative_notebook_path: str
) -> Tuple[str, bool]:
"""Fixes links in a markdown cell and returns the updated source."""
new_lines = []
changes_made = False

for line in cell_source.splitlines():
for key, prefix in LINK_PREFIXES.items():
if prefix not in line:
continue

start_index = line.find(prefix) + len(prefix)
end_index = line.find(".ipynb", start_index) + len(".ipynb")
correct_link = ""

if key in {"colab_link", "github_link"}:
correct_link = relative_notebook_path
elif key == "colab_enterprise_link":
correct_link = urllib.parse.quote(
f"{RAW_URL_PREFIX}{relative_notebook_path}",
safe=":",
)
elif key == "workbench_link":
correct_link = f"{RAW_URL_PREFIX}{relative_notebook_path}"

if correct_link not in line:
print(f"Incorrect link in {relative_notebook_path}: {line}\n")
print(f"Should be: {correct_link}\n")
line = line.replace(line[start_index:end_index], correct_link)
changes_made = True

new_lines.append(line)

return "\n".join(new_lines), changes_made


def fix_links_in_notebook(notebook_path: str) -> int:
"""Fixes specific types of links in a Jupyter notebook."""
with open(notebook_path, "r", encoding="utf-8") as f:
notebook = nbformat.read(f, as_version=4)

relative_notebook_path = os.path.relpath(notebook_path, start=os.getcwd())

for cell in notebook.cells:
if cell.cell_type == "markdown" and "<table" in cell.source:
updated_source, changes_made = fix_markdown_links(
cell.source, relative_notebook_path
)
if changes_made:
cell.source = updated_source
with open(notebook_path, "w", encoding="utf-8") as f:
nbformat.write(notebook, f)
return 1
return 0


if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python check_links.py <notebook_path>")
sys.exit(1)

fix_links_in_notebook(sys.argv[1])
13 changes: 13 additions & 0 deletions .github/workflows/notebook_linter/run_linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ fi

problematic_notebooks=()
if [ ${#notebooks[@]} -gt 0 ]; then
script_dir="$(dirname "$0")"
for notebook in "${notebooks[@]}"; do
if [ -f "$notebook" ]; then
echo "Checking notebook: ${notebook}"

LINK_RTN="0"
NBFMT_RTN="0"
BLACK_RTN="0"
BLACKEN_DOCS_RTN="0"
Expand All @@ -79,6 +81,9 @@ if [ ${#notebooks[@]} -gt 0 ]; then
MYPY_RTN="0"

if [ "$is_test" = true ]; then
echo "Running link checker..."
python3 "$script_dir/check_links.py" "$notebook"
LINK_RTN=$?
echo "Running isort..."
python3 -m nbqa isort --fss "$notebook" --check --profile black
ISORT_RTN=$?
Expand All @@ -101,6 +106,9 @@ if [ ${#notebooks[@]} -gt 0 ]; then
python3 -m nbqa mypy "$notebook" --ignore-missing-imports --disable-error-code=top-level-await --disable-error-code=attr-defined
MYPY_RTN=$?
else
echo "Running link checker..."
python3 "$script_dir/check_links.py" "$notebook"
LINK_RTN=$?
echo "Running isort..."
python3 -m nbqa isort --fss "$notebook" --profile black
ISORT_RTN=$?
Expand All @@ -126,6 +134,11 @@ if [ ${#notebooks[@]} -gt 0 ]; then

NOTEBOOK_RTN="0"

if [ "$LINK_RTN" != "0" ]; then
NOTEBOOK_RTN="$LINK_RTN"
printf "link: Failed\n"
fi

if [ "$NBFMT_RTN" != "0" ]; then
NOTEBOOK_RTN="$NBFMT_RTN"
printf "nbfmt: Failed\n"
Expand Down
4 changes: 2 additions & 2 deletions RESOURCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ Please submit additional resources via a PR.
- [Responsible AI: Applying AI Principles with Google Cloud](https://www.cloudskillsboost.google/paths/118/course_templates/388)

- [Intermediate: Gemini for Google Cloud Learning Path](https://www.cloudskillsboost.google/paths/236): The Gemini for Google Cloud learning path provides examples of how Gemini can help make engineers of all types more efficient in their daily activities.
- [Gemini for Application Developers](https://www.cloudskillsboost.google/paths/236/course_sessions/7024601/labs/448290)
- [Gemini for Application Developers](https://www.cloudskillsboost.google/course_templates/881)
- [Gemini for Cloud Architects](https://www.cloudskillsboost.google/paths/236/course_templates/878)
- [Gemini for Data Scientists and Analysts](https://www.cloudskillsboost.google/paths/236/course_templates/879)
- [Gemini for Network Engineers](https://www.cloudskillsboost.google/paths/236/course_templates/884)
- [Gemini for Security Engineers](https://www.cloudskillsboost.google/paths/236/course_templates/886)
- [Gemini for DevOps Engineers](https://www.cloudskillsboost.google/paths/236/course_templates/882)
- [Gemini for end-to-end SDLC](https://www.cloudskillsboost.google/paths/236/course_sessions/11762414/labs/448528)
- [Gemini for end-to-end SDLC](https://www.cloudskillsboost.google/course_templates/885)
- [Develop Gen AI Apps with Gemini and Streamlit](https://www.cloudskillsboost.google/paths/236/course_templates/978)

- [Advanced: Generative AI for Developers Learning Path](https://www.cloudskillsboost.google/paths/183): A Generative AI Learning Path with a technical focus, built for App Developers, Machine Learning Engineers, and Data Scientists. Recommended prerequisite: Introduction to Generative AI learning path.
Expand Down
1 change: 1 addition & 0 deletions conversation/chat-app/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"printWidth": 100,
"bracketSameLine": true,
"pluginSearchDirs": ["."],
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
Loading

0 comments on commit 81e8ea8

Please sign in to comment.