From e8c8b2a92ff700f3256d54dfeec62b039106bfbb Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 24 May 2023 15:34:23 -0700 Subject: [PATCH] Added ExpansionTile for Hugging Face API section to improve UI organization. --- app/lib/ai_settings_dialog.dart | 26 +++++++++++--- app/lib/api_key_dialog.dart | 64 +++++++++++++++++++-------------- 2 files changed, 60 insertions(+), 30 deletions(-) diff --git a/app/lib/ai_settings_dialog.dart b/app/lib/ai_settings_dialog.dart index 6344a85..ef66a43 100644 --- a/app/lib/ai_settings_dialog.dart +++ b/app/lib/ai_settings_dialog.dart @@ -270,6 +270,14 @@ Human: You choose anything you like. Direction comes from the next message. One @override Widget build(BuildContext context) { + if (HuggingFace_API.oat() == '' && _selectedModel == 'huggingface') { + OpenAI_API.setModel(_selectedModel); + setState(() { + _isHuggingFaceSelected = false; + _isGPT4Selected = false; + _selectedModel = 'gpt-3.5-turbo'; + }); + } return AlertDialog( title: Text('AI Settings'), content: Container( @@ -289,10 +297,11 @@ Human: You choose anything you like. Direction comes from the next message. One value: 'gpt-4', child: Text('GPT-4 (Advanced, Limited Beta)'), ), - DropdownMenuItem( - value: 'huggingface', - child: Text('Hugging Face (Experimental)'), - ), + if (HuggingFace_API.oat() != '') + DropdownMenuItem( + value: 'huggingface', + child: Text('Hugging Face (Experimental)'), + ), /*DropdownMenuItem( value: 'gpt-4-32k', child: Text('GPT-4-32k (Advanced, Limited Beta)'), @@ -314,6 +323,15 @@ Human: You choose anything you like. Direction comes from the next message. One children: [ SizedBox(height: 10), Text('Hugging Face Model ID:'), + SizedBox(height: 6), + InkWell( + child: Text( + '→ Browse available models', + style: TextStyle(color: Colors.blue), + ), + onTap: () => Utils.launchURL( + 'https://huggingface.co/models?pipeline_tag=text2text-generation&sort=downloads'), + ), TextField( controller: _modelIdController, // Use TextEditingController to retrieve user input diff --git a/app/lib/api_key_dialog.dart b/app/lib/api_key_dialog.dart index f83c9ea..78e71f1 100644 --- a/app/lib/api_key_dialog.dart +++ b/app/lib/api_key_dialog.dart @@ -93,34 +93,46 @@ class _ApiKeyDialogState extends State { SizedBox(height: 10), Divider(), SizedBox(height: 10), - Text( - '🤗 Hosted Inference API', - style: TextStyle(fontWeight: FontWeight.bold), - ), - SizedBox(height: 10), - Text('Get your Access Token:'), - InkWell( - child: Text( - '→ Hugging Face Dashboard', - style: TextStyle(color: Colors.blue), + ExpansionTile( + title: Text( + '🤗 Hosted Inference API', + style: TextStyle(fontWeight: FontWeight.bold), ), - onTap: () => - Utils.launchURL('https://huggingface.co/settings/tokens'), + children: [ + Align( + alignment: Alignment.centerLeft, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 10), + Text('Get your Access Token:'), + InkWell( + child: Text( + '→ Hugging Face Dashboard', + style: TextStyle(color: Colors.blue), + ), + onTap: () => Utils.launchURL( + 'https://huggingface.co/settings/tokens'), + ), + SizedBox(height: 10), + Text('Enter your Hugging Face Token:'), + TextField( + controller: _huggingFaceTokenController, + obscureText: true, + decoration: InputDecoration( + labelText: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), + onChanged: (value) { + setState(() { + _huggingFaceToken = value; + }); + }, + ), + SizedBox(height: 20), + ], + ), + ), + ], ), - SizedBox(height: 10), - Text('Enter your Hugging Face Token:'), - TextField( - controller: _huggingFaceTokenController, - obscureText: true, - decoration: InputDecoration( - labelText: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'), - onChanged: (value) { - setState(() { - _huggingFaceToken = value; - }); - }, - ), - SizedBox(height: 20), ], ), ),