-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
616 additions
and
15 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
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
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
src/STranslate/ViewModels/Preference/Services/PromptViewModel.cs
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 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using STranslate.Model; | ||
using System.Linq; | ||
using System.Windows; | ||
|
||
namespace STranslate.ViewModels.Preference.Services | ||
{ | ||
public partial class PromptViewModel : ObservableObject | ||
{ | ||
[ObservableProperty] | ||
private UserDefinePrompt _userDefinePrompt; | ||
|
||
private readonly ServiceType _serviceType; | ||
|
||
public PromptViewModel(ServiceType type, UserDefinePrompt definePrompt) | ||
{ | ||
_serviceType = type; | ||
UserDefinePrompt = definePrompt; | ||
} | ||
|
||
[RelayCommand] | ||
private void Add() | ||
{ | ||
var last = UserDefinePrompt.Prompts.LastOrDefault()?.Role ?? ""; | ||
var newOne = _serviceType switch | ||
{ | ||
ServiceType.GeminiService | ||
=> last switch | ||
{ | ||
"user" => new Prompt("model"), | ||
_ => new Prompt("user") | ||
}, | ||
ServiceType.ChatglmService | ||
=> last switch | ||
{ | ||
"user" => new Prompt("assistant"), | ||
_ => new Prompt("user") | ||
}, | ||
_ | ||
=> last switch | ||
{ | ||
"" => new Prompt("system"), | ||
"user" => new Prompt("assistant"), | ||
_ => new Prompt("user") | ||
}, | ||
}; | ||
UserDefinePrompt.Prompts.Add(newOne); | ||
} | ||
|
||
[RelayCommand] | ||
private void Del(Prompt prompt) | ||
{ | ||
UserDefinePrompt.Prompts.Remove(prompt); | ||
} | ||
|
||
[RelayCommand] | ||
private void Save(Window window) | ||
{ | ||
window.DialogResult = true; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.