增加远程链接项

This commit is contained in:
yangwx
2025-03-12 23:13:02 +08:00
parent 3ccd6d9a39
commit cb5c895d33
16 changed files with 103 additions and 249 deletions

View File

@@ -35,6 +35,16 @@ namespace YwxApp.AiChat.ViewModels
get { return _ollama.OllamaAppPath; }
set { _ollama.OllamaAppPath = value; OnPropertyChanged(); }
}
public string RemoteHost
{
get { return _ollama.RemoteHost; }
set { _ollama.RemoteHost = value; OnPropertyChanged(); }
}
public string RemotePort
{
get { return _ollama.RemotePort; }
set { _ollama.RemotePort = value; OnPropertyChanged(); }
}
public string SelectedModel
{
get => _selectedModel;
@@ -84,6 +94,7 @@ namespace YwxApp.AiChat.ViewModels
public ICommand GetModelListCommand { get; } //get model list command.
public ICommand ModelListUpdateCommand { get; } //model list update command.
public ICommand StartOllamaServerCommand { get; } //start ollam server command.
public ICommand ConnectRemotelyOllamaServerCommand { get; }
#endregion
#endregion
@@ -92,13 +103,19 @@ namespace YwxApp.AiChat.ViewModels
public SettingViewModel(ShareOllamaObject ollama)
{
_ollama = ollama;
Task task = OnGetModelList();
// Task task = OnGetModelList();
OpenFileDialogCommand = new ParameterlessCommand(() => OnSelectOllamaAppPathDialog());
GetModelListCommand = new ParameterlessCommand(async () => await OnGetModelList());
ModelListUpdateCommand = new ParameterlessCommand(async () => await OnModelListUpdate());
StartOllamaServerCommand = new ParameterlessCommand(async () => OnStartOllamaServer());
ConnectRemotelyOllamaServerCommand = new ParameterlessCommand(async () => OnConnectRemotelyStartOllamaServer());
SetConnected();
}
private void OnConnectRemotelyStartOllamaServer()
{
_ollama.ConnectRemotelyOllamaServer();
}
#endregion
#region other method
@@ -185,6 +202,8 @@ namespace YwxApp.AiChat.ViewModels
ModelList = (ObservableCollection<string>)_ollama.GetModelList();
Debug.Print($"ModelList count: {ModelList.Count}");
SelectedModel = _ollama.Ollama.SelectedModel;
SelectedModel = ModelList.FirstOrDefault();
ResetModelName();
var modelName = ModelList.FirstOrDefault(name => name.Equals(SelectedModel));
if (ModelList.Count > 0 && modelName != null)
{