Skip to content

Start LLM always asynchronously #199

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

Merged
merged 1 commit into from
Jul 26, 2024
Merged
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
24 changes: 1 addition & 23 deletions Runtime/LLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,6 @@ public class LLM : MonoBehaviour
[LLM] public bool debug = false;
/// <summary> number of prompts that can happen in parallel (-1 = number of LLMCharacter objects) </summary>
[LLMAdvanced] public int parallelPrompts = -1;
/// <summary> allows to start the server asynchronously.
/// This is useful to not block Unity while the server is initialised.
/// For example it can be used as follows:
/// \code
/// void Start(){
/// StartCoroutine(Loading());
/// ...
/// }
///
/// IEnumerator<string> Loading()
/// {
/// // show loading screen
/// while (!llm.started)
/// {
/// yield return null;
/// }
/// Debug.Log("Server is ready");
/// }
/// \endcode
/// </summary>
[LLMAdvanced] public bool asynchronousStartup = true;
/// <summary> select to not destroy the LLM GameObject when loading a new Scene. </summary>
[LLMAdvanced] public bool dontDestroyOnLoad = true;
/// <summary> Size of the prompt context (0 = context size of the model).
Expand Down Expand Up @@ -119,8 +98,7 @@ public async void Awake()
await AndroidSetup();
string arguments = GetLlamaccpArguments();
if (arguments == null) return;
if (asynchronousStartup) await Task.Run(() => StartLLMServer(arguments));
else StartLLMServer(arguments);
await Task.Run(() => StartLLMServer(arguments));
if (dontDestroyOnLoad) DontDestroyOnLoad(transform.root.gameObject);
if (basePrompt != "") await SetBasePrompt(basePrompt);
}
Expand Down
Loading