mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
ToolGen: LightMode Support added & LLMSelector included
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'package:apidash/apitoolgen/request_consolidator.dart';
|
import 'package:apidash/apitoolgen/request_consolidator.dart';
|
||||||
import 'package:apidash/apitoolgen/tool_templates.dart';
|
import 'package:apidash/apitoolgen/tool_templates.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
|
import 'package:apidash/screens/home_page/editor_pane/details_card/request_pane/ai_request/widgets/llm_selector.dart';
|
||||||
import 'package:apidash/services/agentic_services/agent_caller.dart';
|
import 'package:apidash/services/agentic_services/agent_caller.dart';
|
||||||
import 'package:apidash/services/agentic_services/agents/apitool_bodygen.dart';
|
import 'package:apidash/services/agentic_services/agents/apitool_bodygen.dart';
|
||||||
import 'package:apidash/services/agentic_services/agents/apitool_funcgen.dart';
|
import 'package:apidash/services/agentic_services/agents/apitool_funcgen.dart';
|
||||||
@@ -153,7 +154,7 @@ class _GenerateToolDialogState extends ConsumerState<GenerateToolDialog> {
|
|||||||
)),
|
)),
|
||||||
GeneratedToolCodeCopyPage(
|
GeneratedToolCodeCopyPage(
|
||||||
toolCode: generatedToolCode,
|
toolCode: generatedToolCode,
|
||||||
language: 'javascript',
|
language: selectedLanguage.trim(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -192,6 +193,8 @@ class _ToolRequirementSelectorPageState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final lightMode = Theme.of(context).brightness == Brightness.light;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.4, // Large dialog
|
width: MediaQuery.of(context).size.width * 0.4, // Large dialog
|
||||||
padding: EdgeInsets.all(30),
|
padding: EdgeInsets.all(30),
|
||||||
@@ -203,7 +206,6 @@ class _ToolRequirementSelectorPageState
|
|||||||
"Generate API Tool",
|
"Generate API Tool",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
color: Colors.white,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
kVSpacer5,
|
kVSpacer5,
|
||||||
@@ -211,7 +213,9 @@ class _ToolRequirementSelectorPageState
|
|||||||
padding: EdgeInsets.only(left: 3),
|
padding: EdgeInsets.only(left: 3),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Select an agent framework & language",
|
"Select an agent framework & language",
|
||||||
style: TextStyle(color: Colors.white60, fontSize: 15),
|
style: TextStyle(
|
||||||
|
color: lightMode ? Colors.black54 : Colors.white60,
|
||||||
|
fontSize: 15),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
kVSpacer20,
|
kVSpacer20,
|
||||||
@@ -219,7 +223,9 @@ class _ToolRequirementSelectorPageState
|
|||||||
padding: EdgeInsets.only(left: 3),
|
padding: EdgeInsets.only(left: 3),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Agent Framework",
|
"Agent Framework",
|
||||||
style: TextStyle(color: Colors.white60),
|
style: TextStyle(
|
||||||
|
color: lightMode ? Colors.black54 : Colors.white60,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
kVSpacer8,
|
kVSpacer8,
|
||||||
@@ -248,7 +254,9 @@ class _ToolRequirementSelectorPageState
|
|||||||
padding: EdgeInsets.only(left: 3),
|
padding: EdgeInsets.only(left: 3),
|
||||||
child: Text(
|
child: Text(
|
||||||
"Target Language",
|
"Target Language",
|
||||||
style: TextStyle(color: Colors.white60),
|
style: TextStyle(
|
||||||
|
color: lightMode ? Colors.black54 : Colors.white60,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
kVSpacer8,
|
kVSpacer8,
|
||||||
@@ -273,6 +281,8 @@ class _ToolRequirementSelectorPageState
|
|||||||
isOutlined: true,
|
isOutlined: true,
|
||||||
),
|
),
|
||||||
kVSpacer20,
|
kVSpacer20,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
FilledButton.tonalIcon(
|
FilledButton.tonalIcon(
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
padding: kPh12,
|
padding: kPh12,
|
||||||
@@ -290,6 +300,10 @@ class _ToolRequirementSelectorPageState
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
kHSpacer5,
|
||||||
|
DefaultLLModelSelectorWidget(),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -304,9 +318,8 @@ class GeneratedToolCodeCopyPage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var codeTheme = Theme.of(context).brightness == Brightness.light
|
final lightMode = Theme.of(context).brightness == Brightness.light;
|
||||||
? kLightCodeTheme
|
var codeTheme = lightMode ? kLightCodeTheme : kDarkCodeTheme;
|
||||||
: kDarkCodeTheme;
|
|
||||||
|
|
||||||
if (toolCode == null) {
|
if (toolCode == null) {
|
||||||
return SendingWidget(
|
return SendingWidget(
|
||||||
@@ -321,7 +334,7 @@ class GeneratedToolCodeCopyPage extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.token_outlined,
|
Icons.token_outlined,
|
||||||
color: Colors.white12,
|
color: lightMode ? Colors.black12 : Colors.white12,
|
||||||
size: 500,
|
size: 500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -329,7 +342,7 @@ class GeneratedToolCodeCopyPage extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
color: const Color.fromARGB(255, 28, 28, 28),
|
color: const Color.fromARGB(26, 123, 123, 123),
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
width: MediaQuery.of(context).size.width * 0.50,
|
width: MediaQuery.of(context).size.width * 0.50,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -357,3 +370,40 @@ class GeneratedToolCodeCopyPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DefaultLLModelSelectorWidget extends ConsumerWidget {
|
||||||
|
const DefaultLLModelSelectorWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final settings = ref.watch(settingsProvider);
|
||||||
|
return Opacity(
|
||||||
|
opacity: 0.8,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(left: 3),
|
||||||
|
child: Text(
|
||||||
|
"with",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).brightness == Brightness.light
|
||||||
|
? Colors.black54
|
||||||
|
: Colors.white60,
|
||||||
|
fontSize: 15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 5),
|
||||||
|
DefaultLLMSelectorButton(
|
||||||
|
defaultLLM: settings.defaultLLMSaveObject,
|
||||||
|
onDefaultLLMUpdated: (d) {
|
||||||
|
ref
|
||||||
|
.read(settingsProvider.notifier)
|
||||||
|
.update(defaultLLMSaveObject: d);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
kVSpacer5,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ void showCustomDialog(BuildContext context, Widget dialogContent) {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Color.fromARGB(255, 16, 20, 24), // Dark background
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user