mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
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:
parent
48725a7937
commit
498d2b54ae
7 changed files with 90 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Collections;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
|
@ -108,6 +109,18 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _selectedIssueTrackerRule, value);
|
||||
}
|
||||
|
||||
public List<string> AvailableOpenAIServices
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string PreferedOpenAIService
|
||||
{
|
||||
get => _repo.Settings.PreferedOpenAIService;
|
||||
set => _repo.Settings.PreferedOpenAIService = value;
|
||||
}
|
||||
|
||||
public RepositoryConfigure(Repository repo)
|
||||
{
|
||||
_repo = repo;
|
||||
|
@ -116,6 +129,13 @@ namespace SourceGit.ViewModels
|
|||
foreach (var remote in _repo.Remotes)
|
||||
Remotes.Add(remote.Name);
|
||||
|
||||
AvailableOpenAIServices = new List<string>() { "---" };
|
||||
foreach (var service in Preference.Instance.OpenAIServices)
|
||||
AvailableOpenAIServices.Add(service.Name);
|
||||
|
||||
if (AvailableOpenAIServices.IndexOf(PreferedOpenAIService) == -1)
|
||||
PreferedOpenAIService = "---";
|
||||
|
||||
_cached = new Commands.Config(repo.FullPath).ListAll();
|
||||
if (_cached.TryGetValue("user.name", out var name))
|
||||
UserName = name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue