Skip to content

Commit 0e57413

Browse files
committed
make inputs required
1 parent 1793936 commit 0e57413

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

packages/firebase_ai/firebase_ai/example/lib/pages/server_template_page.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,8 @@ class _ServerTemplatePageState extends State<ServerTemplatePage> {
390390
});
391391

392392
try {
393-
var response = await _templateGenerativeModel?.generateContent(
394-
'new-greeting',
395-
);
393+
var response = await _templateGenerativeModel
394+
?.generateContent('new-greeting', inputs: {});
396395

397396
_messages.add(MessageData(text: response?.text, fromUser: false));
398397

packages/firebase_ai/firebase_ai/lib/src/server_template/template_chat.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ final class TemplateChatSession {
3535

3636
final Future<GenerateContentResponse> Function(
3737
Iterable<Content> content, String templateId,
38-
{Map<String, Object?>? inputs}) _templateHistoryGenerateContent;
38+
{required Map<String, Object?> inputs}) _templateHistoryGenerateContent;
3939

4040
final Stream<GenerateContentResponse> Function(
41-
Iterable<Content> content, String templateId,
42-
{Map<String, Object?>? inputs}) _templateHistoryGenerateContentStream;
41+
Iterable<Content> content, String templateId,
42+
{required Map<String, Object?> inputs})
43+
_templateHistoryGenerateContentStream;
4344
final String _templateId;
4445
final List<Content> _history;
4546

@@ -62,7 +63,7 @@ final class TemplateChatSession {
6263
/// When there are no candidates in the response, the [message] and response
6364
/// are ignored and will not be recorded in the [history].
6465
Future<GenerateContentResponse> sendMessage(Content message,
65-
{Map<String, Object?>? inputs}) async {
66+
{required Map<String, Object?> inputs}) async {
6667
final lock = await _mutex.acquire();
6768
try {
6869
final response = await _templateHistoryGenerateContent(
@@ -95,7 +96,7 @@ final class TemplateChatSession {
9596
/// When there are no candidates in the response, the [message] and response
9697
/// are ignored and will not be recorded in the [history].
9798
Stream<GenerateContentResponse> sendMessageStream(Content message,
98-
{Map<String, Object?>? inputs}) {
99+
{required Map<String, Object?> inputs}) {
99100
final controller = StreamController<GenerateContentResponse>(sync: true);
100101
_mutex.acquire().then((lock) async {
101102
try {

packages/firebase_ai/firebase_ai/lib/src/server_template/template_generative_model.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ final class TemplateGenerativeModel extends BaseTemplateApiClientModel {
7474
/// Sends a "templateGenerateContent" API request for the configured model.
7575
@experimental
7676
Future<GenerateContentResponse> generateContent(String templateId,
77-
{Map<String, Object?>? inputs}) =>
77+
{required Map<String, Object?> inputs}) =>
7878
makeTemplateRequest(TemplateTask.templateGenerateContent, templateId,
7979
inputs, null, _serializationStrategy.parseGenerateContentResponse);
8080

@@ -84,7 +84,7 @@ final class TemplateGenerativeModel extends BaseTemplateApiClientModel {
8484
/// and waits for the response.
8585
@experimental
8686
Stream<GenerateContentResponse> generateContentStream(String templateId,
87-
{Map<String, Object?>? inputs}) {
87+
{required Map<String, Object?> inputs}) {
8888
return streamTemplateRequest(
8989
TemplateTask.templateStreamGenerateContent,
9090
templateId,
@@ -98,7 +98,7 @@ final class TemplateGenerativeModel extends BaseTemplateApiClientModel {
9898
@experimental
9999
Future<GenerateContentResponse> templateGenerateContentWithHistory(
100100
Iterable<Content> history, String templateId,
101-
{Map<String, Object?>? inputs}) =>
101+
{required Map<String, Object?> inputs}) =>
102102
makeTemplateRequest(TemplateTask.templateGenerateContent, templateId,
103103
inputs, history, _serializationStrategy.parseGenerateContentResponse);
104104

@@ -107,7 +107,7 @@ final class TemplateGenerativeModel extends BaseTemplateApiClientModel {
107107
@experimental
108108
Stream<GenerateContentResponse> templateGenerateContentWithHistoryStream(
109109
Iterable<Content> history, String templateId,
110-
{Map<String, Object?>? inputs}) {
110+
{required Map<String, Object?> inputs}) {
111111
return streamTemplateRequest(
112112
TemplateTask.templateStreamGenerateContent,
113113
templateId,

packages/firebase_ai/firebase_ai/lib/src/server_template/template_imagen_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ final class TemplateImagenModel extends BaseTemplateApiClientModel {
6666
@experimental
6767
Future<ImagenGenerationResponse<ImagenInlineImage>> generateImages(
6868
String templateId,
69-
{Map<String, Object?>? inputs}) =>
69+
{required Map<String, Object?> inputs}) =>
7070
makeTemplateRequest(
7171
TemplateTask.templatePredict,
7272
templateId,

0 commit comments

Comments
 (0)