|
|
@@ -48,3 +48,61 @@ export async function updateSpeakingConfig(
|
|
|
})
|
|
|
return parse<SpeakingConfigRecord>(res)
|
|
|
}
|
|
|
+
|
|
|
+import { SPEAKING_DIALOGUE_API_BASE_URL } from '@/views/Editor/EnglishSpeaking/services/speakingApiConfig'
|
|
|
+
|
|
|
+const DIALOGUE_BASE = SPEAKING_DIALOGUE_API_BASE_URL
|
|
|
+
|
|
|
+export interface ClassSessionSummary {
|
|
|
+ userId: string
|
|
|
+ sessionId: string
|
|
|
+ status: 'active' | 'completed' | 'abandoned'
|
|
|
+ overallStatus: 'ready' | 'generating' | 'failed' | null
|
|
|
+ currentRound: number
|
|
|
+ totalRounds: number
|
|
|
+ overallScore: number | null
|
|
|
+ dimensions: Record<string, number>
|
|
|
+ topHighlights: string[]
|
|
|
+ topImprovements: string[]
|
|
|
+ createdAt: string | null
|
|
|
+ completedAt: string | null
|
|
|
+}
|
|
|
+
|
|
|
+export interface ListSessionsByConfigResponse {
|
|
|
+ summaries: ClassSessionSummary[]
|
|
|
+}
|
|
|
+
|
|
|
+export async function listSpeakingSessionsByConfig(
|
|
|
+ configId: string,
|
|
|
+ userIds: string[],
|
|
|
+): Promise<ListSessionsByConfigResponse> {
|
|
|
+ const params = new URLSearchParams({ configId, userIds: userIds.join(',') })
|
|
|
+ const res = await fetch(`${DIALOGUE_BASE}/sessions/by-config?${params}`, {
|
|
|
+ method: 'GET',
|
|
|
+ credentials: 'include',
|
|
|
+ })
|
|
|
+ if (!res.ok) throw new Error(`listSpeakingSessionsByConfig failed: ${res.status}`)
|
|
|
+ return res.json()
|
|
|
+}
|
|
|
+
|
|
|
+export interface ClassSummaryResponse {
|
|
|
+ bullets: [string, string, string]
|
|
|
+ generatedAt: string
|
|
|
+ fromCache: boolean
|
|
|
+ llmStatus: 'ok' | 'fallback'
|
|
|
+}
|
|
|
+
|
|
|
+export async function generateClassSummary(
|
|
|
+ configId: string,
|
|
|
+ userIds: string[],
|
|
|
+ locale: 'zh' | 'en' | 'hk',
|
|
|
+): Promise<ClassSummaryResponse> {
|
|
|
+ const res = await fetch(`${DIALOGUE_BASE}/sessions/by-config/summary`, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: { 'Content-Type': 'application/json' },
|
|
|
+ credentials: 'include',
|
|
|
+ body: JSON.stringify({ configId, userIds, locale }),
|
|
|
+ })
|
|
|
+ if (!res.ok) throw new Error(`generateClassSummary failed: ${res.status}`)
|
|
|
+ return res.json()
|
|
|
+}
|