Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/AppWithWearable/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = UA6Q3X7F6K;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -387,7 +387,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.6;
PRODUCT_BUNDLE_IDENTIFIER = "com.friend-app-with-wearable.ios12";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -510,7 +510,7 @@
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = UA6Q3X7F6K;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -526,7 +526,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.6;
PRODUCT_BUNDLE_IDENTIFIER = "com.friend-app-with-wearable.ios12";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -544,7 +544,7 @@
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 15;
DEVELOPMENT_TEAM = UA6Q3X7F6K;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -560,7 +560,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.4;
MARKETING_VERSION = 1.0.6;
PRODUCT_BUNDLE_IDENTIFIER = "com.friend-app-with-wearable.ios12";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
6 changes: 3 additions & 3 deletions apps/AppWithWearable/lib/backend/api_requests/api_calls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ dynamic extractContentFromResponse(http.Response? response,
}
return data['choices'][0]['message']['content'];
} else {
// TODO: include a global error handler + memory creation
debugPrint('Error fetching data: ${response?.statusCode}');
return {'error': response?.statusCode};
throw Exception('Error fetching data: ${response?.statusCode}');
// return {'error': response?.statusCode};
}
}

Expand Down Expand Up @@ -108,6 +108,7 @@ Future<String> executeGptPrompt(String? prompt) async {
{'role': 'system', 'content': prompt}
]);
prefs.setGptCompletionCache(promptBase64, response);
debugPrint('executeGptPrompt response: $response');
return response;
}

Expand Down Expand Up @@ -154,7 +155,6 @@ Future<String> generateTitleAndSummaryForMemory(String rawMemory, List<MemoryRec
.replaceAll(' ', '')
.replaceAll(' ', '')
.trim();
debugPrint(prompt);
return (await executeGptPrompt(prompt)).replaceAll('```', '').trim();
}

Expand Down
21 changes: 19 additions & 2 deletions apps/AppWithWearable/lib/pages/home/widgets/transcript.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class TranscriptWidgetState extends State<TranscriptWidget> with WidgetsBindingO
setState(() {
whispersDiarized[whispersDiarized.length - 1] = copy;
});
_initiateTimer(); // sometimes final speech callback is not made
},
onWebsocketConnectionSuccess: () {
addEventToContext('Websocket Opened');
Expand Down Expand Up @@ -234,9 +235,14 @@ class TranscriptWidgetState extends State<TranscriptWidget> with WidgetsBindingO
return transcript;
}

bool memoryCreating = false;

_initiateTimer() {
_memoryCreationTimer?.cancel();
_memoryCreationTimer = Timer(const Duration(seconds: 120), () async {
setState(() {
memoryCreating = true;
});
debugPrint('Creating memory from whispers');
String transcript = '';
if (customWebsocketTranscript.trim().isNotEmpty) {
Expand All @@ -247,15 +253,15 @@ class TranscriptWidgetState extends State<TranscriptWidget> with WidgetsBindingO
debugPrint('Transcript: \n$transcript');
File file = await audioStorage!.createWavFile();
String? fileName = await uploadFile(file);
processTranscriptContent(transcript, fileName);
await processTranscriptContent(context, transcript, fileName);
addEventToContext('Memory Created');
setState(() {
whispersDiarized = [{}];
customWebsocketTranscript = '';
memoryCreating = false;
});
audioStorage?.clearAudioBytes();
// TODO: proactive audio, and sends notifications telling like "Dude, don't say x like this, how frequently?
// TODO: when memory created, do a vanishing effect, and put `memory creating ...` for 2 seconds
});
}

Expand Down Expand Up @@ -289,6 +295,17 @@ class TranscriptWidgetState extends State<TranscriptWidget> with WidgetsBindingO
);
}

if (memoryCreating) {
return const Padding(
padding: EdgeInsets.only(top: 48.0),
child: Center(
child: CircularProgressIndicator(
color: Colors.white,
),
),
);
}

var filteredNotEmptyWhispers = whispersDiarized.where((e) => e.isNotEmpty).toList();
if (filteredNotEmptyWhispers.isEmpty) {
return const Padding(
Expand Down
28 changes: 24 additions & 4 deletions apps/AppWithWearable/lib/utils/memories.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,41 @@ import '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart';

// Perform actions periodically
Future<void> processTranscriptContent(String content, String? audioFileName) async {
if (content.isNotEmpty) await memoryCreationBlock(content, audioFileName);
Future<void> processTranscriptContent(BuildContext context, String content, String? audioFileName) async {
if (content.isNotEmpty) await memoryCreationBlock(context, content, audioFileName);
}

// Process the creation of memory records
Future<void> memoryCreationBlock(String rawMemory, String? audioFileName) async {
Future<void> memoryCreationBlock(BuildContext context, String rawMemory, String? audioFileName) async {
changeAppStateMemoryCreating();
List<MemoryRecord> recentMemories = await MemoryStorage.retrieveRecentMemoriesWithinMinutes(minutes: 10);
var structuredMemory = await generateTitleAndSummaryForMemory(rawMemory, recentMemories);
String structuredMemory;
try {
structuredMemory = await generateTitleAndSummaryForMemory(rawMemory, recentMemories);
} catch (e) {
debugPrint('Error: $e');
changeAppStateMemoryCreating();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('There was an error creating your memory, please check your open AI API keys.')));
return;
}
debugPrint('Structured Memory: $structuredMemory');
if (structuredMemory.contains("N/A")) {
await saveFailureMemory(rawMemory, structuredMemory);
changeAppStateMemoryCreating();
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
'Recent Memory Discarded! Nothing useful. 😄',
style: TextStyle(color: Colors.white),
),
duration: Duration(seconds: 4),
));
} else {
await finalizeMemoryRecord(rawMemory, structuredMemory, audioFileName);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('New Memory Created! 🚀', style: TextStyle(color: Colors.white)),
duration: Duration(seconds: 4),
));
}
}

Expand Down