增加远程链接项

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

@@ -22,13 +22,25 @@ namespace YwxApp.AiChat.ViewModels
private bool _ollamaEnabled = false; //ollama connected state
private string _ollamaAppPath; //ollama app path.
private int recordIndex = 0; //current record index.
private string _currentPath; //current record;
private string _remoteHost = "192.168.1.6"; //current record;
private string _remotePort = "11434"; //current record;
private string _currentPath;
private Chat chat; //build interactive chat model object.
private OllamaApiClient _ollama; //OllamaAPI object.
#endregion
#region Property
public string RemoteHost
{
get { return _remoteHost; }
set { _remoteHost = value; }
}
public string RemotePort
{
get { return _remotePort; }
set { _remotePort = value; }
}
public string OllamaAppPath
{
get { return _ollamaAppPath; }
@@ -76,7 +88,7 @@ namespace YwxApp.AiChat.ViewModels
{
RecordIndex = 0;
WriteDataToFileAsync("");
Init(OllamaAppPath, "llama3.2:9b");
Init(OllamaAppPath, "llama3.2:9b");
}
#endregion
@@ -100,7 +112,7 @@ namespace YwxApp.AiChat.ViewModels
//如果路径存在启动Ollama
if (File.Exists(filePath)) CheckStartProcess(OllamaAppPath);
//连接Ollama并设置初始模型
_ollama = new OllamaApiClient(new Uri("http://localhost:11434"));
_ollama = new OllamaApiClient(new Uri("http://192.168.1.6:11434"));
//获取本地可用的模型列表
ModelList = (ObservableCollection<string>)GetModelList();
var tmepModelName = ModelList.FirstOrDefault(name => name.ToLower().Contains("llama3.2"));
@@ -117,6 +129,13 @@ namespace YwxApp.AiChat.ViewModels
OllamaEnabled = false;
}
}
public void ConnectRemotelyOllamaServer() {
_ollama = new OllamaApiClient(new Uri("http://192.168.1.6:11434"));
//获取本地可用的模型列表
ModelList = (ObservableCollection<string>)GetModelList();
}
/// <summary>
/// update the model selected by Ollama
/// </summary>