Generate it / Publish it: Claude Haiku integration + Generate page redesign
- GenerateIt page: objects sidebar, readOnly canvas, collapsible prompt bar - Generate it: calls Claude Haiku, saves questions/words to Directus as draft - Publish it: promotes draft questions/words to published - Deduplication: links existing words/questions instead of duplicating - GenerateObjectsList: tree view with user_notes labels - DrawCanvas: readOnly prop to disable mouse interaction - api.ts: generateQuestions + publishQuestions endpoints - requirements.txt: anthropic==0.40.0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,3 +195,38 @@ export async function generateSentence(
|
||||
if (!res.ok) throw new Error(data.error || 'Fehler bei KI-Sentence')
|
||||
return data
|
||||
}
|
||||
|
||||
export interface GenerateStats {
|
||||
words_created: number
|
||||
words_linked: number
|
||||
questions_created: number
|
||||
questions_linked: number
|
||||
}
|
||||
|
||||
export async function generateQuestions(
|
||||
objId: string,
|
||||
prompt: string,
|
||||
token: string
|
||||
): Promise<{ ok: boolean; stats: GenerateStats }> {
|
||||
const res = await fetch(`/api/object/${encodeURIComponent(objId)}/generate_questions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
||||
body: JSON.stringify({ prompt }),
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error(data.error || 'Fehler bei Generate')
|
||||
return data
|
||||
}
|
||||
|
||||
export async function publishQuestions(
|
||||
objId: string,
|
||||
token: string
|
||||
): Promise<{ ok: boolean; published_questions: number; published_words: number }> {
|
||||
const res = await fetch(`/api/object/${encodeURIComponent(objId)}/publish_questions`, {
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error(data.error || 'Fehler bei Publish')
|
||||
return data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user