Feat: interactive courses (#736)

* add courses page

* add api for courses

* add course page

* update course type

* update client

* update course page

* refactor courses pages

* render chapter content

* shadow in course

* fix video handler

* update style

* mark finished examples

* fix media player

* update locale

* finish chapter

* refactor

* auto update chapter status

* audo finish chapter

* fix media provider

* fix wavesurfer player

* update continue btn

* refactor chapters & page

* minor fix

* fix undefined

* refactor

* refactor

* disable sentry in dev

* clean markdown format before alignment

* refactor

* fix regenerate

* fix transcription pre-process for `-` connector

* upgrade deps

* handle no chapters

* add llm chat api

* create llm chat

* display llm message

* create message

* handle error

* generate llm message

* display llm datetime

* scroll to message

* tts for llm message

* add course provider

* refactor

* translate llm message

* fix llm chat introduction

* refacotr

* upgrade deps

* refactor style

* handle undefined

* fix posts

* update locales

* update courses api

* add enrollments count

* upgrade yarn

* upgrade deps

* restore dep to fix package in mac

* upgrade deps
This commit is contained in:
an-lee
2024-07-11 19:14:40 +08:00
committed by GitHub
parent d9523269a3
commit 728bfae82f
72 changed files with 3083 additions and 1973 deletions

View File

@@ -468,4 +468,108 @@ export class Client {
params: decamelizeKeys(params),
});
}
courses(params?: {
language?: string;
page?: number;
items?: number;
query?: string;
}): Promise<
{
courses: CourseType[];
} & PagyResponseType
> {
return this.api.get("/api/courses", { params: decamelizeKeys(params) });
}
course(id: string): Promise<CourseType> {
return this.api.get(`/api/courses/${id}`);
}
createEnrollment(courseId: string): Promise<EnrollmentType> {
return this.api.post(`/api/enrollments`, decamelizeKeys({ courseId }));
}
courseChapters(
courseId: string,
params?: {
page?: number;
items?: number;
query?: string;
}
): Promise<
{
chapters: ChapterType[];
} & PagyResponseType
> {
return this.api.get(`/api/courses/${courseId}/chapters`, {
params: decamelizeKeys(params),
});
}
coursechapter(courseId: string, id: number | string): Promise<ChapterType> {
return this.api.get(`/api/courses/${courseId}/chapters/${id}`);
}
finishCourseChapter(courseId: string, id: number | string): Promise<void> {
return this.api.post(`/api/courses/${courseId}/chapters/${id}/finish`);
}
enrollments(params?: { page?: number; items?: number }): Promise<
{
enrollments: EnrollmentType[];
} & PagyResponseType
> {
return this.api.get("/api/enrollments", { params: decamelizeKeys(params) });
}
updateEnrollment(
id: string,
params: {
currentChapterId?: string;
}
): Promise<EnrollmentType> {
return this.api.put(`/api/enrollments/${id}`, decamelizeKeys(params));
}
createLlmChat(params: {
agentId: string;
agentType: string;
}): Promise<LLmChatType> {
return this.api.post("/api/chats", decamelizeKeys(params));
}
llmChat(id: string): Promise<LLmChatType> {
return this.api.get(`/api/chats/${id}`);
}
createLlmMessage(
chatId: string,
params: {
query: string;
agentId?: string;
agentType?: string;
}
): Promise<LlmMessageType> {
return this.api.post(
`/api/chats/${chatId}/messages`,
decamelizeKeys(params)
);
}
llmMessages(
chatId: string,
params: {
page?: number;
items?: number;
}
): Promise<
{
messages: LlmMessageType[];
} & PagyResponseType
> {
return this.api.get(`/api/chats/${chatId}/messages`, {
params: decamelizeKeys(params),
});
}
}