Repository navigation
feat(firebase-ai-logic-basics): extract text, multimodal, chat, and streaming capability guides - #212
AustinBenoit wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Firebase AI Logic SDK documentation by extracting capability-specific examples (such as text generation, multimodal input, chat, and streaming) from platform setup guides into dedicated markdown files. The review feedback highlights several API and syntax errors in the newly created guides across multiple SDKs. Specifically, the Dart SafetySetting constructor is incorrectly documented as accepting three parameters instead of two, the Swift examples incorrectly reference non-existent InlineDataPart and FileDataPart types instead of ModelContent.Part enums, and the Web JavaScript snippets incorrectly include a type property inside Part objects.
| Dart `SafetySetting` constructor has **three positional parameters** | ||
| (`category`, `threshold`, `method`); the third is a nullable `HarmBlockMethod` | ||
| that you can pass as `null`. Prompts are passed as a list of `Content`. |
There was a problem hiding this comment.
| // Third positional argument is an optional HarmBlockMethod; pass null. | ||
| final safetySettings = [ | ||
| SafetySetting(HarmCategory.harassment, HarmBlockThreshold.high, null), | ||
| SafetySetting(HarmCategory.hateSpeech, HarmBlockThreshold.medium, null), | ||
| ]; |
There was a problem hiding this comment.
Remove the third positional argument (null) from the SafetySetting constructor calls, as the Dart SDK only accepts two positional parameters (category and threshold). Passing a third argument will cause a compilation error.
| // Third positional argument is an optional HarmBlockMethod; pass null. | |
| final safetySettings = [ | |
| SafetySetting(HarmCategory.harassment, HarmBlockThreshold.high, null), | |
| SafetySetting(HarmCategory.hateSpeech, HarmBlockThreshold.medium, null), | |
| ]; | |
| final safetySettings = [ | |
| SafetySetting(HarmCategory.harassment, HarmBlockThreshold.high), | |
| SafetySetting(HarmCategory.hateSpeech, HarmBlockThreshold.medium), | |
| ]; |
| let pdf = try InlineDataPart(data: Data(contentsOf: pdfURL), mimeType: "application/pdf") | ||
| // e.g. audio instead: InlineDataPart(data: audioData, mimeType: "audio/mpeg") |
There was a problem hiding this comment.
In the Swift SDK (FirebaseAILogic), there are no InlineDataPart or FileDataPart types. Instead, you should use the ModelContent.Part.inlineData enum case to wrap raw data with a MIME type.
| let pdf = try InlineDataPart(data: Data(contentsOf: pdfURL), mimeType: "application/pdf") | |
| // e.g. audio instead: InlineDataPart(data: audioData, mimeType: "audio/mpeg") | |
| let pdf = ModelContent.Part.inlineData(data: try Data(contentsOf: pdfURL), mimeType: "application/pdf") | |
| // e.g. audio instead: ModelContent.Part.inlineData(data: audioData, mimeType: "audio/mpeg") |
| Cloud Storage for Firebase URL (Agent Platform Gemini API provider only): pass | ||
| `FileDataPart(uri: "gs://bucket-name/path/image.jpg", mimeType: "image/jpeg")` | ||
| in place of the `InlineDataPart`. |
| return { | ||
| type: "inlineData", | ||
| inlineData: { | ||
| data: await base64EncodedDataPromise, | ||
| mimeType: file.type, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
In the Firebase AI Web SDK, the Part object for inline data does not contain a type property. It should only contain the inlineData property. Adding type: "inlineData" is incorrect and may cause validation or runtime errors.
| return { | |
| type: "inlineData", | |
| inlineData: { | |
| data: await base64EncodedDataPromise, | |
| mimeType: file.type, | |
| }, | |
| }; | |
| return { | |
| inlineData: { | |
| data: await base64EncodedDataPromise, | |
| mimeType: file.type, | |
| }, | |
| }; |
| directly with an explicit MIME type: | ||
|
|
||
| ```javascript | ||
| const pdfPart = { type: "inlineData", inlineData: { data: base64Pdf, mimeType: "application/pdf" } }; |
There was a problem hiding this comment.
Remove the type: "inlineData" property from the inline data part object, as it is not supported by the Web SDK's Part type.
| const pdfPart = { type: "inlineData", inlineData: { data: base64Pdf, mimeType: "application/pdf" } }; | |
| const pdfPart = { inlineData: { data: base64Pdf, mimeType: "application/pdf" } }; |
| { | ||
| role: "user", | ||
| parts: [{ type: "text", text: "Hello, I am a developer." }], | ||
| }, | ||
| { | ||
| role: "model", | ||
| parts: [{ type: "text", text: "Great to meet you. How can I help with code?" }], | ||
| }, |
There was a problem hiding this comment.
In the Firebase AI Web SDK, the Part object for text does not contain a type property. It should only contain the text property. Adding type: "text" is incorrect and may cause validation or runtime errors.
| { | |
| role: "user", | |
| parts: [{ type: "text", text: "Hello, I am a developer." }], | |
| }, | |
| { | |
| role: "model", | |
| parts: [{ type: "text", text: "Great to meet you. How can I help with code?" }], | |
| }, | |
| history: [ | |
| { | |
| role: "user", | |
| parts: [{ text: "Hello, I am a developer." }], | |
| }, | |
| { | |
| role: "model", | |
| parts: [{ text: "Great to meet you. How can I help with code?" }], | |
| }, | |
| ], |
92f632f to
2952da8
Compare
2952da8 to
3b2fc6e
Compare
3b2fc6e to
6c656dd
Compare
6c656dd to
f881918
Compare
…treaming capability guides ### Summary (Stack 3/6) Extracts the four core generation patterns out of the per-platform setup guides into unified cross-platform capability guides under `references/sdk/capabilities/` covering Android (Kotlin), iOS (Swift), Flutter (Dart), and Web (JavaScript) side by side. ### Changes - Adds `text_generation.md`, `multimodal_input.md`, `chat.md`, and `streaming.md`. - Removes temporary in-file usage sections from `android_setup.md` and `flutter_setup.md` (reaching their final setup-only state). - Updates `SKILL.md` routing table.
f881918 to
a1889fc
Compare
Summary (Stack 2/5)
Extracts the four core generation patterns out of the per-platform setup guides into unified cross-platform capability guides under
references/sdk/capabilities/covering Android (Kotlin), iOS (Swift), Flutter (Dart), and Web (JavaScript) side by side.Changes
text_generation.md,multimodal_input.md,chat.md, andstreaming.md.android_setup.mdandflutter_setup.md(reaching their final setup-only state).SKILL.mdrouting table.