@@ -49,7 +49,8 @@ Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F,
4949 contents := []* genai.Content {
5050 {Parts : []* genai.Part {
5151 {Text : prompt },
52- }},
52+ },
53+ Role : "user" },
5354 }
5455 config := & genai.GenerateContentConfig {
5556 ResponseMIMEType : "application/json" ,
@@ -63,11 +64,11 @@ Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F,
6364 Items : & genai.Schema {
6465 Type : "object" ,
6566 Properties : map [string ]* genai.Schema {
66- "Day" : {Type : "string" , Nullable : true },
67- "Forecast" : {Type : "string" , Nullable : true },
68- "Temperature" : {Type : "integer" , Nullable : true },
69- "Humidity" : {Type : "string" , Nullable : true },
70- "Wind Speed" : {Type : "integer" , Nullable : true },
67+ "Day" : {Type : "string" , Nullable : genai . Ptr ( true ) },
68+ "Forecast" : {Type : "string" , Nullable : genai . Ptr ( true ) },
69+ "Temperature" : {Type : "integer" , Nullable : genai . Ptr ( true ) },
70+ "Humidity" : {Type : "string" , Nullable : genai . Ptr ( true ) },
71+ "Wind Speed" : {Type : "integer" , Nullable : genai . Ptr ( true ) },
7172 },
7273 Required : []string {"Day" , "Temperature" , "Forecast" , "Wind Speed" },
7374 },
@@ -81,10 +82,8 @@ Finally, Saturday rounds off the week with sunny skies, a temperature of 80°F,
8182 return fmt .Errorf ("failed to generate content: %w" , err )
8283 }
8384
84- respText , err := resp .Text ()
85- if err != nil {
86- return fmt .Errorf ("failed to convert model response to text: %w" , err )
87- }
85+ respText := resp .Text ()
86+
8887 fmt .Fprintln (w , respText )
8988
9089 // Example response:
0 commit comments