瀏覽代碼

Sujith :) ->
1. Fixed issue with add component to asset to keep the asset in context
2. Figured how global needs to function

Sujith:) 2 周之前
父節點
當前提交
415a4f6a8d

+ 3 - 1
Assets/LLM/Editor/Client/GeminiApiClient.cs

@@ -101,7 +101,9 @@ namespace LLM.Editor.Client
 
         private async Task SendApiRequest(List<ChatEntry> chatHistory, string authToken)
         {
-            var url = $"https://{_settings.gcpRegion}-aiplatform.googleapis.com/v1/projects/{_settings.gcpProjectId}/locations/{_settings.gcpRegion}/publishers/google/models/{_settings.modelName}:generateContent";
+            var region = _settings.gcpRegion == "global" ? string.Empty : $"{_settings.gcpRegion}-";
+            
+            var url = $"https://{region}aiplatform.googleapis.com/v1/projects/{_settings.gcpProjectId}/locations/{_settings.gcpRegion}/publishers/google/models/{_settings.modelName}:generateContent";
             
             var systemPromptWithContext = GetWorkingContext();
             

+ 6 - 2
Assets/LLM/Editor/Commands/AddComponentToAssetCommand.cs

@@ -36,7 +36,7 @@ namespace LLM.Editor.Commands
             
             _params.scriptName ??= _params.componentName;
 
-            var targetObject = ResolveIdentifier(_params.targetIdentifier);
+            var targetObject = ResolveIdentifier(context, _params.targetIdentifier);
             if (!targetObject)
             {
                 Debug.LogError($"[AddComponentCommand] Could not find target with identifier '{_params.targetIdentifier}'.");
@@ -118,8 +118,12 @@ namespace LLM.Editor.Commands
             return foundChild ? foundChild.gameObject : null;
         }
 
-        private static UnityEngine.Object ResolveIdentifier(string identifier)
+        private static UnityEngine.Object ResolveIdentifier(Data.CommandContext context, string identifier)
         {
+            if (context.CurrentSubject is GameObject subjectGo && subjectGo.name == identifier)
+            {
+                return subjectGo;
+            }
             if (string.IsNullOrEmpty(identifier)) return null;
             if (int.TryParse(identifier, out var instanceId))
             {