DefaultLLMSelectorDialog: ResponsiveUI added

This commit is contained in:
Manas Hejmadi
2025-08-18 00:40:13 +05:30
parent db326b434a
commit 36f58ba26a

View File

@@ -76,6 +76,58 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
@override
Widget build(BuildContext context) {
if (!initialized) return SizedBox();
if (context.isMediumWindow) {
return Container(
padding: EdgeInsets.all(20),
width: MediaQuery.of(context).size.width * 0.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ElevatedButton(
onPressed: () async {
await LLMManager.fetchAvailableLLMs();
setState(() {});
},
child: Text('Fetch Models'),
),
kVSpacer10,
Row(
children: [
Text('Select Provider'),
kHSpacer20,
Expanded(
child: ADDropdownButton(
onChanged: (x) {
if (x == null) return;
selectedLLMProvider = x;
final models = x.models;
final mC = x.modelController;
final p = mC.inputPayload;
llmSaveObject = LLMSaveObject(
endpoint: p.endpoint,
credential: '',
configMap: p.configMap,
selectedLLM: models.first,
provider: x,
);
setState(() {});
},
value: selectedLLMProvider,
values: LLMProvider.values
.where(((e) => e.models.isNotEmpty))
.map((e) => (e, e.displayName)),
),
),
],
),
kVSpacer10,
_buildModelSelector(),
],
),
);
}
return Container(
padding: EdgeInsets.all(20),
width: MediaQuery.of(context).size.width * 0.8,
@@ -128,7 +180,15 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
SizedBox(width: 40),
Flexible(
flex: 3,
child: Container(
child: _buildModelSelector(),
),
],
),
);
}
_buildModelSelector() {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
@@ -194,12 +254,6 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
radius: 5,
backgroundColor: Colors.green,
),
IconButton(
onPressed: () => removeModel(x),
icon: Icon(
Icons.delete,
size: 20,
))
],
),
onTap: () {
@@ -226,19 +280,9 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
),
],
),
),
),
],
),
);
}
removeModel(LLMModel model) async {
await LLMManager.removeLLM(
selectedLLMProvider.name, model.identifier, model.modelName);
setState(() {});
}
addNewModel() async {
TextEditingController iC = TextEditingController();
TextEditingController nC = TextEditingController();