Ver Fonte

VertexAI: migrate test cases to use updated set of golden files (#13152)

Tanzim Hossain há 1 ano atrás
pai
commit
2dcb05cfc4
48 ficheiros alterados com 131 adições e 153 exclusões
  1. 1 1
      FirebaseVertexAI/Tests/Unit/ChatTests.swift
  2. 0 2
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-finish-reason-safety.txt
  3. 0 6
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-recitation-no-content.txt
  4. 0 1
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-basic-reply-short.txt
  5. 0 7
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-citations.txt
  6. 0 53
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-finish-reason-safety.json
  7. 0 50
      FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-basic-reply-long.json
  8. 11 15
      FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift
  9. 1 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-empty-content.txt
  10. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-error-mid-stream.txt
  11. 2 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-finish-reason-safety.txt
  12. 1 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-invalid-json.txt
  13. 1 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-malformed-content.txt
  14. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-prompt-blocked-safety.txt
  15. 6 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-recitation-no-content.txt
  16. 1 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-unknown-finish-enum.txt
  17. 12 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-long.txt
  18. 16 15
      FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-parts.txt
  19. 2 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-short.txt
  20. 12 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-success-citations.txt
  21. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/streaming-success-unknown-safety-enum.txt
  22. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-api-key.json
  23. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-empty-content.json
  24. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-finish-reason-safety-no-content.json
  25. 54 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-finish-reason-safety.json
  26. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-firebaseml-api-not-enabled.json
  27. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-image-rejected.json
  28. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-invalid-response.json
  29. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-malformed-content.json
  30. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-model-not-found.json
  31. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-prompt-blocked-safety.json
  32. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-enum-finish-reason.json
  33. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-enum-prompt-blocked.json
  34. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-model.json
  35. 7 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-basic-reply-long.json
  36. 2 1
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-basic-reply-short.json
  37. 1 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-citations.json
  38. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-empty-arguments.json
  39. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-mixed-content.json
  40. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-no-arguments.json
  41. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-parallel-calls.json
  42. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-with-arguments.json
  43. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-missing-safety-ratings.json
  44. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-no-billable-characters.json
  45. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-quote-reply.json
  46. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-total-tokens.json
  47. 0 0
      FirebaseVertexAI/Tests/Unit/Responses/unary-success-unknown-enum-safety-ratings.json
  48. 1 2
      Package.swift

+ 1 - 1
FirebaseVertexAI/Tests/Unit/ChatTests.swift

@@ -33,7 +33,7 @@ final class ChatTests: XCTestCase {
 
   func testMergingText() async throws {
     let fileURL = try XCTUnwrap(Bundle.module.url(
-      forResource: "streaming-success-basic-reply-long",
+      forResource: "streaming-success-basic-reply-parts",
       withExtension: "txt"
     ))
 

+ 0 - 2
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-finish-reason-safety.txt

@@ -1,2 +0,0 @@
-data: {"candidates": [{"content": {"parts": [{"text": "No"}]},"finishReason": "SAFETY","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "HIGH"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
-

+ 0 - 6
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-recitation-no-content.txt

@@ -1,6 +0,0 @@
-data: {"candidates": [{"content": {"parts": [{"text": "Some information"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
-
-data: {"candidates": [{"content": {"parts": [{"text": "Some information cited from an external source"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "LOW"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}],"citationMetadata": {"citationSources": [{"startIndex": 30,"endIndex": 179,"uri": "https://www.example.com/some-citation","license": ""}]}}]}
-
-data: {"candidates": [{"finishReason": "RECITATION","index": 0}]}
-

+ 0 - 1
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-basic-reply-short.txt

@@ -1 +0,0 @@
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "Mountain View, California"}]},"finishReason": "STOP","safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.02854415,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.052424565},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.24926445,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.0996453},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.087096825,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.043123372},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.14402841,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.086169556}]}],"usageMetadata": {"promptTokenCount": 6,"candidatesTokenCount": 4,"totalTokenCount": 10}}

+ 0 - 7
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-citations.txt

@@ -1,7 +0,0 @@
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "Some information"}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.043204036,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.082549304},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.046291895,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.071461484},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.100701615,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.06164962},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.13150747,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.040087357}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "  Some information cited from an external source"}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.18982129,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.1337543},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.13637818,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.021906368},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.25404602,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.09073549},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.24202643,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.06548521}],"citationMetadata": {"citations": [{"endIndex": 128,"uri": "https://www.example.com/citation-1"},{"startIndex": 130,"endIndex": 265,"uri": "https://www.example.com/citation-2"}]}}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": " More information cited from an external source"}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.07850098,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.039416388},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.08035747,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04885778},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.12273335,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.059646938},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.053206205,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04099903}],"citationMetadata": {"citations": [{"startIndex": 272,"endIndex": 431,"uri": "https://www.example.com/citation-3","license": "mit"}]}}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": " More information "}]},"finishReason": "STOP","safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.16013464,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.11716747},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.10818896,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.021990221},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.2158462,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.07682221},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.19636348,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.08021325}]}],"usageMetadata": {"promptTokenCount": 9,"candidatesTokenCount": 53,"totalTokenCount": 62}}

+ 0 - 53
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-finish-reason-safety.json

@@ -1,53 +0,0 @@
-{
-    "candidates": [
-        {
-            "content": {
-                "parts": [
-                    {
-                        "text": "No"
-                    }
-                ]
-            },
-            "finishReason": "SAFETY",
-            "index": 0,
-            "safetyRatings": [
-                {
-                    "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
-                    "probability": "NEGLIGIBLE"
-                },
-                {
-                    "category": "HARM_CATEGORY_HATE_SPEECH",
-                    "probability": "HIGH"
-                },
-                {
-                    "category": "HARM_CATEGORY_HARASSMENT",
-                    "probability": "NEGLIGIBLE"
-                },
-                {
-                    "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
-                    "probability": "NEGLIGIBLE"
-                }
-            ]
-        }
-    ],
-    "promptFeedback": {
-        "safetyRatings": [
-            {
-                "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
-                "probability": "NEGLIGIBLE"
-            },
-            {
-                "category": "HARM_CATEGORY_HATE_SPEECH",
-                "probability": "NEGLIGIBLE"
-            },
-            {
-                "category": "HARM_CATEGORY_HARASSMENT",
-                "probability": "NEGLIGIBLE"
-            },
-            {
-                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
-                "probability": "NEGLIGIBLE"
-            }
-        ]
-    }
-}

+ 0 - 50
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-basic-reply-long.json

@@ -1,50 +0,0 @@
-{
-  "candidates": [
-    {
-      "content": {
-        "role": "model",
-        "parts": [
-          {
-            "text": "You can ask me a wide range of questions, including:\n\n* **General knowledge questions:** What is the capital of France? Who painted the Mona Lisa?\n* **Science questions:** What is the chemical formula for water? How does photosynthesis work?\n* **History questions:** When did World War II start? Who was the first president of the United States?\n* **Math questions:** What is the square root of 16? How do you solve for x in the equation x + 5 = 10?\n* **Current events questions:** What is happening in Ukraine? Who is the current president of the United States?\n* **Personal questions:** What are your hobbies? What are your favorite books?\n* **Hypothetical questions:** What would happen if all the ice caps melted? What if humans could live on Mars?\n* **Questions about me:** What is your name? How old are you? What are your capabilities?\n\n**Tips for asking questions:**\n\n* Be specific and clear in your questions.\n* Use correct grammar and spelling.\n* Try to ask open-ended questions that allow for multiple answers.\n* Be patient and wait for my response. I am still under development, so I may take a few seconds to process your question.\n\nPlease note that I am still under development and may not be able to answer all questions accurately. However, I will do my best to provide you with the most relevant information I have available."
-          }
-        ]
-      },
-      "finishReason": "STOP",
-      "safetyRatings": [
-        {
-          "category": "HARM_CATEGORY_HATE_SPEECH",
-          "probability": "NEGLIGIBLE",
-          "probabilityScore": 0.047869004,
-          "severity": "HARM_SEVERITY_NEGLIGIBLE",
-          "severityScore": 0.050705366
-        },
-        {
-          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
-          "probability": "NEGLIGIBLE",
-          "probabilityScore": 0.052134257,
-          "severity": "HARM_SEVERITY_NEGLIGIBLE",
-          "severityScore": 0.036288295
-        },
-        {
-          "category": "HARM_CATEGORY_HARASSMENT",
-          "probability": "NEGLIGIBLE",
-          "probabilityScore": 0.08464396,
-          "severity": "HARM_SEVERITY_NEGLIGIBLE",
-          "severityScore": 0.033907957
-        },
-        {
-          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
-          "probability": "NEGLIGIBLE",
-          "probabilityScore": 0.06290424,
-          "severity": "HARM_SEVERITY_NEGLIGIBLE",
-          "severityScore": 0.050611436
-        }
-      ]
-    }
-  ],
-  "usageMetadata": {
-    "promptTokenCount": 6,
-    "candidatesTokenCount": 303,
-    "totalTokenCount": 309
-  }
-}

+ 11 - 15
FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

@@ -71,7 +71,7 @@ final class GenerativeModelTests: XCTestCase {
     XCTAssertEqual(candidate.content.parts.count, 1)
     let part = try XCTUnwrap(candidate.content.parts.first)
     let partText = try XCTUnwrap(part.text)
-    XCTAssertTrue(partText.hasPrefix("You can ask me a wide range of questions"))
+    XCTAssertTrue(partText.hasPrefix("1. **Use Freshly Ground Coffee**:"))
     XCTAssertEqual(response.text, partText)
     XCTAssertEqual(response.functionCalls, [])
   }
@@ -92,7 +92,7 @@ final class GenerativeModelTests: XCTestCase {
     XCTAssertEqual(candidate.safetyRatings.sorted(), safetyRatingsNegligible)
     XCTAssertEqual(candidate.content.parts.count, 1)
     let part = try XCTUnwrap(candidate.content.parts.first)
-    XCTAssertEqual(part.text, "Mountain View, California, United States")
+    XCTAssertEqual(part.text, "Mountain View, California")
     XCTAssertEqual(response.text, part.text)
     XCTAssertEqual(response.functionCalls, [])
   }
@@ -506,7 +506,7 @@ final class GenerativeModelTests: XCTestCase {
       XCTFail("Should throw")
     } catch let GenerateContentError.responseStoppedEarly(reason, response) {
       XCTAssertEqual(reason, .safety)
-      XCTAssertEqual(response.text, "No")
+      XCTAssertEqual(response.text, "<redacted>")
     } catch {
       XCTFail("Should throw a responseStoppedEarly")
     }
@@ -888,7 +888,7 @@ final class GenerativeModelTests: XCTestCase {
       responses += 1
     }
 
-    XCTAssertEqual(responses, 8)
+    XCTAssertEqual(responses, 6)
   }
 
   func testGenerateContentStream_successBasicReplyShort() async throws {
@@ -949,18 +949,14 @@ final class GenerativeModelTests: XCTestCase {
 
     let lastCandidate = try XCTUnwrap(responses.last?.candidates.first)
     XCTAssertEqual(lastCandidate.finishReason, .stop)
-    XCTAssertEqual(citations.count, 3)
+    XCTAssertEqual(citations.count, 6)
     XCTAssertTrue(citations
       .contains(where: {
-        $0.startIndex == 0 && $0.endIndex == 128 && !$0.uri.isEmpty && $0.license == nil
+        $0.startIndex == 574 && $0.endIndex == 705 && !$0.uri.isEmpty && $0.license == ""
       }))
     XCTAssertTrue(citations
       .contains(where: {
-        $0.startIndex == 130 && $0.endIndex == 265 && !$0.uri.isEmpty && $0.license == nil
-      }))
-    XCTAssertTrue(citations
-      .contains(where: {
-        $0.startIndex == 272 && $0.endIndex == 431 && !$0.uri.isEmpty && $0.license == "mit"
+        $0.startIndex == 899 && $0.endIndex == 1026 && !$0.uri.isEmpty && $0.license == ""
       }))
   }
 
@@ -1159,7 +1155,7 @@ final class GenerativeModelTests: XCTestCase {
 
   func testCountTokens_succeeds() async throws {
     MockURLProtocol.requestHandler = try httpRequestHandler(
-      forResource: "success-total-tokens",
+      forResource: "unary-success-total-tokens",
       withExtension: "json"
     )
 
@@ -1171,7 +1167,7 @@ final class GenerativeModelTests: XCTestCase {
 
   func testCountTokens_succeeds_noBillableCharacters() async throws {
     MockURLProtocol.requestHandler = try httpRequestHandler(
-      forResource: "success-no-billable-characters",
+      forResource: "unary-success-no-billable-characters",
       withExtension: "json"
     )
 
@@ -1186,7 +1182,7 @@ final class GenerativeModelTests: XCTestCase {
 
   func testCountTokens_modelNotFound() async throws {
     MockURLProtocol.requestHandler = try httpRequestHandler(
-      forResource: "failure-model-not-found", withExtension: "json",
+      forResource: "unary-failure-model-not-found", withExtension: "json",
       statusCode: 404
     )
 
@@ -1207,7 +1203,7 @@ final class GenerativeModelTests: XCTestCase {
     let expectedTimeout = 150.0
     MockURLProtocol
       .requestHandler = try httpRequestHandler(
-        forResource: "success-total-tokens",
+        forResource: "unary-success-total-tokens",
         withExtension: "json",
         timeout: expectedTimeout
       )

+ 1 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-empty-content.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-empty-content.txt

@@ -1 +1,2 @@
 data: {"candidates": [{"content": {},"index": 0}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
+

+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-error-mid-stream.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-error-mid-stream.txt


+ 2 - 0
FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-finish-reason-safety.txt

@@ -0,0 +1,2 @@
+data: {"candidates": [{"content": {"parts": [{"text": "<redacted>"}],"role": "model"},"finishReason": "SAFETY","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "HIGH"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
+

+ 1 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-invalid-json.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-invalid-json.txt

@@ -1 +1,2 @@
 data: {"this": [{"is": {"not": [{"a": "valid"}]}, "response": {}}]}
+

+ 1 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-malformed-content.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-malformed-content.txt

@@ -1 +1,2 @@
 data: {"candidates": [{"content": {"missing-parts": true},"index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_TOXICITY","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_VIOLENCE","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_TOXICITY","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_VIOLENCE","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
+

+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-prompt-blocked-safety.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-prompt-blocked-safety.txt


+ 6 - 0
FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-recitation-no-content.txt

@@ -0,0 +1,6 @@
+data: {"candidates": [{"content": {"parts": [{"text": "Copyrighted text goes here"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
+
+data: {"candidates": [{"content": {"parts": [{"text": "More copyrighted text"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "LOW"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}],"citationMetadata": {"citations": [{"startIndex": 30,"endIndex": 179,"uri": "https://www.example.com","license": ""}]}}]}
+
+data: {"candidates": [{"finishReason": "RECITATION","index": 0}]}
+

+ 1 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-unknown-finish-enum.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-failure-unknown-finish-enum.txt

@@ -9,3 +9,4 @@ data: {"candidates": [{"content": {"parts": [{"text": ", flexible tails that the
 data: {"candidates": [{"content": {"parts": [{"text": "ls.\n\n- **Health and Care:**\n  - Diet: Cats are obligate carnivores, meaning they require animal-based protein for optimal health.\n  - Grooming: Cats spend a significant amount of time grooming themselves to keep their fur clean and free of mats.\n  - Exercise: Cats need regular exercise to stay healthy and active. This can be achieved through play sessions or access to outdoor space.\n  - Veterinary Care: Regular veterinary checkups are essential for maintaining a cat's health and detecting any potential health issues early on.\n\n**Dogs:**\n\n- **Physical Characteristics:**\n  - Size: Dogs come in a wide range of sizes, from small breeds like the Chihuahua to giant breeds like the Great Dane.\n  - Fur: Dogs have fur coats that can vary in length, texture, and color depending on the breed.\n  - Eyes: Dogs have expressive eyes that can be various colors, including brown, blue, green, and hazel.\n  - Ears: Dogs have floppy or erect ears that are sensitive to sound.\n  - Tail: Dogs have long, wagging tails that they use for communication and expressing emotions.\n\n- **Behavior and Personality:**\n  - Loyal: Dogs are known for their loyalty and"}]},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
 
 data: {"candidates": [{"content": {"parts": [{"text": " devotion to their owners.\n  - Friendly: Dogs are generally friendly and outgoing animals that enjoy interacting with people and other animals.\n  - Playful: Dogs are playful and energetic creatures that love to engage in activities such as fetching, running, and playing with toys.\n  - Trainable: Dogs are highly trainable and can learn a variety of commands and tricks.\n  - Vocal: Dogs communicate through a variety of vocalizations, including barking, howling, whining, and growling.\n\n- **Health and Care:**\n  - Diet: Dogs are omnivores and can eat a variety of foods, including meat, vegetables, and grains.\n  - Grooming: Dogs require regular grooming to keep their fur clean and free of mats. The frequency of grooming depends on the breed and coat type.\n  - Exercise: Dogs need regular exercise to stay healthy and active. The amount of exercise required varies depending on the breed and age of the dog.\n  - Veterinary Care: Regular veterinary checkups are essential for maintaining a dog's health and detecting any potential health issues early on."}]},"finishReason": "FAKE_ENUM","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT_NEW_ENUM","probability": "NEGLIGIBLE_UNKNOWN_ENUM"}]}]}
+

+ 12 - 0
FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-long.txt

@@ -0,0 +1,12 @@
+data: {"candidates": [{"content": {"parts": [{"text": "**Cats:**\n\n- **Physical Characteristics:**\n  - Size: Cats come"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
+
+data: {"candidates": [{"content": {"parts": [{"text": " in a wide range of sizes, from small breeds like the Singapura to large breeds like the Maine Coon.\n  - Fur: Cats have soft, furry coats"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": " that can vary in length and texture depending on the breed.\n  - Eyes: Cats have large, expressive eyes that can be various colors, including green, blue, yellow, and hazel.\n  - Ears: Cats have pointed, erect ears that are sensitive to sound.\n  - Tail: Cats have long"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": ", flexible tails that they use for balance and communication.\n\n- **Behavior and Personality:**\n  - Independent: Cats are often described as independent animals that enjoy spending time alone.\n  - Affectionate: Despite their independent nature, cats can be very affectionate and form strong bonds with their owners.\n  - Playful: Cats are naturally playful and enjoy engaging in activities such as chasing toys, climbing, and pouncing.\n  - Curious: Cats are curious creatures that love to explore their surroundings.\n  - Vocal: Cats communicate through a variety of vocalizations, including meows, purrs, hisses, and grow"}]},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": "ls.\n\n- **Health and Care:**\n  - Diet: Cats are obligate carnivores, meaning they require animal-based protein for optimal health.\n  - Grooming: Cats spend a significant amount of time grooming themselves to keep their fur clean and free of mats.\n  - Exercise: Cats need regular exercise to stay healthy and active. This can be achieved through play sessions or access to outdoor space.\n  - Veterinary Care: Regular veterinary checkups are essential for maintaining a cat's health and detecting any potential health issues early on.\n\n**Dogs:**\n\n- **Physical Characteristics:**\n  - Size: Dogs come in a wide range of sizes, from small breeds like the Chihuahua to giant breeds like the Great Dane.\n  - Fur: Dogs have fur coats that can vary in length, texture, and color depending on the breed.\n  - Eyes: Dogs have expressive eyes that can be various colors, including brown, blue, green, and hazel.\n  - Ears: Dogs have floppy or erect ears that are sensitive to sound.\n  - Tail: Dogs have long, wagging tails that they use for communication and expressing emotions.\n\n- **Behavior and Personality:**\n  - Loyal: Dogs are known for their loyalty and"}]},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": " devotion to their owners.\n  - Friendly: Dogs are generally friendly and outgoing animals that enjoy interacting with people and other animals.\n  - Playful: Dogs are playful and energetic creatures that love to engage in activities such as fetching, running, and playing with toys.\n  - Trainable: Dogs are highly trainable and can learn a variety of commands and tricks.\n  - Vocal: Dogs communicate through a variety of vocalizations, including barking, howling, whining, and growling.\n\n- **Health and Care:**\n  - Diet: Dogs are omnivores and can eat a variety of foods, including meat, vegetables, and grains.\n  - Grooming: Dogs require regular grooming to keep their fur clean and free of mats. The frequency of grooming depends on the breed and coat type.\n  - Exercise: Dogs need regular exercise to stay healthy and active. The amount of exercise required varies depending on the breed and age of the dog.\n  - Veterinary Care: Regular veterinary checkups are essential for maintaining a dog's health and detecting any potential health issues early on."}]},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+

+ 16 - 15
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-basic-reply-long.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-parts.txt

@@ -1,15 +1,16 @@
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "1 "}]}}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "2 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.0394904,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04468087},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.034553625,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.03890198},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.09401018,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.025809621},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.036562506,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.047691282}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "3 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.03507868,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.045183755},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.027742893,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.043528143},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.08803312,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.026105914},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.06681233,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.053899158}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "4 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.037750278,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05089372},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.040087357,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05888469},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.071202725,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.034100424},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.07613248,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.051749535}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "5 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.04672496,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.059210256},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.04977345,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05623635},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.083890386,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.03825006},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.08359067,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05975658}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "6 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.07779744,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.06052939},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.041930523,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.056756895},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.12787028,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05350215},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.09203286,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.048676573}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "7 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.071202725,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05291181},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.031439852,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04509957},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.11417085,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04922211},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.09451043,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.052716404}]}]}
-
-data: {"candidates": [{"content": {"role": "model","parts": [{"text": "8"}]},"finishReason": "STOP","safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.06221698,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.045777276},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.03085051,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04560694},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.0992954,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.040769264},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.100701615,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.061424047}]}],"usageMetadata": {"promptTokenCount": 6,"candidatesTokenCount": 326,"totalTokenCount": 332}}
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "1 "}]}}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "2 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.0394904,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04468087},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.034553625,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.03890198},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.09401018,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.025809621},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.036562506,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.047691282}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "3 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.03507868,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.045183755},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.027742893,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.043528143},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.08803312,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.026105914},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.06681233,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.053899158}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "4 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.037750278,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05089372},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.040087357,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05888469},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.071202725,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.034100424},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.07613248,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.051749535}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "5 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.04672496,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.059210256},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.04977345,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05623635},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.083890386,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.03825006},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.08359067,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05975658}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "6 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.07779744,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.06052939},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.041930523,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.056756895},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.12787028,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05350215},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.09203286,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.048676573}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "7 "}]},"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.071202725,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.05291181},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.031439852,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04509957},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.11417085,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04922211},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.09451043,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.052716404}]}]}
+
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "8"}]},"finishReason": "STOP","safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.06221698,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.045777276},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.03085051,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.04560694},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.0992954,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.040769264},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.100701615,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.061424047}]}],"usageMetadata": {"promptTokenCount": 6,"candidatesTokenCount": 326,"totalTokenCount": 332}}
+

+ 2 - 0
FirebaseVertexAI/Tests/Unit/Responses/streaming-success-basic-reply-short.txt

@@ -0,0 +1,2 @@
+data: {"candidates": [{"content": {"role": "model","parts": [{"text": "Cheyenne"}]},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE","probabilityScore": 0.02854415,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.052424565},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE","probabilityScore": 0.24926445,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.0996453},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE","probabilityScore": 0.087096825,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.043123372},{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE","probabilityScore": 0.14402841,"severity": "HARM_SEVERITY_NEGLIGIBLE","severityScore": 0.086169556}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]},"usageMetadata": {"promptTokenCount": 6,"candidatesTokenCount": 4,"totalTokenCount": 10}}
+

+ 12 - 0
FirebaseVertexAI/Tests/Unit/Responses/streaming-success-citations.txt

@@ -0,0 +1,12 @@
+data: {"candidates": [{"content": {"parts": [{"text": "1. **Definition:**\nQuantum mechanics is a fundamental theory in physics that provides"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": " the foundation for understanding the physical properties of nature at the scale of atoms and subatomic particles. It is based on the idea that energy, momentum, angular momentum"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": ", and other quantities are quantized, meaning they can exist only in discrete values. \n\n2. **Key Concepts:**\n   - **Wave-particle Duality:** Particles such as electrons and photons can exhibit both wave-like and particle-like behaviors. \n   - **Uncertainty Principle:** Proposed by Werner"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": " Heisenberg, it states that the more precisely the position of a particle is known, the less precisely its momentum can be known, and vice versa. \n   - **Superposition:** A quantum system can exist in multiple states simultaneously until it is observed or measured, at which point it \"collapses\" into a single state.\n   - **Quantum Entanglement:** Two or more particles can become correlated in such a way that the state of one particle cannot be described independently of the other, even when they are separated by large distances. \n\n3. **Applications:**\n   - **Quantum Computing:** It explores the use of quantum"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}],"citationMetadata": {"citations": [{"startIndex": 574,"endIndex": 705,"uri": "https://www.example.com","license": ""},{"startIndex": 899,"endIndex": 1026,"uri": "https://www.example.com","license": ""}]}}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": "-mechanical phenomena to perform complex calculations and solve problems that are intractable for classical computers. \n   - **Quantum Cryptography:** Utilizes the principles of quantum mechanics to develop secure communication channels. \n   - **Quantum Imaging:** Employs quantum effects to enhance the resolution and sensitivity of imaging techniques in fields such as microscopy and medical imaging. \n   - **Quantum Sensors:** Leverages quantum properties to develop highly sensitive sensors for detecting magnetic fields, accelerations, and other physical quantities. \n\n4. **Learning Resources:**\n   - **Books:**\n     - \"Quantum Mechanics for Mathematicians\" by James Glimm and Arthur Jaffe\n     - \"Principles of Quantum Mechanics\" by R. Shankar\n     - \"Quantum Mechanics: Concepts and Applications\" by Nouredine Zettili\n   - **Online Courses:**\n     - \"Quantum Mechanics I\" by MIT OpenCourseWare\n     - \"Quantum Mechanics for Everyone\" by Coursera\n     - \"Quantum Mechanics\" by Stanford Online\n   - **Documentaries and Videos:**\n     - \"Quantum Mechanics: The Strangest Theory\" (BBC Documentary)\n     - \"Quantum Mechanics Explained Simply\" by Veritasium (YouTube Channel)\n     - \"What is Quantum Mechanics?\" by Minute"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}],"citationMetadata": {"citations": [{"startIndex": 574,"endIndex": 705,"uri": "https://www.example.com","license": ""},{"startIndex": 899,"endIndex": 1026,"uri": "https://www.example.com","license": ""}]}}]}
+
+data: {"candidates": [{"content": {"parts": [{"text": "Physics (YouTube Channel)"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}],"citationMetadata": {"citations": [{"startIndex": 574,"endIndex": 705,"uri": "https://www.example.com","license": ""},{"startIndex": 899,"endIndex": 1026,"uri": "https://www.example.com","license": ""}]}}]}
+

+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-unknown-safety-enum.txt → FirebaseVertexAI/Tests/Unit/Responses/streaming-success-unknown-safety-enum.txt


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-api-key.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-api-key.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-empty-content.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-empty-content.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-finish-reason-safety-no-content.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-finish-reason-safety-no-content.json


+ 54 - 0
FirebaseVertexAI/Tests/Unit/Responses/unary-failure-finish-reason-safety.json

@@ -0,0 +1,54 @@
+{
+  "candidates": [
+    {
+      "content": {
+        "parts": [
+          {
+            "text": "<redacted>"
+          }
+        ],
+        "role": "model"
+      },
+      "finishReason": "SAFETY",
+      "index": 0,
+      "safetyRatings": [
+        {
+          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
+          "probability": "NEGLIGIBLE"
+        },
+        {
+          "category": "HARM_CATEGORY_HATE_SPEECH",
+          "probability": "HIGH"
+        },
+        {
+          "category": "HARM_CATEGORY_HARASSMENT",
+          "probability": "NEGLIGIBLE"
+        },
+        {
+          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
+          "probability": "NEGLIGIBLE"
+        }
+      ]
+    }
+  ],
+  "promptFeedback": {
+    "safetyRatings": [
+      {
+        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
+        "probability": "NEGLIGIBLE"
+      },
+      {
+        "category": "HARM_CATEGORY_HATE_SPEECH",
+        "probability": "NEGLIGIBLE"
+      },
+      {
+        "category": "HARM_CATEGORY_HARASSMENT",
+        "probability": "NEGLIGIBLE"
+      },
+      {
+        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
+        "probability": "NEGLIGIBLE"
+      }
+    ]
+  }
+}

+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-firebaseml-api-not-enabled.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-firebaseml-api-not-enabled.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-image-rejected.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-image-rejected.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-invalid-response.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-invalid-response.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-malformed-content.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-malformed-content.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/CountTokenResponses/failure-model-not-found.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-model-not-found.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-prompt-blocked-safety.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-prompt-blocked-safety.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-unknown-enum-finish-reason.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-enum-finish-reason.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-unknown-enum-prompt-blocked.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-enum-prompt-blocked.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-unknown-model.json → FirebaseVertexAI/Tests/Unit/Responses/unary-failure-unknown-model.json


Diff do ficheiro suprimidas por serem muito extensas
+ 7 - 0
FirebaseVertexAI/Tests/Unit/Responses/unary-success-basic-reply-long.json


+ 2 - 1
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-basic-reply-short.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-basic-reply-short.json

@@ -5,10 +5,11 @@
         "role": "model",
         "parts": [
           {
-            "text": "Mountain View, California, United States"
+            "text": "Mountain View, California"
           }
         ]
       },
+      "index": 0,
       "finishReason": "STOP",
       "safetyRatings": [
         {

+ 1 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-citations.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-citations.json

@@ -10,6 +10,7 @@
         ]
       },
       "finishReason": "STOP",
+      "index": 0,
       "safetyRatings": [
         {
           "category": "HARM_CATEGORY_HATE_SPEECH",

+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-function-call-empty-arguments.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-empty-arguments.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-function-call-mixed-content.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-mixed-content.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-function-call-no-arguments.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-no-arguments.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-function-call-parallel-calls.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-parallel-calls.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-function-call-with-arguments.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-function-call-with-arguments.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-missing-safety-ratings.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-missing-safety-ratings.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/CountTokenResponses/success-no-billable-characters.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-no-billable-characters.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-quote-reply.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-quote-reply.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/CountTokenResponses/success-total-tokens.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-total-tokens.json


+ 0 - 0
FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-unknown-enum-safety-ratings.json → FirebaseVertexAI/Tests/Unit/Responses/unary-success-unknown-enum-safety-ratings.json


+ 1 - 2
Package.swift

@@ -1378,8 +1378,7 @@ let package = Package(
       dependencies: ["FirebaseVertexAI", "SharedTestUtilities"],
       path: "FirebaseVertexAI/Tests/Unit",
       resources: [
-        .process("CountTokenResponses"),
-        .process("GenerateContentResponses"),
+        .process("Responses"),
       ],
       cSettings: [
         .headerSearchPath("../../../"),

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff