Repository navigation
add google/gemini-models #237
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
Open
adssib
wants to merge
1
commit into
pl5-convex
Choose a base branch
from
pl5-gemini
base: pl5-convex
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,359
−30
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package notices | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" | ||
| "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" | ||
| ) | ||
|
|
||
| // section is the saved page from start up to end (to the end of the page | ||
| // when end is ""), as a page of its own. | ||
| func section(t *testing.T, file, start, end string) string { | ||
| t.Helper() | ||
| b, err := os.ReadFile(file) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| s := string(b) | ||
| i := strings.Index(s, start) | ||
| if i < 0 { | ||
| t.Fatalf("%s: the saved page's shape changed", file) | ||
| } | ||
| if end == "" { | ||
| return s[i:] | ||
| } | ||
| j := strings.Index(s[i+1:], end) | ||
| if j < 0 { | ||
| t.Fatalf("%s: the saved page's shape changed", file) | ||
| } | ||
| return s[i : i+1+j] | ||
| } | ||
|
|
||
| // readGoogle is a first read of page, served as content, through the kind. | ||
| func readGoogle(t *testing.T, page retire.Page, content string) int { | ||
| t.Helper() | ||
| f := t.TempDir() + "/page" | ||
| if err := os.WriteFile(f, []byte(content), 0o644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| saved := kittest.Pages{page.URL: f} | ||
| return len(kittest.Page(t, kittest.Env(t, saved), Plugin{Page: page, Archiver: &kittest.Archive{T: t, Pages: saved}})) | ||
| } | ||
|
|
||
| // The pinned drop test for the Gemini API page: the Gemini 4 models (no | ||
| // shutdown date announced) and the managed agents, whose deprecated table | ||
| // has real dates but names agents, not models, next to the two Gemini 3 | ||
| // models shut down already. Only those two are events; the agents' table | ||
| // renamed to "Model" would give two more, so the header is what keeps it | ||
| // out. | ||
| func TestGeminiDropsModelsWithNoDateAndAgents(t *testing.T) { | ||
| const file = "retire/testdata/gemini-deprecations.md" | ||
| current := section(t, file, "## Gemini 4 models", "## Gemini 3 models") | ||
| retired := section(t, file, "### Deprecated models {% id=\"gemini-3-deprecated-models\" %}", "## Gemini 2.5 Pro models") | ||
| agents := section(t, file, "## Managed agents", "") | ||
| if n := readGoogle(t, retire.Gemini, current+retired+agents); n != 2 { | ||
| t.Errorf("%d events, want the 2 shut-down Gemini 3 models only", n) | ||
| } | ||
| if _, err := retire.Parse(retire.Gemini.Format.Pipes([]byte(agents)), retire.Gemini.Keep); err == nil { | ||
| t.Error("the agents' tables read as retirements") | ||
| } | ||
| asModels := strings.ReplaceAll(agents, " * Agent\n", " * Model\n") | ||
| if rs, err := retire.Parse(retire.Gemini.Format.Pipes([]byte(asModels)), retire.Gemini.Keep); err != nil || len(rs) != 2 { | ||
| t.Errorf("the agents' table with a Model header: %d, %v; the drop proves nothing", len(rs), err) | ||
| } | ||
| } | ||
|
|
||
| // Google's Gemini dates are the earliest a model may go: the description | ||
| // says so. | ||
| func TestGeminiDatesAreTheEarliest(t *testing.T) { | ||
| saved := kittest.Pages{retire.Gemini.URL: "retire/testdata/gemini-deprecations.md"} | ||
| for _, e := range kittest.Page(t, kittest.Env(t, saved), Plugin{Page: retire.Gemini, Archiver: &kittest.Archive{T: t, Pages: saved}}) { | ||
| if !strings.Contains(e.Description, "the earliest date Google gives") { | ||
| t.Fatalf("%s: %q", e.Subject.Name, e.Description) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package retire | ||
|
|
||
| import ( | ||
| "regexp" | ||
| "strings" | ||
| ) | ||
|
|
||
| var ( | ||
| // markdocCell is one cell of a Markdoc table: " * `gemini-2.0-flash`". | ||
| markdocCell = regexp.MustCompile(`^\s*\* ?(.*)$`) | ||
| markdocHeading = regexp.MustCompile(`^(#+ .*?)\s*(\{%.*%\})?\s*$`) | ||
| ) | ||
|
|
||
| // markdocPipes reads a Markdoc page's tables ({% table %}, a "* cell" per | ||
| // line, rows split by "---", the first row the header) into pipe tables, | ||
| // each under the heading above it. Nothing else on the page is kept. | ||
| func markdocPipes(page []byte) []byte { | ||
| var out []string | ||
| var rows [][]string | ||
| var cur []string | ||
| in := false | ||
| flush := func() { | ||
| if len(cur) > 0 { | ||
| rows = append(rows, cur) | ||
| cur = nil | ||
| } | ||
| } | ||
| for _, line := range strings.Split(strings.ReplaceAll(string(page), "\r\n", "\n"), "\n") { | ||
| t := strings.TrimSpace(line) | ||
| switch { | ||
| case !in && strings.HasPrefix(t, "#"): | ||
| if m := markdocHeading.FindStringSubmatch(t); m != nil { | ||
| out = append(out, m[1]) | ||
| } | ||
| case !in && t == "{% table %}": | ||
| in, rows, cur = true, nil, nil | ||
| case in && t == "{% /table %}": | ||
| flush() | ||
| out = append(out, pipeTable(rows)...) | ||
| in = false | ||
| case in && t == "---": | ||
| flush() | ||
| case in && strings.HasPrefix(t, "*"): | ||
| cur = append(cur, strings.TrimSpace(markdocCell.FindStringSubmatch(line)[1])) | ||
| case in && t != "" && len(cur) > 0: | ||
| // A cell's text continued on the next line. | ||
| cur[len(cur)-1] += " " + t | ||
| } | ||
| } | ||
| return []byte(strings.Join(out, "\n") + "\n") | ||
| } | ||
|
|
||
| // pipeTable writes rows (the first the header) as a Markdown pipe table, | ||
| // escaping a pipe inside a cell. | ||
| func pipeTable(rows [][]string) []string { | ||
| if len(rows) == 0 { | ||
| return nil | ||
| } | ||
| line := func(cells []string) string { | ||
| esc := make([]string, len(cells)) | ||
| for i, c := range cells { | ||
| esc[i] = strings.ReplaceAll(c, "|", `\|`) | ||
| } | ||
| return "| " + strings.Join(esc, " | ") + " |" | ||
| } | ||
| out := []string{"", line(rows[0]), "|" + strings.Repeat(" --- |", len(rows[0]))} | ||
| for _, r := range rows[1:] { | ||
| out = append(out, line(r)) | ||
| } | ||
| return append(out, "") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: for some rows this sentence is wrong.
gemini-2.5-pro,gemini-2.5-flashandgemini-embedding-2-previewdon't fail on their date. Google says requests to them "will automatically route to" the replacement and are billed at its rates. The event is still worth emitting, since behaviour and price change, and the hint already quotes the routing note. But "requests naming it fail once it is" isn't true for those three. A softer wording such as "…: Google stops serving it under that name from then" would be correct for every row.