Skip to content

Commit

Permalink
Merge pull request #23 from guchengxi1994/master
Browse files Browse the repository at this point in the history
cmakelist
  • Loading branch information
guchengxi1994 authored May 3, 2024
2 parents 89cea45 + e57a8ef commit b5fb1a8
Show file tree
Hide file tree
Showing 24 changed files with 1,174 additions and 172 deletions.
4 changes: 2 additions & 2 deletions assets/llm.json
Git LFS file not shown
1 change: 1 addition & 0 deletions lib/llm/langchain/components/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Buttons extends ConsumerWidget {
GestureDetector(
onTap: () {
ref.read(toolProvider.notifier).changeState(null);
ref.read(toolProvider.notifier).jumpTo(0);
},
child: _wrapper(const Text(
"返回",
Expand Down
176 changes: 176 additions & 0 deletions lib/llm/langchain/components/modify_chain_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import 'package:all_in_one/llm/langchain/models/chains.dart';
import 'package:all_in_one/styles/app_style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';

class ModifyChainDialog extends StatefulWidget {
const ModifyChainDialog({super.key, required this.item});
final FlowElement item;

@override
State<ModifyChainDialog> createState() => _ModifyChainDialogState();
}

class _ModifyChainDialogState extends State<ModifyChainDialog> {
late final TextEditingController itemTextController = TextEditingController()
..text = widget.item.text;
final itemTextFocusNode = FocusNode();
final TextEditingController inputKeyController = TextEditingController();
final inputKeyFocusNode = FocusNode();
final TextEditingController outputKeyController = TextEditingController();
final outputKeyFocusNode = FocusNode();
final TextEditingController promptController = TextEditingController()
..text = "{{placeholder}}";
final promptFocusNode = FocusNode();

final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
return Material(
borderRadius: BorderRadius.circular(4),
elevation: 10,
child: Container(
padding: const EdgeInsets.all(20),
width: 400,
height: 320,
child: Form(
key: _formKey,
child: Column(
children: [
_wrapper(
"name",
SizedBox(
height: 30,
child: TextFormField(
validator: (value) {
if (value == null || value == "") {
return "";
}
return null;
},
controller: itemTextController,
style:
const TextStyle(color: Colors.black, fontSize: 12),
decoration: AppStyle.inputDecoration,
autofocus: true,
onFieldSubmitted: (value) {
inputKeyFocusNode.requestFocus();
},
),
)),
const SizedBox(
height: 20,
),
_wrapper(
"input",
SizedBox(
height: 30,
child: TextFormField(
validator: (value) {
if (value == null || value == "") {
return "";
}
return null;
},
controller: inputKeyController,
style: const TextStyle(
color: Colors.black, fontSize: 12),
decoration: AppStyle.inputDecoration,
autofocus: false,
onFieldSubmitted: (value) {
outputKeyFocusNode.requestFocus();
},
))),
const SizedBox(
height: 20,
),
_wrapper(
"output",
SizedBox(
height: 30,
child: TextFormField(
validator: (value) {
if (value == null || value == "") {
return "";
}
return null;
},
controller: outputKeyController,
style: const TextStyle(
color: Colors.black, fontSize: 12),
decoration: AppStyle.inputDecoration,
autofocus: false,
onFieldSubmitted: (value) {
promptFocusNode.requestFocus();
},
))),
const SizedBox(
height: 20,
),
_wrapper(
"prompt",
TextFormField(
validator: (value) {
if (value == null || value == "") {
return "";
}
if (value.contains("{{placeholder}}")) {
return null;
}

return "";
},
maxLines: 3,
controller: promptController,
style: const TextStyle(color: Colors.black, fontSize: 12),
decoration: AppStyle.inputDecoration,
autofocus: false,
onFieldSubmitted: (value) {
_formKey.currentState!.validate();
},
)),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.of(context).pop((
itemTextController.text,
ChainItem(
inputKey: inputKeyController.text,
outputKey: outputKeyController.text,
prompt: promptController.text)
));
}
},
child: const Text("确定"))
],
)
],
)),
),
);
}

_wrapper(String title, Widget child) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 100,
child: Text(title),
),
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: child,
))
],
);
}
}
Loading

0 comments on commit b5fb1a8

Please sign in to comment.