Skip to content

Commit ca5a63e

Browse files
authored
Shorten lines over 80 columns (#13493)
Reflow comments and break long strings into adjacent string literals.
1 parent 35a976a commit ca5a63e

File tree

1 file changed

+23
-17
lines changed
  • packages/firebase_vertexai/firebase_vertexai/example/lib

1 file changed

+23
-17
lines changed

packages/firebase_vertexai/firebase_vertexai/example/lib/main.dart

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ class _ChatWidgetState extends State<ChatWidget> {
103103
});
104104
}
105105

106-
// This is a hypothetical API to return a fake weather data collection for certain location
106+
// This is a hypothetical API to return a fake weather data collection for
107+
// certain location
107108
Future<Map<String, Object?>> fetchWeather(
108109
double latitude,
109110
double longitude,
110111
String date,
111112
) async {
112113
// TODO(developer): Call a real weather API.
113-
// Mock response from the API. In developer live code this would call the external API and return what that API returns.
114+
// Mock response from the API. In developer live code this would call the
115+
// external API and return what that API returns.
114116
final apiResponse = {
115117
'location': '$latitude, $longitude',
116118
'date': date,
@@ -127,24 +129,26 @@ class _ChatWidgetState extends State<ChatWidget> {
127129
'Get the weather conditions for a specific city on a specific date.',
128130
parameters: {
129131
'location': Schema.object(
130-
description:
131-
'The longitude and latitude of the city for which to get the weather. Must always be a nested object of `longitude` and `latitude`. The values must be floats.',
132+
description: 'The longitude and latitude of the city for which to get '
133+
'the weather. Must always be a nested object of '
134+
'`longitude` and `latitude`. The values must be floats.',
132135
properties: {
133136
'latitude': Schema.number(
134137
format: 'float',
135-
description:
136-
'A numeric value indicating the latitude of the desired location between -90 and 90',
138+
description: 'A numeric value indicating the latitude of the '
139+
'desired location between -90 and 90',
137140
),
138141
'longitude': Schema.number(
139142
format: 'float',
140143
description:
141-
'A numeric value indicating the longitude of the desired location between -180 and 180',
144+
'A numeric value indicating the longitude of the desired '
145+
'location between -180 and 180',
142146
),
143147
},
144148
),
145149
'date': Schema.string(
146-
description:
147-
'The date for which to get the weather. Date must be in the format: YYYY-MM-DD.',
150+
description: 'The date for which to get the weather. '
151+
'Date must be in the format: YYYY-MM-DD.',
148152
),
149153
},
150154
);
@@ -532,8 +536,8 @@ class _ChatWidgetState extends State<ChatWidget> {
532536
var latitude = location['latitude']! as double;
533537
var longitude = location['longitude']! as double;
534538
final functionResult = await fetchWeather(latitude, longitude, date);
535-
// Send the response to the model so that it can use the result to generate
536-
// text for the user.
539+
// Send the response to the model so that it can use the result to
540+
// generate text for the user.
537541
response = await functionCallChat.sendMessage(
538542
Content.functionResponse(functionCall.name, functionResult),
539543
);
@@ -560,15 +564,17 @@ class _ChatWidgetState extends State<ChatWidget> {
560564
const prompt = 'tell a short story';
561565
var content = Content.text(prompt);
562566
var tokenResponse = await _model.countTokens([content]);
563-
final tokenResult =
564-
'Count token: ${tokenResponse.totalTokens}, billable characters: ${tokenResponse.totalBillableCharacters}';
567+
final tokenResult = 'Count token: ${tokenResponse.totalTokens}, billable '
568+
'characters: ${tokenResponse.totalBillableCharacters}';
565569
_generatedContent.add((image: null, text: tokenResult, fromUser: false));
566570

567571
var contentResponse = await _model.generateContent([content]);
568-
final contentMetaData =
569-
'result metadata, promptTokenCount:${contentResponse.usageMetadata!.promptTokenCount}, '
570-
'candidatesTokenCount:${contentResponse.usageMetadata!.candidatesTokenCount}, '
571-
'totalTokenCount:${contentResponse.usageMetadata!.totalTokenCount}';
572+
final contentMetaData = 'result metadata, promptTokenCount:'
573+
'${contentResponse.usageMetadata!.promptTokenCount}, '
574+
'candidatesTokenCount:'
575+
'${contentResponse.usageMetadata!.candidatesTokenCount}, '
576+
'totalTokenCount:'
577+
'${contentResponse.usageMetadata!.totalTokenCount}';
572578
_generatedContent
573579
.add((image: null, text: contentMetaData, fromUser: false));
574580
setState(() {

0 commit comments

Comments
 (0)