Skip to content

Commit 09adbeb

Browse files
Merge pull request #140 from acara-app/feature/improve-ai-tool-naming
Improve AI Tool Naming & Consistency
2 parents aaf5e3b + 01eb8bf commit 09adbeb

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

app/Ai/Agents/AssistantAgent.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function __construct(
4040
private readonly GetHealthGoals $getHealthGoalsTool,
4141
private readonly SuggestWorkoutRoutine $suggestWorkoutRoutineTool,
4242
private readonly GetFitnessGoals $getFitnessGoalsTool,
43-
) {}
43+
) {
44+
}
4445

4546
public function withMode(AgentMode $mode): self
4647
{
@@ -158,8 +159,8 @@ private function getContextInstructions(array $profileData): array
158159

159160
if ($this->mode === AgentMode::CreateMealPlan) {
160161
$context[] = '';
161-
$context[] = 'The user has explicitly selected "Generate Meal Plan" mode. They want a complete multi-day meal plan.';
162-
$context[] = 'Use the generate_meal_plan tool to initiate the meal plan generation workflow.';
162+
$context[] = 'The user has explicitly selected "Create Meal Plan" mode. They want a complete multi-day meal plan.';
163+
$context[] = 'Use the create_meal_plan tool to initiate the meal plan generation workflow.';
163164
}
164165

165166
return $context;
@@ -174,8 +175,8 @@ private function getStepsInstructions(): array
174175
'1. Analyze the user\'s message to understand their wellness needs (nutrition, fitness, health/lifestyle)',
175176
'2. Review the user\'s profile context to understand their biometrics, goals, and constraints',
176177
'3. Use appropriate tools based on user intent:',
177-
' - generate_meal: For specific meal suggestions',
178-
' - generate_meal_plan: For multi-day meal plans or when in "Generate Meal Plan" mode',
178+
' - suggest_meal: For specific meal suggestions',
179+
' - create_meal_plan: For multi-day meal plans or when in "Create Meal Plan" mode',
179180
' - predict_glucose_spike: For food/meal glucose impact questions',
180181
' - suggest_wellness_routine: For sleep, stress, hydration, or lifestyle routines',
181182
' - suggest_workout_routine: For fitness and exercise guidance',
@@ -218,8 +219,8 @@ private function getOutputInstructions(): array
218219
private function getToolsUsageInstructions(): array
219220
{
220221
return [
221-
'generate_meal: Use when user wants specific meal suggestions',
222-
'generate_meal_plan: Use for multi-day meal plans or when in "Generate Meal Plan" mode',
222+
'suggest_meal: Use when user wants specific meal suggestions',
223+
'create_meal_plan: Use for multi-day meal plans or when in "Create Meal Plan" mode',
223224
'predict_glucose_spike: Use for food/meal glucose impact questions',
224225
'suggest_wellness_routine: Use for sleep, stress, hydration, or lifestyle guidance',
225226
'suggest_workout_routine: Use for fitness and exercise recommendations',

app/Ai/Tools/CreateMealPlan.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public function __construct(
1919
) {
2020
}
2121

22+
public function name(): string
23+
{
24+
return 'create_meal_plan';
25+
}
26+
2227
/**
2328
* Get the description of the tool's purpose.
2429
*/

app/Ai/Tools/SuggestSingleMeal.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
{
1717
public function __construct(
1818
private SingleMealAgent $singleMealAgent,
19-
) {}
19+
) {
20+
}
21+
22+
public function name(): string
23+
{
24+
return 'suggest_meal';
25+
}
2026

2127
public function description(): string
2228
{

app/Enums/AgentMode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
enum AgentMode: string
88
{
99
case Ask = 'ask';
10-
case CreateMealPlan = 'generate-meal-plan';
10+
case CreateMealPlan = 'create-meal-plan';
1111
}

resources/js/pages/chat/chat-input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const CHAT_MODES = {
2828
label: 'chat.modes.ask',
2929
icon: MessageSquare,
3030
},
31-
'generate-meal-plan': {
31+
'create-meal-plan': {
3232
label: 'chat.modes.meal_plan',
3333
icon: UtensilsCrossed,
3434
},
@@ -103,7 +103,7 @@ export default function ChatInput({
103103
className="gap-1.5"
104104
>
105105
<SelectedModeIcon className="size-4" />
106-
{selectedMode !== 'generate-meal-plan' && (
106+
{selectedMode !== 'create-meal-plan' && (
107107
<span>
108108
{t(CHAT_MODES[selectedMode].label)}
109109
</span>

resources/js/pages/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default function Dashboard() {
106106
</Button>
107107
</Link>
108108
<Link
109-
href={`${chat.create().url}?mode=generate-meal-plan`}
109+
href={`${chat.create().url}?mode=create-meal-plan`}
110110
className="group/action"
111111
>
112112
<Button

0 commit comments

Comments
 (0)