Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danemadsen committed Jul 15, 2024
1 parent e6ef415 commit 62fc9f6
Show file tree
Hide file tree
Showing 62 changed files with 208 additions and 294 deletions.
5 changes: 5 additions & 0 deletions lib/classes/providers/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class Session extends ChangeNotifier {
fromMap(inputJson);
}

void reset() {
newSession();
notifyListeners();
}

static Future<Session> get last async {
final prefs = await SharedPreferences.getInstance();

Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/frequency_penalty_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class FrequencyPenaltyParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Frequency Penalty',
inputValue: session.model.penaltyFreq,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/last_n_penalty_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class LastNPenaltyParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Last N Penalty',
inputValue: session.model.penaltyLastN,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/min_p_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class MinPParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'MinP',
inputValue: session.model.minP,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/mirostat_eta_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class MirostatEtaParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'MirostatEta',
inputValue: session.model.mirostatEta,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/mirostat_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class MirostatParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Mirostat',
inputValue: session.model.mirostat,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/mirostat_tau_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class MirostatTauParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'MirostatTau',
inputValue: session.model.mirostatTau,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/n_batch_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class NBatchParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'NBatch',
inputValue: session.model.nBatch,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/n_ctx_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class NCtxParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'NCtx',
inputValue: session.model.nCtx,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/n_keep_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class NKeepParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'NKeep',
inputValue: session.model.nKeep,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/n_predict_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class NPredictParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'NPredict',
inputValue: session.model.nPredict,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/n_threads_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/enumerators/large_language_model_type.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -11,10 +11,8 @@ class NThreadsParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'NThreads',
inputValue: session.model.nThread,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/penalize_nl_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/switch_container.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,14 +8,12 @@ class PenalizeNlParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
return Consumer<Session>(
builder: buildSwitchContainer
);
}

Widget buildSwitchContainer(BuildContext context, AppData appData, Widget? child) {
final session = appData.currentSession;

Widget buildSwitchContainer(BuildContext context, Session session, Widget? child) {
return SwitchContainer(
title: 'Penalize New Line',
initialValue: session.model.penalizeNewline,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/present_penalty_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class PresentPenaltyParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Presence Penalty',
inputValue: session.model.penaltyPresent,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/repeat_penalty_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class RepeatPenaltyParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Repeat Penalty',
inputValue: session.model.penaltyRepeat,
Expand Down
7 changes: 2 additions & 5 deletions lib/ui/desktop/parameters/seed_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/large_language_model.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:provider/provider.dart';

Expand All @@ -16,16 +15,14 @@ class SeedParameter extends StatelessWidget {
color: Theme.of(context).colorScheme.surfaceDim,
borderRadius: BorderRadius.circular(8.0)
),
child: Consumer<AppData>(
child: Consumer<Session>(
builder: buildColumn
),
)
);
}

Widget buildColumn(BuildContext context, AppData appData, Widget? child) {
final session = appData.currentSession;

Widget buildColumn(BuildContext context, Session session, Widget? child) {
TextEditingController controller = TextEditingController(
text: LargeLanguageModel.of(context).seed.toString()
);
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/temperature_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class TemperatureParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'Temperature',
inputValue: session.model.temperature,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/tfs_z_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class TfsZParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'TfsZ',
inputValue: session.model.tfsZ,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/desktop/parameters/top_k_parameter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:maid/classes/providers/app_data.dart';
import 'package:maid/classes/providers/session.dart';
import 'package:maid/ui/shared/tiles/slider_grid_tile.dart';
import 'package:provider/provider.dart';

Expand All @@ -8,10 +8,8 @@ class TopKParameter extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Consumer<AppData>(
builder: (context, appData, child) {
final session = appData.currentSession;

return Consumer<Session>(
builder: (context, session, child) {
return SliderGridTile(
labelText: 'TopK',
inputValue: session.model.topK,
Expand Down
Loading

0 comments on commit 62fc9f6

Please sign in to comment.