Skip to content

Commit

Permalink
Merge pull request #1954 from matthiasn/feat/ai_prompt_refinement
Browse files Browse the repository at this point in the history
feat: add AI response type & Flutter 3.29.1
  • Loading branch information
matthiasn authored Mar 8, 2025
2 parents 6c5c96e + 9d5bb58 commit d10dc21
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .fvm/flutter_sdk
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutterSdkVersion": "3.29.0"
"flutterSdkVersion": "3.29.1"
}
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.29.0"
"flutter": "3.29.1"
}
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ SPEC CHECKSUMS:
audio_session: 19e9480dbdd4e5f6c4543826b2e8b0e4ab6145fe
connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
ffmpeg-kit-ios-https: f9c838aa5400a6c5ba12324c6b798f52197ba354
ffmpeg-kit-ios-https: ac1fbdb6095fc1595b446084a3447de2c6d78347
ffmpeg_kit_flutter: b4ca70cac3fc1d8ac14cdc660754b60870358732
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_health_fit: af332b5d7512b9cc8a05e7282cfcee02b056d32e
Expand Down
1 change: 1 addition & 0 deletions lib/classes/entity_definitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class AiResponseData with _$AiResponseData {
required String prompt,
required String thoughts,
required String response,
String? type,
double? temperature,
}) = _AiResponseData;

Expand Down
24 changes: 22 additions & 2 deletions lib/classes/entity_definitions.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5521,6 +5521,7 @@ mixin _$AiResponseData {
String get prompt => throw _privateConstructorUsedError;
String get thoughts => throw _privateConstructorUsedError;
String get response => throw _privateConstructorUsedError;
String? get type => throw _privateConstructorUsedError;
double? get temperature => throw _privateConstructorUsedError;

/// Serializes this AiResponseData to a JSON map.
Expand All @@ -5545,6 +5546,7 @@ abstract class $AiResponseDataCopyWith<$Res> {
String prompt,
String thoughts,
String response,
String? type,
double? temperature});
}

Expand All @@ -5568,6 +5570,7 @@ class _$AiResponseDataCopyWithImpl<$Res, $Val extends AiResponseData>
Object? prompt = null,
Object? thoughts = null,
Object? response = null,
Object? type = freezed,
Object? temperature = freezed,
}) {
return _then(_value.copyWith(
Expand All @@ -5591,6 +5594,10 @@ class _$AiResponseDataCopyWithImpl<$Res, $Val extends AiResponseData>
? _value.response
: response // ignore: cast_nullable_to_non_nullable
as String,
type: freezed == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String?,
temperature: freezed == temperature
? _value.temperature
: temperature // ignore: cast_nullable_to_non_nullable
Expand All @@ -5613,6 +5620,7 @@ abstract class _$$AiResponseDataImplCopyWith<$Res>
String prompt,
String thoughts,
String response,
String? type,
double? temperature});
}

Expand All @@ -5634,6 +5642,7 @@ class __$$AiResponseDataImplCopyWithImpl<$Res>
Object? prompt = null,
Object? thoughts = null,
Object? response = null,
Object? type = freezed,
Object? temperature = freezed,
}) {
return _then(_$AiResponseDataImpl(
Expand All @@ -5657,6 +5666,10 @@ class __$$AiResponseDataImplCopyWithImpl<$Res>
? _value.response
: response // ignore: cast_nullable_to_non_nullable
as String,
type: freezed == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String?,
temperature: freezed == temperature
? _value.temperature
: temperature // ignore: cast_nullable_to_non_nullable
Expand All @@ -5674,6 +5687,7 @@ class _$AiResponseDataImpl implements _AiResponseData {
required this.prompt,
required this.thoughts,
required this.response,
this.type,
this.temperature});

factory _$AiResponseDataImpl.fromJson(Map<String, dynamic> json) =>
Expand All @@ -5690,11 +5704,13 @@ class _$AiResponseDataImpl implements _AiResponseData {
@override
final String response;
@override
final String? type;
@override
final double? temperature;

@override
String toString() {
return 'AiResponseData(model: $model, systemMessage: $systemMessage, prompt: $prompt, thoughts: $thoughts, response: $response, temperature: $temperature)';
return 'AiResponseData(model: $model, systemMessage: $systemMessage, prompt: $prompt, thoughts: $thoughts, response: $response, type: $type, temperature: $temperature)';
}

@override
Expand All @@ -5710,14 +5726,15 @@ class _$AiResponseDataImpl implements _AiResponseData {
other.thoughts == thoughts) &&
(identical(other.response, response) ||
other.response == response) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.temperature, temperature) ||
other.temperature == temperature));
}

@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, model, systemMessage, prompt,
thoughts, response, temperature);
thoughts, response, type, temperature);

/// Create a copy of AiResponseData
/// with the given fields replaced by the non-null parameter values.
Expand All @@ -5743,6 +5760,7 @@ abstract class _AiResponseData implements AiResponseData {
required final String prompt,
required final String thoughts,
required final String response,
final String? type,
final double? temperature}) = _$AiResponseDataImpl;

factory _AiResponseData.fromJson(Map<String, dynamic> json) =
Expand All @@ -5759,6 +5777,8 @@ abstract class _AiResponseData implements AiResponseData {
@override
String get response;
@override
String? get type;
@override
double? get temperature;

/// Create a copy of AiResponseData
Expand Down
2 changes: 2 additions & 0 deletions lib/classes/entity_definitions.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/database/conversions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import 'package:lotti/database/database.dart';

JournalDbEntity toDbEntity(JournalEntity entity) {
final createdAt = entity.meta.createdAt;

final subtype = entity.maybeMap(
quantitative: (QuantitativeEntry entry) => entry.data.dataType,
measurement: (MeasurementEntry entry) => entry.data.dataTypeId,
survey: (SurveyEntry entry) =>
entry.data.taskResult.identifier.toLowerCase(),
workout: (WorkoutEntry entry) => entry.data.workoutType,
habitCompletion: (HabitCompletionEntry entry) => entry.data.habitId,
aiResponse: (AiResponseEntry entry) => entry.data.type,
orElse: () => '',
);

Expand Down
2 changes: 1 addition & 1 deletion lib/features/ai/state/latest_summary_controller.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions lib/features/ai/state/ollama_task_checklist_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,23 @@ class AiTaskChecklistSummaryController
return;
}

const systemMessage =
'The prompt is a markdown document describing a task, with the '
'logbook of the completion of the task, including transcripts of '
'audio recordings, and images, for example screenshots. '
'Also, there is a array of already defined and tracked checklist items, '
'as JSON. Your job is to find new TODOs that are not mentioned here yet, '
'but only in the logbook of the task. '
'This may be empty if the task has no checklist items yet. '
'Summarize the task and the achieved results, and the remaining steps '
'that have not been completed yet. '
'Note any learnings or insights that can be drawn from the task, if any. '
'Note that the logbook is in reverse chronological order. '
'Keep it short and succinct. '
'At the end of the response, add a list of '
'TODOs/checklist items that are new and not already tracked, where '
'each item is prefixed with the String "TODO: ". ';
const systemMessage = '''
The prompt is a markdown document describing a task, with the
logbook of the completion of the task, including transcripts of
audio recordings, and images, for example screenshots.
Also, there is a array of already defined and tracked checklist items,
as JSON. Your job is to find new TODOs that are not mentioned here yet,
but only in the logbook of the task.
This may be empty if the task has no checklist items yet.
Summarize the task and the achieved results, and the remaining steps
that have not been completed yet.
Note any learnings or insights that can be drawn from the task, if any.
Note that the logbook is in reverse chronological order.
Keep it short and succinct.
At the end of the response, add a list of
TODOs/checklist items that are new and not already tracked, where
each item is prefixed with the String "TODO: ".
''';

final buffer = StringBuffer();

Expand Down Expand Up @@ -80,6 +81,7 @@ class AiTaskChecklistSummaryController
prompt: markdown,
thoughts: thoughts.replaceAll('<think>', ''),
response: response,
type: 'TaskSummary',
);

await getIt<PersistenceLogic>().createAiResponseEntry(
Expand Down
2 changes: 1 addition & 1 deletion macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ SPEC CHECKSUMS:
connectivity_plus: 0a976dfd033b59192912fa3c6c7b54aab5093802
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
device_info_plus: 1b14eed9bf95428983aed283a8d51cce3d8c4215
ffmpeg-kit-macos-https: 60de703db964ccca7fd0d4d1611f4c102a8139cc
ffmpeg-kit-macos-https: 8fe9a5bdb2a42ecb2caf067522aa9a8ce386294e
ffmpeg_kit_flutter: 5bd75928cf88ec177cea410b027681e4bfe09452
file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d
flutter_image_compress_macos: c26c3c13ea0f28ae6dea4e139b3292e7729f99f1
Expand Down
Loading

0 comments on commit d10dc21

Please sign in to comment.