fix: boucle infinie Maximum update depth dans useAutoTagging + toolbar
- use-auto-tagging: onQuotaExceeded via ref stable → n'invalide plus useCallback analyzeContent à chaque render parent - note-editor-context: filteredSuggestions et existingLabelsLower stabilisés avec useMemo (était recalculé sans memo → nouvelle ref à chaque render → état useMemo state se réexécutait → boucle) - deepseek.ts: generateTags via generateText (pas generateObject) pour éviter response_format:json_schema non supporté Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -30,21 +30,23 @@ export class DeepSeekProvider implements AIProvider {
|
||||
this.embeddingModel = deepseek.embedding(embeddingModelName);
|
||||
}
|
||||
|
||||
async generateTags(content: string): Promise<TagSuggestion[]> {
|
||||
async generateTags(content: string, language?: string): Promise<TagSuggestion[]> {
|
||||
try {
|
||||
const { object } = await generateObject({
|
||||
// DeepSeek doesn't support response_format: json_schema — use generateText + manual parse
|
||||
const { text } = await aiGenerateText({
|
||||
model: this.model,
|
||||
schema: z.object({
|
||||
tags: z.array(z.object({
|
||||
tag: z.string().describe('Short tag name in lowercase'),
|
||||
confidence: z.number().min(0).max(1).describe('Confidence level between 0 and 1')
|
||||
}))
|
||||
}),
|
||||
prompt: `Analyze the following note and suggest 1 to 5 relevant tags.
|
||||
Note content: "${content}"`,
|
||||
prompt: `Analyze the following note and suggest 1 to 5 relevant tags as a JSON array.
|
||||
Return ONLY a JSON array like: [{"tag":"example","confidence":0.9}]
|
||||
Note content: "${content.substring(0, 1500)}"`,
|
||||
});
|
||||
|
||||
return object.tags;
|
||||
const clean = text.replace(/^```json\n?/, '').replace(/\n?```$/, '').trim();
|
||||
const parsed = JSON.parse(clean);
|
||||
const arr = Array.isArray(parsed) ? parsed : (parsed.tags || []);
|
||||
return arr.map((t: any) => ({
|
||||
tag: t.tag || t.label || t.name || '',
|
||||
confidence: t.confidence || t.score || 0.7,
|
||||
}));
|
||||
} catch (e) {
|
||||
console.error('Error generating tags (DeepSeek):', e);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user