feat: AI assistant panel, editor improvements, vite and package config
This commit is contained in:
18
editor/composables/useAI.ts
Normal file
18
editor/composables/useAI.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export async function sendAIRequest(sessionId: string, userMessage: string, mode: string, apiKey: string): Promise<{ result: string }> {
|
||||
const resp = await fetch('/api/ai', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ sessionId, userMessage, apiKey, mode }),
|
||||
})
|
||||
if (!resp.ok) {
|
||||
const err = await resp.json().catch(() => ({ error: 'request failed' }))
|
||||
throw new Error(err.error || 'request failed')
|
||||
}
|
||||
return resp.json()
|
||||
}
|
||||
|
||||
export async function listSessions(): Promise<any[]> {
|
||||
const resp = await fetch('/api/ai/sessions')
|
||||
if (!resp.ok) return []
|
||||
return resp.json()
|
||||
}
|
||||
Reference in New Issue
Block a user