Skip to content

Commit f38ee9f

Browse files
committed
Refactor DashBot
1 parent bd86a71 commit f38ee9f

File tree

130 files changed

+391
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+391
-521
lines changed

lib/dashbot/constants.dart

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/// Role of a chat message author.
2+
enum MessageRole { user, system }
3+
4+
enum ChatMessageType {
5+
explainResponse,
6+
debugError,
7+
generateTest,
8+
generateDoc,
9+
generateCode,
10+
importCurl,
11+
importOpenApi,
12+
general
13+
}
14+
15+
enum ChatActionType {
16+
updateField('update_field'),
17+
addHeader('add_header'),
18+
updateHeader('update_header'),
19+
deleteHeader('delete_header'),
20+
updateBody('update_body'),
21+
updateUrl('update_url'),
22+
updateMethod('update_method'),
23+
showLanguages('show_languages'),
24+
applyCurl('apply_curl'),
25+
applyOpenApi('apply_openapi'),
26+
downloadDoc('download_doc'),
27+
other('other'),
28+
noAction('no_action'),
29+
uploadAsset('upload_asset');
30+
31+
const ChatActionType(this.text);
32+
final String text;
33+
}
34+
35+
enum ChatActionTarget {
36+
httpRequestModel,
37+
codegen,
38+
test,
39+
code,
40+
attachment,
41+
documentation,
42+
}
43+
44+
ChatActionType chatActionTypeFromString(String s) {
45+
return ChatActionType.values.firstWhere(
46+
(type) => type.text == s,
47+
orElse: () => ChatActionType.other,
48+
);
49+
}
50+
51+
ChatActionTarget chatActionTargetFromString(String s) {
52+
return ChatActionTarget.values.firstWhere(
53+
(target) => target.name == s,
54+
orElse: () => ChatActionTarget.httpRequestModel,
55+
);
56+
}

lib/dashbot/core/constants/constants.dart

Lines changed: 0 additions & 143 deletions
This file was deleted.

lib/dashbot/core/constants/prompts/prompts.dart

Lines changed: 0 additions & 10 deletions
This file was deleted.

lib/dashbot/core/utils/utils.dart

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/dashbot/dashbot.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export 'dashbot_dashboard.dart';
2-
export 'core/providers/dashbot_window_notifier.dart';
3-
export 'core/utils/utils.dart';
2+
export 'dashbot_tab.dart';
3+
export 'providers/providers.dart';
4+
export 'utils/utils.dart';

lib/dashbot/dashbot_dashboard.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import 'package:apidash/providers/providers.dart';
2-
import 'package:apidash/screens/common_widgets/ai/ai.dart';
31
import 'package:apidash_core/apidash_core.dart';
42
import 'package:apidash_design_system/apidash_design_system.dart';
5-
import 'core/utils/dashbot_icons.dart';
6-
7-
import 'core/providers/dashbot_window_notifier.dart';
8-
import 'core/routes/dashbot_router.dart';
9-
import 'core/routes/dashbot_routes.dart';
103
import 'package:flutter/material.dart';
114
import 'package:flutter_riverpod/flutter_riverpod.dart';
12-
import 'core/providers/dashbot_active_route_provider.dart';
5+
import 'package:apidash/providers/providers.dart';
6+
import 'package:apidash/screens/common_widgets/ai/ai.dart';
7+
import 'providers/providers.dart';
8+
import 'routes/routes.dart';
9+
import 'utils/utils.dart';
1310

1411
class DashbotWindow extends ConsumerWidget {
1512
final VoidCallback onClose;

lib/dashbot/dashbot_tab.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import 'package:apidash_design_system/apidash_design_system.dart';
2-
import 'core/routes/dashbot_router.dart';
3-
import 'core/routes/dashbot_routes.dart';
42
import 'package:flutter/material.dart';
53
import 'package:flutter_riverpod/flutter_riverpod.dart';
6-
import 'core/providers/dashbot_window_notifier.dart';
7-
import 'core/utils/show_dashbot.dart';
84
import 'package:apidash/consts.dart';
9-
import 'core/providers/dashbot_active_route_provider.dart';
5+
import 'providers/providers.dart';
6+
import 'routes/routes.dart';
7+
import 'utils/utils.dart';
108

119
class DashbotTab extends ConsumerStatefulWidget {
1210
const DashbotTab({super.key});
File renamed without changes.

lib/dashbot/features/chat/models/chat_action.dart renamed to lib/dashbot/models/chat_action.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../../../core/constants/constants.dart';
1+
import '../constants.dart';
22

33
class ChatAction {
44
final String action;
@@ -40,8 +40,8 @@ class ChatAction {
4040
'field': field,
4141
'path': path,
4242
'value': value,
43-
'action_type': chatActionTypeToString(actionType),
44-
'target_type': chatActionTargetToString(targetType),
43+
'action_type': actionType.text,
44+
'target_type': targetType.name,
4545
};
4646
}
4747
}
File renamed without changes.

0 commit comments

Comments
 (0)