Skip to content

Commit

Permalink
Added ExpansionTile for Hugging Face API section to improve UI organi…
Browse files Browse the repository at this point in the history
…zation.
  • Loading branch information
jacob-i committed May 24, 2023
1 parent b1c25e8 commit e8c8b2a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 30 deletions.
26 changes: 22 additions & 4 deletions app/lib/ai_settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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<String>(
value: 'huggingface',
child: Text('Hugging Face (Experimental)'),
),
if (HuggingFace_API.oat() != '')
DropdownMenuItem<String>(
value: 'huggingface',
child: Text('Hugging Face (Experimental)'),
),
/*DropdownMenuItem<String>(
value: 'gpt-4-32k',
child: Text('GPT-4-32k (Advanced, Limited Beta)'),
Expand All @@ -314,6 +323,15 @@ Human: You choose anything you like. Direction comes from the next message. One
children: <Widget>[
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
Expand Down
64 changes: 38 additions & 26 deletions app/lib/api_key_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,46 @@ class _ApiKeyDialogState extends State<ApiKeyDialog> {
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: <Widget>[
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),
],
),
),
Expand Down

0 comments on commit e8c8b2a

Please sign in to comment.