Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.2.2 #105

Merged
merged 6 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v1.2.2
#### 🐛 Fixes

- use namespaces in all classes (PR: #104)
- await separately in StartServer (PR: #107)


## v1.2.1
#### 🐛 Fixes

Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### 🐛 Fixes

- Kill server after Unity crash (PR: #101)
- Persist chat template on remote servers (PR: #103)
- use namespaces in all classes (PR: #104)
- await separately in StartServer (PR: #107)

22 changes: 12 additions & 10 deletions Runtime/LLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,30 @@ private async Task StartLLMServer()

string GPUArgument = numGPULayers <= 0 ? "" : $" -ngl {numGPULayers}";
LLMUnitySetup.makeExecutable(server);
await RunAndWait(server, arguments + GPUArgument);

RunServerCommand(server, arguments + GPUArgument);
if (asynchronousStartup) await WaitOneASync(serverBlock, TimeSpan.FromSeconds(60));
else serverBlock.WaitOne(60000);

if (process.HasExited && mmapCrash)
{
Debug.Log("Mmap error, fallback to no mmap use");
serverBlock.Reset();
arguments += " --no-mmap";
await RunAndWait(server, arguments + GPUArgument);

RunServerCommand(server, arguments + GPUArgument);
if (asynchronousStartup) await WaitOneASync(serverBlock, TimeSpan.FromSeconds(60));
else serverBlock.WaitOne(60000);
}

if (process.HasExited && numGPULayers > 0)
{
Debug.Log("GPU failed, fallback to CPU");
serverBlock.Reset();
await RunAndWait(server, arguments);

RunServerCommand(server, arguments);
if (asynchronousStartup) await WaitOneASync(serverBlock, TimeSpan.FromSeconds(60));
else serverBlock.WaitOne(60000);
}

if (process.HasExited) throw new Exception("Server could not be started!");
Expand All @@ -342,13 +351,6 @@ public void OnDestroy()
StopProcess();
}

private async Task RunAndWait(string exe, string args, int seconds = 60)
{
RunServerCommand(exe, args);
if (asynchronousStartup) await WaitOneASync(serverBlock, TimeSpan.FromSeconds(seconds));
else serverBlock.WaitOne(seconds * 1000);
}

/// Wrapper from https://stackoverflow.com/a/18766131
private static Task WaitOneASync(WaitHandle handle, TimeSpan timeout)
{
Expand Down
Loading
Loading