@oscloudlab/vgen-agent-assistant 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # VgenAgentAssistant
2
+
3
+ 基于AI的Vgen视频内容生成智能助手,提供聊天式交互界面来分析URL并生成视频内容与课程。
4
+
5
+ ## 项目架构设计
6
+
7
+ ### 核心功能模块
8
+
9
+ - **AI Assistant Core (VgenAgent)**: 主交互界面,支持SSE实时通信
10
+ - **URL分析引擎**: 智能解析视频URL,提取关键信息用于后续内容生成
11
+ - **内容生成管道**:
12
+ - 视频续写与再创作
13
+ - 课程分镜头设计
14
+ - 教学内容优化
15
+ - **实时通信**: 基于Server-Sent Events的流式AI响应
16
+
17
+ ### 技术架构特点
18
+
19
+ ```
20
+ ┌─────────────────────┐
21
+ │ React + Vite │
22
+ │ 前端框架层 │
23
+ ├─────────────────────┤
24
+ │ SSE/REST API │
25
+ │ 服务端通信层 │
26
+ ├─────────────────────┤
27
+ │ 内容分析引擎 │
28
+ │ AI能力集成层 │
29
+ └─────────────────────┘
30
+ ```
31
+
32
+ - **组件架构**: 模块化设计,核心组件可复用
33
+ - **状态管理**: React Hooks + 上下文模式,轻量级状态方案
34
+ - **样式方案**: Less + CSS Modules + Tailwind,灵活且可维护
35
+ - **类型安全**: 全TypeScript实现,提供完整的类型定义
36
+
37
+ ## 使用方法
38
+
39
+ ### 开发环境启动
40
+
41
+ ```bash
42
+ # 安装依赖
43
+ npm install
44
+
45
+ # 启动开发服务器
46
+ npm run dev
47
+
48
+ # 启动演示应用
49
+ npm run demo
50
+ ```
51
+
52
+ #### 环境配置
53
+
54
+ 项目支持多环境配置,根据需要修改对应的环境变量文件:
55
+
56
+ - **开发环境**: `.env.development`
57
+ - **测试环境**: `.env.test`
58
+ - **生产环境**: `.env.production`
59
+
60
+ ### 核心使用场景
61
+
62
+ #### 1. 作为独立Web应用
63
+
64
+ 适用于希望直接使用完整AI助手功能的场景:
65
+
66
+ ```typescript
67
+ // 直接访问开发环境
68
+ npm run dev -> http://localhost:3003
69
+ ```
70
+
71
+ #### 2. 作为NPM包集成
72
+
73
+ 适用于将VgenAgent能力集成到其他项目:
74
+
75
+ ```typescript
76
+ import VgenAgent from 'vgen-agent-assistant'
77
+
78
+ function App() {
79
+ return (
80
+ <div>
81
+ <VgenAgent
82
+ apiEndpoint="your-api-endpoint"
83
+ projectId="your-project-id"
84
+ />
85
+ </div>
86
+ )
87
+ }
88
+ ```
89
+
90
+ #### 3. 模块级使用
91
+
92
+ 按需求引入特定组件:
93
+
94
+ ```typescript
95
+ import { AnalyzeUrl } from 'vgen-agent-assistant/components'
96
+ import { MyReactMarldown } from 'vgen-agent-assistant/components'
97
+ import { TagsTextarea } from 'vgen-agent-assistant/components'
98
+ ```
99
+
100
+ ### API接入配置
101
+
102
+ 在项目根目录创建或修改 `.env.local`:
103
+
104
+ ```
105
+ # AI服务配置
106
+ VITE_API_BASE_URL=http://your-api-server.com
107
+ VITE_SSE_ENDPOINT=/api/vgen/assistant
108
+
109
+ # 功能开关
110
+ VITE_ENABLE_VIDEO_ANALYSIS=true
111
+ VITE_ENABLE_COURSE_GENERATION=true
112
+ VITE_ENABLE_STREAMING=true
113
+
114
+ # 项目配置
115
+ VITE_PROJECT_ID=your-project-id
116
+ VITE_LANGUAGE=chinese
117
+ ```
118
+
119
+ ### 高级配置
120
+
121
+ #### 自定义主题与样式
122
+
123
+ 项目支持通过CSS变量覆盖默认样式:
124
+
125
+ ```css
126
+ :root {
127
+ --vgen-primary-color: #1890ff;
128
+ --vgen-border-radius: 8px;
129
+ --vgen-font-family: "PingFang SC";
130
+ }
131
+ ```
132
+
133
+ #### 扩展组件能力
134
+
135
+ 通过props传递自定义配置:
136
+
137
+ ```typescript
138
+ <VgenAgent
139
+ customComponents={{
140
+ MessageComponents: MyCustomMessages,
141
+ InputComponents: MyCustomInput
142
+ }}
143
+ themeConfig={{
144
+ colorScheme: 'light',
145
+ compact: true
146
+ }}
147
+ />
148
+ ```
149
+
150
+ ### 构建与部署
151
+
152
+ ```bash
153
+ # 构建生产版本
154
+ npm run build
155
+
156
+ # 预览构建结果
157
+ npm run preview
158
+
159
+ # 打包Lib库版本
160
+ npm run build:lib
161
+ ```
162
+
163
+ ### 开发调试
164
+
165
+ ```bash
166
+ # 代码检查
167
+ npm run lint
168
+
169
+ # 类型检查
170
+ npm run type-check
171
+
172
+ # 查看打包分析
173
+ npm run analyze
174
+ ```
175
+
176
+ ## 功能特点
177
+
178
+ - **智能URL分析**: 自动识别视频平台并提取关键元数据
179
+ - **AI内容续写**: 基于上下文智能生成视频后续内容
180
+ - **课程分镜**: 将长视频智能拆分为教学片段
181
+ - **实时交互**: 支持打字动画和流式响应
182
+ - **多端适配**: 响应式设计,支持PC和移动端
183
+ - **扩展性**: 组件化架构,便于功能扩展
184
+
185
+ ## 环境要求
186
+
187
+ - Node.js >= 16.0.0
188
+ - npm >= 8.0.0
189
+ - 现代浏览器(Chrome 80+, Firefox 75+, Safari 13+)
@@ -0,0 +1,3 @@
1
+ export * from './src/index'
2
+ import VgenAgentAssistant from './src/index'
3
+ export default VgenAgentAssistant
@@ -0,0 +1,94 @@
1
+ import { SSEChatEvents } from '../../utils/sseForChat';
2
+
3
+ export declare const getUserInfo: () => Promise<import('axios').AxiosResponse<any, any, {}>>;
4
+ export declare const createSession: (params: {
5
+ btype: number;
6
+ dataBtype?: number;
7
+ dataId?: string;
8
+ }) => any;
9
+ export declare const getSesstionList: (params: {
10
+ sessionId: number;
11
+ anchorId?: number;
12
+ direction?: "before" | "after" | null;
13
+ limit?: number;
14
+ keyword?: string;
15
+ }) => any;
16
+ export declare const updateSession: (params: {
17
+ sessionId: number;
18
+ messages: {
19
+ role: string;
20
+ content: string;
21
+ id?: string;
22
+ messageType?: string;
23
+ extraInfo?: string;
24
+ }[];
25
+ }) => any;
26
+ export interface getTraceIdProps {
27
+ "app": "vgen" | "vgen-web";
28
+ "btype": 'session' | 'button-event' | 'workflow';
29
+ "extra": string;
30
+ }
31
+ export declare const getTraceId: (params: getTraceIdProps) => any;
32
+ export declare const chatSse: (query: any, params: any, receiverObj: SSEChatEvents, enableGlobalSearch?: boolean, traceId?: string) => import('../../utils/sseForChat').SSEChatController;
33
+ export declare const chatSseSaas: (query: any, params: any, receiverObj: SSEChatEvents, traceId?: string) => import('../../utils/sseForChat').SSEChatController;
34
+ export declare const saveKnowledges: (params: {
35
+ btype: number;
36
+ data: any;
37
+ }) => any;
38
+ export declare const getRecommendVideos: (title: string) => any;
39
+ export declare const getVideoStatus: (id: string) => any;
40
+ export declare const saveSkillTree: (params: any) => any;
41
+ export interface searchParamsProps {
42
+ currentPage?: number;
43
+ pageSize?: number;
44
+ orders?: {
45
+ key: string;
46
+ asc: boolean;
47
+ }[];
48
+ nameLike?: string;
49
+ }
50
+ export declare const getWaitTaskScene: (params: searchParamsProps) => any;
51
+ export declare const getWaitTaskRecommendKnowledgeList: (params: searchParamsProps) => any;
52
+ export interface searchParamsPropsForQuestion extends searchParamsProps {
53
+ knowledge?: string;
54
+ difficulty?: string;
55
+ }
56
+ export declare const getWaitTaskQuestionList: (params: searchParamsPropsForQuestion) => any;
57
+ export declare const bilibiliSearchType: (params: {
58
+ keywords: string;
59
+ order: string;
60
+ currentPage: number;
61
+ pageSize: number;
62
+ publicTimeBeginSecond?: number;
63
+ publicTimeEndSecond?: number;
64
+ }) => any;
65
+ export declare const analyzeUrls: (params: {
66
+ urls: string[];
67
+ code?: string;
68
+ }) => any;
69
+ export declare const getUserDurantion: () => any;
70
+ export declare const startAnalyze: (params: {
71
+ groupName?: string;
72
+ videoIdParamList: {
73
+ code: string;
74
+ bvid: string;
75
+ cid: string;
76
+ }[];
77
+ }[], traceId?: string) => any;
78
+ export declare const getAgentFormFields: () => any;
79
+ export declare const batchSaveQuestionNew: (params: {
80
+ "questionList": string;
81
+ }) => any;
82
+ export declare const getSessionListByBiz: (params: {
83
+ "currentPage": number;
84
+ "pageSize": number;
85
+ "orders"?: {
86
+ "key": string;
87
+ "asc": boolean;
88
+ }[];
89
+ "dataBtype": number;
90
+ "dataId": string;
91
+ }) => any;
92
+ export declare const deleteSession: (params: {
93
+ ids: number[];
94
+ }) => any;
@@ -0,0 +1,34 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface AnalyzeUrlProps {
4
+ analyzeCallback?: (costArr: {
5
+ costDuration: number;
6
+ recordId: string;
7
+ }[], arr: analyzeListProps[]) => void;
8
+ closeAnalysisModal?: () => void;
9
+ initUrl?: string;
10
+ hasSearch?: boolean;
11
+ forChatUse?: boolean;
12
+ chatVideoUrl?: string;
13
+ needTraceId?: boolean;
14
+ sessionId?: number;
15
+ }
16
+ export interface analyzeListProps {
17
+ groupName?: string;
18
+ videoIdParamList: {
19
+ code: string;
20
+ bvid: string;
21
+ cid: string;
22
+ duration?: number | string;
23
+ title: string;
24
+ }[];
25
+ userGuide?: boolean;
26
+ }
27
+ export declare const parseBilibiliUrl: (url: string) => {
28
+ bvid: string | null;
29
+ p: string;
30
+ recordId: string;
31
+ code: string;
32
+ };
33
+ declare const AnalyzeUrl: React.FC<AnalyzeUrlProps>;
34
+ export default AnalyzeUrl;
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+
3
+ interface BiliRecommendProps {
4
+ searchKey: string;
5
+ selectCallback: (result: SearchResult) => void;
6
+ }
7
+ export interface SearchResult {
8
+ id: string;
9
+ title: string;
10
+ duration: string;
11
+ upic: string;
12
+ typename: string;
13
+ play: number;
14
+ pubdate: number;
15
+ description: string;
16
+ arcurl: string;
17
+ cid?: string;
18
+ bvid: string;
19
+ tag: string;
20
+ showAllTag: boolean;
21
+ }
22
+ declare const _default: React.NamedExoticComponent<BiliRecommendProps>;
23
+ export default _default;
@@ -0,0 +1,5 @@
1
+
2
+ declare const MyReactMarkdown: import('react').MemoExoticComponent<({ children }: {
3
+ children: string;
4
+ }) => import("react/jsx-runtime").JSX.Element>;
5
+ export default MyReactMarkdown;
@@ -0,0 +1,24 @@
1
+
2
+ export interface structuredDataProps {
3
+ type: string;
4
+ value: string;
5
+ }
6
+ export interface TagsTextareaProps {
7
+ onChange?: (value: structuredDataProps[]) => void;
8
+ minHeight?: number;
9
+ maxHeight?: number;
10
+ placeholder?: string;
11
+ sendMsg?: (msg?: string) => void;
12
+ }
13
+ export interface TagsTextareaRef {
14
+ getHtmlContent: () => string;
15
+ getStructuredData: () => structuredDataProps[];
16
+ addText: (text: string) => void;
17
+ addTag: (tag: string) => void;
18
+ addInput: (input: string, placeholder: string) => void;
19
+ addDropdown: (options: string[], defaultValue: string) => void;
20
+ focusInput: () => void;
21
+ clearContent: () => void;
22
+ }
23
+ declare const TagsTextarea: import('react').ForwardRefExoticComponent<TagsTextareaProps & import('react').RefAttributes<unknown>>;
24
+ export default TagsTextarea;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { courseInfoProps } from '../type';
3
+
4
+ interface CourseContinueMsgProps {
5
+ courseInfo: courseInfoProps;
6
+ handleSendMessage: (props: {
7
+ input: string;
8
+ isInitial?: boolean;
9
+ scene?: string;
10
+ chatId?: number;
11
+ }) => void;
12
+ }
13
+ declare const _default: React.NamedExoticComponent<CourseContinueMsgProps>;
14
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { courseInfoProps } from '../type';
3
+
4
+ interface CourseStartMsgProps {
5
+ courseInfo: courseInfoProps;
6
+ handleSendMessage: (props: {
7
+ input: string;
8
+ isInitial?: boolean;
9
+ scene?: string;
10
+ chatId?: number;
11
+ }) => void;
12
+ }
13
+ declare const _default: React.NamedExoticComponent<CourseStartMsgProps>;
14
+ export default _default;
@@ -0,0 +1,35 @@
1
+ import { default as React } from 'react';
2
+ import { agentScene } from '../../../../utils/consts';
3
+ import { MessageProps, recommendVideosProps } from '../type';
4
+
5
+ interface MessageContentProps {
6
+ messages: MessageProps[];
7
+ answerIsDone: boolean;
8
+ recommendScene?: agentScene;
9
+ recommendSceneData?: any;
10
+ setAnalyzeUrlNow?: (url: string) => void;
11
+ setConfirmAnalyzeModalVisible?: (visible: boolean) => void;
12
+ setAnalyzeMsgShouldSave?: (shouldSave: boolean) => void;
13
+ studyPathFormSubmit?: (formVals: any) => void;
14
+ questionFormSubmit?: (formVals: any) => void;
15
+ knowledgeCardFormSubmit?: (formVals: any) => void;
16
+ taskFormSubmit?: (formVals: any) => void;
17
+ StudyMapFormFields?: any[];
18
+ QuestionFormFields?: any[];
19
+ KnowledgeCardFormFields?: any[];
20
+ TaskFormFields?: any[];
21
+ saveStudyPath?: (treeData: any[]) => void;
22
+ studyPathSaving?: boolean;
23
+ toCheckQuestions?: (extraInfo: any) => void;
24
+ toCheckVideo?: (recordId: string) => void;
25
+ recommendVideos?: recommendVideosProps[];
26
+ handleSend: (props: {
27
+ input: string;
28
+ isInitial?: boolean;
29
+ scene?: string;
30
+ chatId?: number;
31
+ }) => void;
32
+ isTaskPage?: boolean;
33
+ }
34
+ declare const _default: React.NamedExoticComponent<MessageContentProps>;
35
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { videoInfoProps } from '../type';
3
+
4
+ interface VideoContinueMsgProps {
5
+ videoInfo: videoInfoProps;
6
+ handleSendMessage: (props: {
7
+ input: string;
8
+ isInitial?: boolean;
9
+ scene?: string;
10
+ chatId?: number;
11
+ }) => void;
12
+ }
13
+ declare const _default: React.NamedExoticComponent<VideoContinueMsgProps>;
14
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { videoInfoProps } from '../type';
3
+
4
+ interface VideoStartMsgProps {
5
+ videoInfo: videoInfoProps;
6
+ handleSendMessage: (props: {
7
+ input: string;
8
+ isInitial?: boolean;
9
+ scene?: string;
10
+ chatId?: number;
11
+ }) => void;
12
+ }
13
+ declare const _default: React.NamedExoticComponent<VideoStartMsgProps>;
14
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ import { viewModeType } from '../type';
3
+
4
+ interface defaultWelcomeMsgProps {
5
+ videoMode: viewModeType;
6
+ }
7
+ declare const _default: React.NamedExoticComponent<defaultWelcomeMsgProps>;
8
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { VgenAgentProps } from './type';
2
+
3
+ declare const VgenAgent: import('react').ForwardRefExoticComponent<VgenAgentProps & import('react').RefAttributes<unknown>>;
4
+ export default VgenAgent;