From 57a0cf59deea7c46cf2bc4ddea7dfaa204fddc9f Mon Sep 17 00:00:00 2001 From: Antonis Makropoulos Date: Tue, 27 Aug 2024 13:21:30 +0300 Subject: [PATCH] allow relative StreamingAssets paths for models --- Runtime/LLMManager.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Runtime/LLMManager.cs b/Runtime/LLMManager.cs index 34301fac..f08edc87 100644 --- a/Runtime/LLMManager.cs +++ b/Runtime/LLMManager.cs @@ -19,9 +19,20 @@ public class ModelEntry public bool includeInBuild; public int contextLength; + public static string GetFilenameOrRelativeAssetPath(string path) + { + string assetPath = LLMUnitySetup.GetAssetPath(path); // Note: this will return the full path if a full path is passed + string basePath = LLMUnitySetup.GetAssetPath(); + if (File.Exists(assetPath) && LLMUnitySetup.IsSubPath(assetPath, basePath)) + { + return LLMUnitySetup.RelativePath(assetPath, basePath); + } + return path; + } + public ModelEntry(string path, bool lora = false, string label = null, string url = null) { - filename = Path.GetFileName(path); + filename = GetFilenameOrRelativeAssetPath(path); this.label = label == null ? filename : label; this.lora = lora; this.path = LLMUnitySetup.GetFullPath(path);