-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Badly working knowledge base selector in llm
However, its rough, it assumes a hardcoded path to an embedder Looks like state is not well done thus it doesnt know when it's done. Just a lot of problems to fix before release but a working prototype.
- Loading branch information
1 parent
69d2450
commit fce62b3
Showing
4 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
lib/pages/text_generation/widgets/knowledge_base_selector.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:fluent_ui/fluent_ui.dart'; | ||
import 'package:inference/langchain/object_box/embedding_entity.dart'; | ||
import 'package:inference/langchain/object_box/object_box.dart'; | ||
import 'package:inference/objectbox.g.dart'; | ||
import 'package:inference/providers/text_inference_provider.dart'; | ||
import 'package:inference/widgets/controls/no_outline_button.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class KnowledgeBaseSelector extends StatefulWidget { | ||
const KnowledgeBaseSelector({super.key}); | ||
|
||
@override | ||
State<KnowledgeBaseSelector> createState() => _KnowledgeBaseSelectorState(); | ||
} | ||
|
||
class _KnowledgeBaseSelectorState extends State<KnowledgeBaseSelector> { | ||
late List<KnowledgeGroup> groups; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
groups = ObjectBox.instance.store.box<KnowledgeGroup>().getAll(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Consumer<TextInferenceProvider>(builder: (context, inference, child) { | ||
return DropDownButton( | ||
buttonBuilder: (context, callback) { | ||
return NoOutlineButton( | ||
onPressed: callback, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Row( | ||
children: [ | ||
(inference.knowledgeGroup == null | ||
? const Text("Knowledge Base") | ||
: Text("Knowledge Base: ${inference.knowledgeGroup!.name}") | ||
), | ||
const Padding( | ||
padding: EdgeInsets.only(left: 8), | ||
child: Icon(FluentIcons.chevron_down, size: 12), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
}, | ||
items: [ | ||
MenuFlyoutItem(text: const Text("None"), onPressed: () { | ||
inference.knowledgeGroup = null; | ||
}), | ||
for (final group in groups) | ||
|
||
MenuFlyoutItem(text: Text(group.name), onPressed: () { | ||
inference.knowledgeGroup = group; | ||
}) | ||
] | ||
); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters