





















@@ -1628,6 +1628,76 @@ describe("google transport stream", () => {
16281628expect(generationConfig).not.toHaveProperty("thinkingConfig");
16291629});
163016301631+it("forwards configured stop sequences to the Gemini generationConfig", () => {
1632+const params = buildGoogleGenerativeAiParams(
1633+buildGeminiModel(),
1634+{
1635+messages: [{ role: "user", content: "hello", timestamp: 0 }],
1636+} as never,
1637+{
1638+stop: ["</tool>", "\n\nObservation:"],
1639+} as never,
1640+);
1641+1642+const generationConfig = requireGenerationConfig(params);
1643+expect(generationConfig.stopSequences).toEqual(["</tool>", "\n\nObservation:"]);
1644+});
1645+1646+it("omits stopSequences when the stop list is empty", () => {
1647+const params = buildGoogleGenerativeAiParams(
1648+buildGeminiModel(),
1649+{
1650+messages: [{ role: "user", content: "hello", timestamp: 0 }],
1651+} as never,
1652+{
1653+stop: [],
1654+} as never,
1655+);
1656+1657+expect(params.generationConfig ?? {}).not.toHaveProperty("stopSequences");
1658+});
1659+1660+it("sends stopSequences in the serialized Gemini request body via the guarded fetch transport", async () => {
1661+guardedFetchMock.mockResolvedValueOnce(buildSseResponse([]));
1662+1663+const model = attachModelProviderRequestTransport(
1664+{
1665+id: "gemini-3.1-pro-preview",
1666+name: "Gemini 3.1 Pro Preview",
1667+api: "google-generative-ai",
1668+provider: "google",
1669+baseUrl: "https://generativelanguage.googleapis.com",
1670+reasoning: true,
1671+input: ["text"],
1672+cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
1673+contextWindow: 128000,
1674+maxTokens: 8192,
1675+} satisfies Model<"google-generative-ai">,
1676+{},
1677+);
1678+1679+const streamFn = createGoogleGenerativeAiTransportStreamFn();
1680+const stream = await Promise.resolve(
1681+streamFn(
1682+model,
1683+{
1684+messages: [{ role: "user", content: "hello", timestamp: 0 }],
1685+} as Parameters<typeof streamFn>[1],
1686+{
1687+apiKey: "gemini-api-key",
1688+stop: ["</tool>", "\n\nObservation:"],
1689+} as Parameters<typeof streamFn>[2],
1690+),
1691+);
1692+await stream.result();
1693+1694+const guardedCall = requireMockCall(guardedFetchMock, 0, "guarded fetch");
1695+const init = requireRequestInit(guardedCall, "guarded fetch");
1696+const payload = parseRequestJsonBody(init);
1697+const generationConfig = requireGenerationConfig(payload);
1698+expect(generationConfig.stopSequences).toEqual(["</tool>", "\n\nObservation:"]);
1699+});
1700+16311701it("strips explicit thinkingBudget=0 but preserves includeThoughts for Gemini 2.5 Pro", () => {
16321702const params = buildGoogleGenerativeAiParams(
16331703buildGeminiModel(),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。