Skip to content

Commit 86a725b

Browse files
committed
Try to reduce flakiness of generateContentThinkingFunctionCalling test
1 parent b142c34 commit 86a725b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ struct GenerateContentIntegrationTests {
233233

234234
@Test(
235235
arguments: [
236-
(.vertexAI_v1beta_global, ModelNames.gemini2_5_Flash, ThinkingConfig(thinkingBudget: 0)),
237236
(.vertexAI_v1beta_global, ModelNames.gemini2_5_Flash, ThinkingConfig(thinkingBudget: -1)),
238237
(.vertexAI_v1beta_global, ModelNames.gemini2_5_Flash, ThinkingConfig(
239238
thinkingBudget: -1, includeThoughts: true
@@ -242,13 +241,11 @@ struct GenerateContentIntegrationTests {
242241
(.vertexAI_v1beta_global, ModelNames.gemini2_5_Pro, ThinkingConfig(
243242
thinkingBudget: -1, includeThoughts: true
244243
)),
245-
(.googleAI_v1beta, ModelNames.gemini2_5_Flash, ThinkingConfig(thinkingBudget: 0)),
246244
(.googleAI_v1beta, ModelNames.gemini2_5_Flash, ThinkingConfig(thinkingBudget: -1)),
247245
(.googleAI_v1beta, ModelNames.gemini2_5_Flash, ThinkingConfig(
248246
thinkingBudget: -1, includeThoughts: true
249247
)),
250248
(.googleAI_v1beta, ModelNames.gemini2_5_Pro, ThinkingConfig(thinkingBudget: -1)),
251-
(.googleAI_v1beta, ModelNames.gemini2_5_Pro, ThinkingConfig(thinkingBudget: -1)),
252249
(.googleAI_v1beta, ModelNames.gemini2_5_Pro, ThinkingConfig(
253250
thinkingBudget: -1, includeThoughts: true
254251
)),
@@ -257,7 +254,7 @@ struct GenerateContentIntegrationTests {
257254
func generateContentThinkingFunctionCalling(_ config: InstanceConfig, modelName: String,
258255
thinkingConfig: ThinkingConfig) async throws {
259256
let currentLocationDeclaration = FunctionDeclaration(
260-
name: "currentLocation",
257+
name: "getCurrentLocation",
261258
description: "Returns the user's current city, province or state, and country",
262259
parameters: [:]
263260
)
@@ -279,18 +276,23 @@ struct GenerateContentIntegrationTests {
279276
thinkingConfig: thinkingConfig
280277
),
281278
safetySettings: safetySettings,
282-
tools: [.functionDeclarations([currentLocationDeclaration, getTemperatureDeclaration])]
279+
tools: [.functionDeclarations([currentLocationDeclaration, getTemperatureDeclaration])],
280+
systemInstruction: ModelContent(parts: """
281+
You are a weather bot that specializes in reporting outdoor temperatures in Celsius.
282+
283+
If not specified, assume that the user is asking for the temperature in their current \
284+
location. Use the `getCurrentLocation` function to determine the user's location. Always use the \
285+
`getTemperature` function to determine the current outdoor temperature in a location. You \
286+
can use the output of the `getCurrentLocation` function as input to the `getTemperature` \
287+
function to get the temperature in the user's location.
288+
289+
Always respond in the format:
290+
- Location: City, Province/State, Country
291+
- Temperature: #C
292+
""")
283293
)
284294
let chat = model.startChat()
285-
let prompt = """
286-
What is the temperature outside right now? Respond in the format:
287-
- Location: City, Province/State, Country
288-
- Temperature: #C
289-
290-
Example Output:
291-
- Location: Vancouver, British Columbia, Canada
292-
- Temperature: 15C
293-
"""
295+
let prompt = "What is the current temperature?"
294296

295297
let response = try await chat.sendMessage(prompt)
296298

@@ -340,10 +342,8 @@ struct GenerateContentIntegrationTests {
340342

341343
#expect(response3.functionCalls.isEmpty)
342344
let finalText = try #require(response3.text).trimmingCharacters(in: .whitespacesAndNewlines)
343-
#expect(finalText == """
344-
- Location: Waterloo, Ontario, Canada
345-
- Temperature: 25C
346-
""")
345+
#expect(finalText.contains("Waterloo"))
346+
#expect(finalText.contains("25"))
347347

348348
if let _ = thinkingConfig.includeThoughts, case .googleAI = config.apiConfig.service {
349349
#expect(thoughtSignatureCount > 0)

0 commit comments

Comments
 (0)