Voice commands now create activities directly via API
- Replace navigation to pre-filled forms with direct API activity creation - Fetch children from family and use first child (can be enhanced for name matching) - Show success/error messages with proper feedback - Auto-close dialog after successful save - Add test endpoint /api/v1/voice/test-classify for easy testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { VoiceService } from './voice.service';
|
||||
import { Public } from '../auth/decorators/public.decorator';
|
||||
|
||||
@Controller('api/v1/voice')
|
||||
export class VoiceController {
|
||||
@@ -150,4 +151,36 @@ export class VoiceController {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Test endpoint for voice classification (public, for development/testing only)
|
||||
* IMPORTANT: Remove @Public() decorator in production
|
||||
*/
|
||||
@Public()
|
||||
@Post('test-classify')
|
||||
async testClassify(
|
||||
@Body('text') text: string,
|
||||
@Body('language') language?: string,
|
||||
@Body('childName') childName?: string,
|
||||
) {
|
||||
if (!text) {
|
||||
throw new BadRequestException('Text is required');
|
||||
}
|
||||
|
||||
this.logger.log(`[TEST] Voice classification request: "${text}"`);
|
||||
|
||||
const result = await this.voiceService.extractActivityFromText(
|
||||
text,
|
||||
language || 'en',
|
||||
childName,
|
||||
);
|
||||
|
||||
this.logger.log(`[TEST] Classification result: ${JSON.stringify(result, null, 2)}`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
transcript: text,
|
||||
classification: result,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user