@@ -21,11 +21,50 @@ import { CountTokensRequest, GenerateContentRequest } from './requests';
2121 * Defines an inference "backend" that uses Chrome's on-device model,
2222 * and encapsulates logic for detecting when on-device is possible.
2323 *
24+ * These methods should not be called directly by the user.
25+ *
2426 * @public
2527 */
2628export interface ChromeAdapter {
29+ /**
30+ * Checks if a given request can be made on-device.
31+ *
32+ * <ol>Encapsulates a few concerns:
33+ * <li>the mode</li>
34+ * <li>API existence</li>
35+ * <li>prompt formatting</li>
36+ * <li>model availability, including triggering download if necessary</li>
37+ * </ol>
38+ *
39+ * <p>Pros: callers needn't be concerned with details of on-device availability.</p>
40+ * <p>Cons: this method spans a few concerns and splits request validation from usage.
41+ * If instance variables weren't already part of the API, we could consider a better
42+ * separation of concerns.</p>
43+ */
2744 isAvailable ( request : GenerateContentRequest ) : Promise < boolean > ;
45+
46+ /**
47+ * Stub - not yet available for on-device.
48+ */
2849 countTokens ( _request : CountTokensRequest ) : Promise < Response > ;
50+
51+ /**
52+ * Generates content on device.
53+ *
54+ * <p>This is comparable to {@link GenerativeModel.generateContent} for generating content in
55+ * Cloud.</p>
56+ * @param request - a standard Firebase AI {@link GenerateContentRequest}
57+ * @returns {@link Response }, so we can reuse common response formatting.
58+ */
2959 generateContent ( request : GenerateContentRequest ) : Promise < Response > ;
60+
61+ /**
62+ * Generates content stream on device.
63+ *
64+ * <p>This is comparable to {@link GenerativeModel.generateContentStream} for generating content in
65+ * Cloud.</p>
66+ * @param request - a standard Firebase AI {@link GenerateContentRequest}
67+ * @returns {@link Response }, so we can reuse common response formatting.
68+ */
3069 generateContentStream ( request : GenerateContentRequest ) : Promise < Response > ;
3170}
0 commit comments