Commit 146a016
authored
fix(vertexai): route labels to request envelope instead of
Closes #1118
`ChatVertexAI` hard-fails with `ValueError: Unknown field for
GenerationConfig: labels` whenever `labels` is passed at call time
(`.invoke(..., labels={...})` or `.bind(labels=...)`). `"labels"` was
listed in `_allowed_params`, which filters the kwargs used to build the
Gemini `GenerationConfig` — but `GenerationConfig` has no `labels` field
(it belongs on the `GenerateContentRequest` envelope).
A constructor-level `labels=` worked because `self.labels` was passed
straight to `GenerateContentRequest`; only the per-call path leaked into
`GenerationConfig`.
## What
- Remove `"labels"` from `_allowed_params` so it can never reach
`GenerationConfig`.
- In `_prepare_request_gemini`, pop a call-time `labels` kwarg and route
it (falling back to `self.labels`) onto `GenerateContentRequest` across
all return branches. This also fixes the cached-content branches, which
previously dropped labels entirely.
- Add a unit test covering init / per-call-override / per-call-only /
none.
- Drop the now-passing `xfail` markers on the two labels integration
tests.GenerationConfig (#1865)1 parent bab2961 commit 146a016
3 files changed
Lines changed: 108 additions & 7 deletions
File tree
- libs/vertexai
- langchain_google_vertexai
- tests
- integration_tests
- unit_tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | 170 | | |
172 | 171 | | |
173 | 172 | | |
| |||
180 | 179 | | |
181 | 180 | | |
182 | 181 | | |
183 | | - | |
184 | 182 | | |
185 | 183 | | |
186 | 184 | | |
| |||
1899 | 1897 | | |
1900 | 1898 | | |
1901 | 1899 | | |
1902 | | - | |
| 1900 | + | |
1903 | 1901 | | |
1904 | 1902 | | |
1905 | 1903 | | |
| |||
2242 | 2240 | | |
2243 | 2241 | | |
2244 | 2242 | | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
2245 | 2251 | | |
2246 | 2252 | | |
2247 | 2253 | | |
| |||
2334 | 2340 | | |
2335 | 2341 | | |
2336 | 2342 | | |
| 2343 | + | |
2337 | 2344 | | |
2338 | 2345 | | |
2339 | 2346 | | |
| |||
2342 | 2349 | | |
2343 | 2350 | | |
2344 | 2351 | | |
| 2352 | + | |
2345 | 2353 | | |
2346 | 2354 | | |
2347 | 2355 | | |
| |||
2353 | 2361 | | |
2354 | 2362 | | |
2355 | 2363 | | |
2356 | | - | |
| 2364 | + | |
2357 | 2365 | | |
2358 | 2366 | | |
2359 | 2367 | | |
| |||
2364 | 2372 | | |
2365 | 2373 | | |
2366 | 2374 | | |
2367 | | - | |
| 2375 | + | |
2368 | 2376 | | |
2369 | 2377 | | |
2370 | 2378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1414 | 1414 | | |
1415 | 1415 | | |
1416 | 1416 | | |
1417 | | - | |
1418 | 1417 | | |
1419 | 1418 | | |
1420 | 1419 | | |
| |||
1427 | 1426 | | |
1428 | 1427 | | |
1429 | 1428 | | |
1430 | | - | |
1431 | 1429 | | |
1432 | 1430 | | |
1433 | 1431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1932 | 1932 | | |
1933 | 1933 | | |
1934 | 1934 | | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
1935 | 2030 | | |
1936 | 2031 | | |
1937 | 2032 | | |
| |||
0 commit comments