mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
DefaultLLMSelectorDialog: ResponsiveUI added
This commit is contained in:
@@ -76,6 +76,58 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (!initialized) return SizedBox();
|
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(
|
return Container(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
width: MediaQuery.of(context).size.width * 0.8,
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
@@ -128,7 +180,15 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
|
|||||||
SizedBox(width: 40),
|
SizedBox(width: 40),
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Container(
|
child: _buildModelSelector(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildModelSelector() {
|
||||||
|
return Container(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
@@ -194,12 +254,6 @@ class _DefaultLLMSelectorDialogState extends State<DefaultLLMSelectorDialog> {
|
|||||||
radius: 5,
|
radius: 5,
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
),
|
),
|
||||||
IconButton(
|
|
||||||
onPressed: () => removeModel(x),
|
|
||||||
icon: Icon(
|
|
||||||
Icons.delete,
|
|
||||||
size: 20,
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
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 {
|
addNewModel() async {
|
||||||
TextEditingController iC = TextEditingController();
|
TextEditingController iC = TextEditingController();
|
||||||
TextEditingController nC = TextEditingController();
|
TextEditingController nC = TextEditingController();
|
||||||
|
|||||||
Reference in New Issue
Block a user