Skip to content

Commit bafd3cb

Browse files
committed
Fixes from codelab review
1 parent c7c73b4 commit bafd3cb

File tree

34 files changed

+685
-691
lines changed

34 files changed

+685
-691
lines changed

colorist/codelab_rebuild.yaml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ steps:
420420
steps:
421421
- name: Remove generated code
422422
rmdir: step_03
423-
- name: Mkdir assets/prompts/
423+
- name: Mkdir assets
424424
path: colorist
425-
mkdir: assets/prompts/
426-
- name: Add assets/prompts/system_prompt.md
427-
path: colorist/assets/prompts/system_prompt.md
425+
mkdir: assets
426+
- name: Add assets/system_prompt.md
427+
path: colorist/assets/system_prompt.md
428428
replace-contents: |
429429
# Colorist System Prompt
430430
@@ -434,7 +434,7 @@ steps:
434434
435435
You are knowledgeable about colors, color theory, and how to translate natural language descriptions into specific RGB values. When users describe a color, you should:
436436
437-
1. Analyze their description to understand the color they're trying to convey
437+
1. Analyze their description to understand the color they are trying to convey
438438
2. Determine the appropriate RGB values (values should be between 0.0 and 1.0)
439439
3. Respond with a conversational explanation and explicitly state the RGB values
440440
@@ -472,14 +472,13 @@ steps:
472472
patch-u: |
473473
--- b/colorist/step_03/pubspec.yaml
474474
+++ a/colorist/step_03/pubspec.yaml
475-
@@ -28,3 +28,7 @@ dev_dependencies:
476-
475+
@@ -28,3 +28,6 @@ dev_dependencies:
476+
477477
flutter:
478478
uses-material-design: true
479479
+
480480
+ assets:
481481
+ - assets/
482-
+ - assets/prompts/
483482
- name: Add lib/providers/system_prompt.dart
484483
path: colorist/lib/providers/system_prompt.dart
485484
replace-contents: |
@@ -495,7 +494,7 @@ steps:
495494
496495
@riverpod
497496
Future<String> systemPrompt(Ref ref) =>
498-
rootBundle.loadString('assets/prompts/system_prompt.md');
497+
rootBundle.loadString('assets/system_prompt.md');
499498
- name: Patch lib/providers/gemini.dart
500499
path: colorist/lib/providers/gemini.dart
501500
patch-u: |
@@ -596,11 +595,11 @@ steps:
596595
);
597596
return model;
598597
}
599-
- name: Patch assets/prompts/system_prompt.md
600-
path: colorist/assets/prompts/system_prompt.md
598+
- name: Patch assets/system_prompt.md
599+
path: colorist/assets/system_prompt.md
601600
patch-u: |
602-
--- a/colorist/step_04/assets/prompts/system_prompt.md
603-
+++ b/colorist/step_04/assets/prompts/system_prompt.md
601+
--- a/colorist/step_04/assets/system_prompt.md
602+
+++ b/colorist/step_04/assets/system_prompt.md
604603
@@ -1,14 +1,12 @@
605604
# Colorist System Prompt
606605
@@ -612,7 +611,7 @@ steps:
612611
-You are knowledgeable about colors, color theory, and how to translate natural language descriptions into specific RGB values. When users describe a color, you should:
613612
+You are knowledgeable about colors, color theory, and how to translate natural language descriptions into specific RGB values. You have access to the following tool:
614613
615-
-1. Analyze their description to understand the color they're trying to convey
614+
-1. Analyze their description to understand the color they are trying to convey
616615
-2. Determine the appropriate RGB values (values should be between 0.0 and 1.0)
617616
-3. Respond with a conversational explanation and explicitly state the RGB values
618617
+**set_color** - Sets the RGB values for the color display based on a description
@@ -669,12 +668,12 @@ steps:
669668
+++ a/colorist/step_05/lib/services/gemini_chat_service.dart
670669
@@ -11,6 +11,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
671670
import 'package:riverpod_annotation/riverpod_annotation.dart';
672-
671+
673672
import '../providers/gemini.dart';
674673
+import 'gemini_tools.dart';
675-
674+
676675
part 'gemini_chat_service.g.dart';
677-
676+
678677
@@ -34,6 +35,30 @@ class GeminiChatService {
679678
logStateNotifier.logLlmText(responseText);
680679
chatStateNotifier.appendToMessage(llmMessage.id, responseText);
@@ -786,31 +785,31 @@ steps:
786785
--- b/colorist/step_06/lib/services/gemini_chat_service.dart
787786
+++ a/colorist/step_06/lib/services/gemini_chat_service.dart
788787
@@ -4,6 +4,7 @@
789-
788+
790789
import 'dart:async';
791-
790+
792791
+import 'package:colorist_ui/models/conversation_state.dart';
793792
import 'package:colorist_ui/providers/chat_state_notifier.dart';
794793
import 'package:colorist_ui/providers/log_state_notifier.dart';
795794
import 'package:firebase_vertexai/firebase_vertexai.dart';
796795
@@ -15,49 +16,41 @@ import 'gemini_tools.dart';
797-
796+
798797
part 'gemini_chat_service.g.dart';
799-
798+
800799
+final conversationStateProvider = StateProvider(
801800
+ (ref) => ConversationState.idle,
802801
+);
803802
+
804803
class GeminiChatService {
805804
GeminiChatService(this.ref);
806805
final Ref ref;
807-
806+
808807
Future<void> sendMessage(String message) async {
809808
final chatSession = await ref.read(chatSessionProvider.future);
810809
+ final conversationState = ref.read(conversationStateProvider);
811810
final chatStateNotifier = ref.read(chatStateNotifierProvider.notifier);
812811
final logStateNotifier = ref.read(logStateNotifierProvider.notifier);
813-
812+
814813
+ if (conversationState == ConversationState.busy) {
815814
+ logStateNotifier.logWarning(
816815
+ "Can't send a message while a conversation is in progress",
@@ -987,11 +986,11 @@ steps:
987986
sendMessage: (text) {
988987
ref.read(geminiChatServiceProvider).sendMessage(text);
989988
},
990-
- name: Patch assets/prompts/system_prompt.md
991-
path: colorist/assets/prompts/system_prompt.md
989+
- name: Patch assets/system_prompt.md
990+
path: colorist/assets/system_prompt.md
992991
patch-u: |
993-
--- b/colorist/step_07/assets/prompts/system_prompt.md
994-
+++ a/colorist/step_07/assets/prompts/system_prompt.md
992+
--- b/colorist/step_07/assets/system_prompt.md
993+
+++ a/colorist/step_07/assets/system_prompt.md
995994
@@ -29,6 +29,14 @@ After the tool call: "I've set a warm orange with strong red, moderate green, an
996995
997996
If a color description is ambiguous or unclear, please ask the user clarifying questions, one at a time.

0 commit comments

Comments
 (0)