This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// The Model Widget defines external parameters. | |
| class Page extends StatefulWidget { | |
| const Page({Key? key}) : super(key: key); | |
| @override | |
| PageController createState() => PageController(); | |
| } | |
| /// The Controller handles the state and business logic. | |
| class PageController extends State<Page> { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Return the view appropriate for the device screen size | |
| return LayoutBuilder( | |
| builder: (BuildContext context, BoxConstraints constraints) { | |
| debugPrint('Host device screen width: ${constraints.maxWidth}'); | |
| // Watch-sized device | |
| if (constraints.maxWidth < 300) { | |
| return DailyForecastViewWatch(this); | |
| } | |
| // Phone-sized device | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Partly Windy', | |
| theme: buildLightTheme(), | |
| darkTheme: buildDarkTheme(), | |
| themeMode: ThemeMode.system, | |
| debugShowCheckedModeBanner: false, | |
| home: const DailyForecastRoute(), | |
| ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | AmbientMode( | |
| builder: (BuildContext context, WearMode mode, child) { | |
| return mode == WearMode.active | |
| ? DailyForecastViewWatchActive(state) | |
| : DailyForecastViewWatchAmbient(state); | |
| }, | |
| ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// View for [DailyForecastRoute] for watch-sized devices while the watch | |
| /// is in an ambient mode. | |
| class DailyForecastViewWatchAmbient extends StatelessWidget { | |
| final DailyForecastController state; | |
| const DailyForecastViewWatchAmbient(this.state, {Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// View for [DailyForecastRoute] for watch-sized devices while the watch | |
| /// is in an active mode. | |
| class DailyForecastViewWatchActive extends StatelessWidget { | |
| final DailyForecastController state; | |
| const DailyForecastViewWatchActive(this.state, {Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// Represents the parameters used in the body of a request to the OpenAI completions endpoint. | |
| class CompletionsRequest { | |
| final String model; | |
| final String prompt; | |
| final int maxTokens; | |
| final double? temperature; | |
| final int? topP; | |
| final int? n; | |
| final bool? stream; | |
| final int? longprobs; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | String toJson() { | |
| Map<String, dynamic> jsonBody = { | |
| 'model': model, | |
| 'prompt': prompt, | |
| 'max_tokens': maxTokens, | |
| }; | |
| if (temperature != null) { | |
| jsonBody.addAll({'temperature': temperature}); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class CompletionsResponse { | |
| final String? id; | |
| final String object; | |
| final int? created; | |
| final String? model; | |
| final List<dynamic>? choices; // This list contains the completions | |
| final Map<String, dynamic>? usage; | |
| final int? promptTokens; | |
| final int? completionTokens; | |
| final int? totalTokens; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// Returns a [CompletionResponse] from the JSON obtained from the | |
| /// completions endpoint. | |
| factory CompletionsResponse.fromResponse(Response response) { | |
| // Get the response body in JSON format | |
| Map<String, dynamic> responseBody = json.decode(response.body); | |
| // Parse out information from the response | |
| Map<String, dynamic> usage = responseBody['usage']; | |
| // Parse out the choices | 
OlderNewer