feature: add per-repository setting for prefered OpenAI service

* If there is only one OpenAI service available, discard the setting of prefered OpenAI service. Instead, use it directly
* If there are multiple OpenAI service available, try to find the prefered one or show a context menu for users to choose the one they want to use

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-28 21:31:40 +08:00
parent 48725a7937
commit 498d2b54ae
No known key found for this signature in database
7 changed files with 90 additions and 4 deletions

View file

@ -340,6 +340,39 @@
</ContentControl>
</Grid>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.OpenAI}"/>
</TabItem.Header>
<Grid Margin="16,4,16,8" RowDefinitions="32,Auto" ColumnDefinitions="Auto,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Text="{DynamicResource Text.Configure.OpenAI.Prefered}"/>
<ComboBox Grid.Row="0" Grid.Column="1"
Height="28" Padding="8,0"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
ItemsSource="{Binding AvailableOpenAIServices}"
SelectedItem="{Binding PreferedOpenAIService, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
<Path Width="12" Height="12" Data="{StaticResource Icons.AIAssist}" Fill="{DynamicResource Brush.FG1}"/>
<TextBlock Margin="6,0,0,0" Text="{Binding}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Row="1" Grid.Column="1"
Margin="0,6,0,0"
Text="{DynamicResource Text.Configure.OpenAI.Prefered.Tip}"
TextWrapping="Wrap"
Foreground="{DynamicResource Brush.FG2}"/>
</Grid>
</TabItem>
</TabControl>
</Grid>
</v:ChromelessWindow>