Skip to content

Commit 54e99ce

Browse files
committed
Embeddings browser
1 parent 6342ffc commit 54e99ce

15 files changed

+350
-170
lines changed

App.xaml.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
using System.Windows;
1+
using System.Windows;
82

93
namespace SDPromptTool
104
{

GlobalResDictionary.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,4 +1218,6 @@
12181218
</Style.Triggers>
12191219
</Style>
12201220
<!--#endregion-->
1221+
1222+
<converter:MiscToolReplaceCharConverter x:Key="MTRCConverter" />
12211223
</ResourceDictionary>

MainWindow.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using SDPromptTool.ViewModel;
2-
using System.Collections;
32
using System.Windows;
43
using System.Windows.Input;
54

@@ -18,9 +17,9 @@ public MainWindow()
1817

1918
private void Window_KeyDown(object sender, KeyEventArgs e)
2019
{
21-
if(Keyboard.IsKeyDown(Key.LeftCtrl))
20+
if (Keyboard.IsKeyDown(Key.LeftCtrl))
2221
{
23-
switch(e.Key)
22+
switch (e.Key)
2423
{
2524
case Key.D1:
2625
MainTab.SelectedIndex = 0;

Model/EmbeddingsListModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace SDPromptTool.Model
2+
{
3+
public class EmbeddingsListModel
4+
{
5+
public string EmbName { get; set; }
6+
public string EmbTag { get; set; }
7+
}
8+
}

Model/MiscToolReplaceCharModel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows.Controls;
1+
using System.Windows.Controls;
52

63
namespace SDPromptTool.Model
74
{

View/MiscellaneousTools.xaml

Lines changed: 183 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,90 +11,192 @@
1111
d:DesignHeight="420"
1212
d:DesignWidth="580">
1313
<UserControl.Resources>
14-
<converter:MiscToolReplaceCharConverter x:Key="MTRCConverter" />
15-
</UserControl.Resources>
16-
<d:UserControl.Resources>
1714
<ResourceDictionary>
1815
<ResourceDictionary.MergedDictionaries>
1916
<ResourceDictionary Source="/GlobalResDictionary.xaml" />
2017
</ResourceDictionary.MergedDictionaries>
2118
</ResourceDictionary>
22-
</d:UserControl.Resources>
23-
<Grid Margin="5">
24-
<Grid.RowDefinitions>
25-
<RowDefinition />
26-
<RowDefinition />
27-
</Grid.RowDefinitions>
28-
<Grid.ColumnDefinitions>
29-
<ColumnDefinition />
30-
<ColumnDefinition />
31-
</Grid.ColumnDefinitions>
32-
<Grid Margin="0,0,5,5"
33-
Grid.Row="0"
34-
Grid.Column="0">
35-
<Grid.RowDefinitions>
36-
<RowDefinition Height="25" />
37-
<RowDefinition Height="*" />
38-
<RowDefinition Height="*" />
39-
</Grid.RowDefinitions>
40-
<StackPanel Grid.Row="0"
41-
Orientation="Horizontal">
42-
<Label Content="Replace"
43-
FontSize="14"
44-
Foreground="White"
45-
Margin="0,-2,0,0" />
46-
<TextBox Style="{DynamicResource UniTextBoxStyle}"
47-
Name="ReplaceFrom"
48-
FontSize="14"
49-
Text="{}{}"
50-
VerticalContentAlignment="Center"
51-
Height="20"
52-
Width="25"
53-
Margin="0,0,0,2"
54-
Padding="0,-3,0,0" />
55-
<Label Content="with"
56-
FontSize="14"
57-
Foreground="White"
58-
Margin="0,-2,0,0" />
59-
<TextBox Style="{DynamicResource UniTextBoxStyle}"
60-
Name="ReplaceTo"
61-
FontSize="14"
62-
Text="()"
63-
VerticalContentAlignment="Center"
64-
Height="20"
65-
Width="25"
66-
Margin="0,0,0,2"
67-
Padding="0,-3,0,0" />
68-
<Button Style="{DynamicResource UniBtnStyle}"
69-
Content="🔰"
70-
Height="20"
71-
Width="20"
72-
Margin="20,0,0,2"
73-
ToolTip="It's character-based.&#x0a;By default, it will replace all '{' with '(' and all '}' with ')'."
74-
Command="{Binding MiscTools.ReplaceCharCommand}">
75-
<Button.CommandParameter>
76-
<MultiBinding Converter="{StaticResource MTRCConverter}">
77-
<Binding ElementName="ReplaceFrom"
78-
Path="Text" />
79-
<Binding ElementName="ReplaceTo"
80-
Path="Text" />
81-
<Binding ElementName="TextBefore"
82-
Path="Text" />
83-
<Binding ElementName="TextAfter" />
84-
</MultiBinding>
85-
</Button.CommandParameter>
86-
</Button>
87-
</StackPanel>
88-
<TextBox Name="TextBefore"
89-
Grid.Row="1"
90-
AcceptsReturn="True"
91-
Style="{DynamicResource UniTextBoxStyle}"
92-
Margin="0,0,0,2" />
93-
<TextBox Name="TextAfter"
94-
Grid.Row="2"
95-
AcceptsReturn="True"
96-
Style="{DynamicResource UniTextBoxStyle}"
97-
Margin="0,2,0,0" />
98-
</Grid>
99-
</Grid>
19+
</UserControl.Resources>
20+
<TabControl Background="Transparent"
21+
TabStripPlacement="Left">
22+
<TabItem Header="Replace Char"
23+
Foreground="White"
24+
Style="{StaticResource TabItemStyle1}"
25+
Background="#1E1E1E">
26+
<Grid Margin="5,2,5,5"
27+
Grid.Row="0"
28+
Grid.Column="0">
29+
<Grid.RowDefinitions>
30+
<RowDefinition Height="25" />
31+
<RowDefinition Height="*" />
32+
<RowDefinition Height="*" />
33+
</Grid.RowDefinitions>
34+
<StackPanel Grid.Row="0"
35+
Orientation="Horizontal">
36+
<Label Content="Replace"
37+
FontSize="14"
38+
Foreground="White"
39+
Margin="0,-2,0,0" />
40+
<TextBox Style="{DynamicResource UniTextBoxStyle}"
41+
Name="ReplaceFrom"
42+
FontSize="14"
43+
Text="{}{}"
44+
VerticalContentAlignment="Center"
45+
Height="20"
46+
Width="25"
47+
Margin="0,0,0,2"
48+
Padding="0,-3,0,0" />
49+
<Label Content="with"
50+
FontSize="14"
51+
Foreground="White"
52+
Margin="0,-2,0,0" />
53+
<TextBox Style="{DynamicResource UniTextBoxStyle}"
54+
Name="ReplaceTo"
55+
FontSize="14"
56+
Text="()"
57+
VerticalContentAlignment="Center"
58+
Height="20"
59+
Width="25"
60+
Margin="0,0,0,2"
61+
Padding="0,-3,0,0" />
62+
<Button Style="{DynamicResource UniBtnStyle}"
63+
Content="🔰"
64+
Height="20"
65+
Width="20"
66+
Margin="20,0,0,2"
67+
ToolTip="It's character-based.&#x0a;By default, it will replace all '{' with '(' and all '}' with ')'."
68+
Command="{Binding MiscTools.ReplaceCharCommand}">
69+
<Button.CommandParameter>
70+
<MultiBinding Converter="{StaticResource MTRCConverter}">
71+
<Binding ElementName="ReplaceFrom"
72+
Path="Text" />
73+
<Binding ElementName="ReplaceTo"
74+
Path="Text" />
75+
<Binding ElementName="TextBefore"
76+
Path="Text" />
77+
<Binding ElementName="TextAfter" />
78+
</MultiBinding>
79+
</Button.CommandParameter>
80+
</Button>
81+
</StackPanel>
82+
<TextBox Name="TextBefore"
83+
Grid.Row="1"
84+
AcceptsReturn="True"
85+
Style="{DynamicResource UniTextBoxStyle}"
86+
Margin="0,0,0,2" />
87+
<TextBox Name="TextAfter"
88+
Grid.Row="2"
89+
AcceptsReturn="True"
90+
Style="{DynamicResource UniTextBoxStyle}"
91+
Margin="0,2,0,0" />
92+
</Grid>
93+
</TabItem>
94+
<TabItem Header="Emb. List"
95+
Foreground="White"
96+
Style="{StaticResource TabItemStyle1}"
97+
Background="#1E1E1E">
98+
<Grid Margin="5">
99+
<Grid.ColumnDefinitions>
100+
<ColumnDefinition Width="2*" />
101+
<ColumnDefinition Width="*" />
102+
</Grid.ColumnDefinitions>
103+
<Grid.RowDefinitions>
104+
<RowDefinition Height="*" />
105+
<RowDefinition Height="25" />
106+
</Grid.RowDefinitions>
107+
<DockPanel Grid.Row="1"
108+
Grid.Column="0"
109+
Grid.ColumnSpan="2">
110+
<Label Content="Path"
111+
Foreground="WhiteSmoke"
112+
DockPanel.Dock="Left"
113+
Padding="0,4,5,0" />
114+
<TextBox DockPanel.Dock="Left"
115+
Background="Transparent"
116+
VerticalContentAlignment="Center"
117+
Style="{DynamicResource UniTextBoxStyle}"
118+
Text="{Binding MiscTools.EmbDir, UpdateSourceTrigger=PropertyChanged}" />
119+
</DockPanel>
120+
<Grid Grid.Column="0">
121+
<Grid.RowDefinitions>
122+
<RowDefinition Height="25" />
123+
<RowDefinition Height="*" />
124+
</Grid.RowDefinitions>
125+
<DockPanel Grid.Row="0">
126+
<Label DockPanel.Dock="Left"
127+
Content="Positive Embeddings"
128+
Foreground="WhiteSmoke"
129+
FontSize="14"
130+
Padding="5,0,0,0" />
131+
<Button DockPanel.Dock="Right"
132+
Width="60"
133+
Style="{DynamicResource UniBtnStyle}"
134+
Content="Save All"
135+
HorizontalAlignment="Right"
136+
Margin="0,0,5,3"
137+
Padding="0,0,0,1.4"
138+
Command="{Binding MiscTools.UpdateEmbJsonCommand}" />
139+
</DockPanel>
140+
<ListBox Grid.Row="1"
141+
Background="Transparent"
142+
Margin="0,0,5,5"
143+
ItemsSource="{Binding MiscTools.PEmbList}"
144+
d:ItemsSource="{d:SampleData ItemCount=8}">
145+
<ListBox.ItemTemplate>
146+
<DataTemplate>
147+
<StackPanel Orientation="Horizontal">
148+
<Label Foreground="White"
149+
FontSize="13"
150+
Content="{Binding EmbName}"
151+
ToolTip="{Binding EmbName}" />
152+
<TextBox Foreground="White"
153+
VerticalContentAlignment="Center"
154+
Style="{DynamicResource UniTextBoxStyle}"
155+
Text="{Binding EmbTag}"
156+
ToolTip="{Binding EmbTag}" />
157+
</StackPanel>
158+
</DataTemplate>
159+
</ListBox.ItemTemplate>
160+
</ListBox>
161+
</Grid>
162+
<Grid Grid.Column="1">
163+
<Grid.RowDefinitions>
164+
<RowDefinition Height="25" />
165+
<RowDefinition Height="*" />
166+
</Grid.RowDefinitions>
167+
<Label Grid.Row="0"
168+
Content="Negative Embeddings"
169+
Foreground="WhiteSmoke"
170+
FontSize="14"
171+
Padding="5,0,0,0" />
172+
<ListBox Grid.Row="1"
173+
Background="Transparent"
174+
Margin="0,0,5,5"
175+
ItemsSource="{Binding MiscTools.NEmbList}"
176+
d:ItemsSource="{d:SampleData ItemCount=8}">
177+
<ListBox.ItemTemplate>
178+
<DataTemplate>
179+
<StackPanel Orientation="Horizontal">
180+
<Label Foreground="White"
181+
FontSize="13"
182+
Content="{Binding EmbName}"
183+
ToolTip="{Binding EmbName}" />
184+
<TextBox Foreground="White"
185+
VerticalContentAlignment="Center"
186+
Style="{DynamicResource UniTextBoxStyle}"
187+
Text="{Binding EmbTag}"
188+
ToolTip="{Binding EmbTag}" />
189+
</StackPanel>
190+
</DataTemplate>
191+
</ListBox.ItemTemplate>
192+
</ListBox>
193+
</Grid>
194+
</Grid>
195+
</TabItem>
196+
<TabItem Header="TBD"
197+
Foreground="White"
198+
Style="{StaticResource TabItemStyle1}"
199+
Background="#1E1E1E">
200+
</TabItem>
201+
</TabControl>
100202
</UserControl>

View/MiscellaneousTools.xaml.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows;
5-
using System.Windows.Controls;
6-
using System.Windows.Data;
7-
using System.Windows.Documents;
8-
using System.Windows.Input;
9-
using System.Windows.Media;
10-
using System.Windows.Media.Imaging;
11-
using System.Windows.Navigation;
12-
using System.Windows.Shapes;
1+
using System.Windows.Controls;
132

143
namespace SDPromptTool.View
154
{

0 commit comments

Comments
 (0)