Skip to content

Commit 80fa2bd

Browse files
committed
create file with password and delete it afterwards
1 parent 7f5297a commit 80fa2bd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Runtime/LLM.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class LLM : LLMClient
5454
private ManualResetEvent serverBlock = new ManualResetEvent(false);
5555
static object crashKillLock = new object();
5656
static bool crashKill = false;
57+
private string keyfile = "";
5758

5859
#if UNITY_EDITOR
5960
[InitializeOnLoadMethod]
@@ -222,6 +223,7 @@ private void CheckIfListening(string message)
222223
{
223224
// Read the output of the llm binary and check if the server has been started and listening
224225
DebugLog(message);
226+
if (keyfile != "" && File.Exists(keyfile)) File.Delete(keyfile);
225227
if (serverListening) return;
226228
try
227229
{
@@ -252,8 +254,19 @@ private string EscapeSpaces(string input)
252254

253255
private void RunServerCommand(string exe, string args)
254256
{
257+
string passwordArgs = "";
258+
if (password != "")
259+
{
260+
keyfile = Path.Combine(Application.temporaryCachePath, Path.GetTempFileName());
261+
using (StreamWriter writer = new StreamWriter(keyfile))
262+
{
263+
writer.WriteLine(password);
264+
}
265+
passwordArgs = $" --api-key-file {keyfile}";
266+
}
267+
255268
string binary = exe;
256-
string arguments = args;
269+
string arguments = args + passwordArgs;
257270
if (Application.platform == RuntimePlatform.LinuxEditor || Application.platform == RuntimePlatform.LinuxPlayer)
258271
{
259272
// use APE binary directly if on Linux

0 commit comments

Comments
 (0)