Skip to content

Commit 84991b7

Browse files
fix regression bugs in AI functionality
1 parent 4a36226 commit 84991b7

File tree

21 files changed

+88
-55
lines changed

21 files changed

+88
-55
lines changed

Bellatrix.LLM/assertions/AiValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void WaitForAssertionToPass()
4343

4444
var result = SemanticKernelService.Kernel.InvokeAsync(nameof(AssertionSkill), nameof(AssertionSkill.EvaluateAssertion), new()
4545
{
46-
["htmlSummary"] = appSnapshot,
46+
["viewSnapshot"] = appSnapshot,
4747
["assertInstruction"] = assertInstruction
4848
}).Result;
4949

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1+
version: '3.9'
12
services:
2-
postgres-locator:
3+
bellatrixllm-cache:
34
image: postgres:15
4-
container_name: locator-cache-db
5+
container_name: bellatrixllm-cache
56
restart: unless-stopped
67
environment:
78
POSTGRES_DB: LocatorCacheDb
89
POSTGRES_USER: postgres
910
POSTGRES_PASSWORD: devpassword
1011
ports:
11-
- "5433:5432" # Use a different host port
12+
- "5433:5432"
1213
volumes:
13-
- locator_pgdata:/var/lib/postgresql/data
14+
- bellatrixllm_pgdata:/var/lib/postgresql/data
15+
16+
bellatrixllm-vectorstore:
17+
image: qdrant/qdrant
18+
container_name: bellatrixllm-vectorstore
19+
restart: unless-stopped
20+
ports:
21+
- "6333:6333"
22+
- "6334:6334"
23+
volumes:
24+
- bellatrixllm_qdrantdata:/qdrant/storage
1425

1526
volumes:
16-
locator_pgdata:
27+
bellatrixllm_pgdata:
28+
bellatrixllm_qdrantdata:

Bellatrix.LLM/embeddingsPythonServerInstructions.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ In WebTests we need to call -> WebPluginsConfiguration.ConfigureLLM();
1010

1111
- Execute this for local cache and postgres:
1212

13+
14+
// run both
15+
docker compose -f docker-compose.local_cache_postgres.yml up -d
16+
17+
// run to start Qdrant in docker
18+
docker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
19+
20+
// run to start postgres in docker
1321
docker-compose -f docker-compose.local_cache_postgres.yml up -d
1422

1523
docker-compose -f docker-compose.local_cache_postgres.yml down -v

Bellatrix.LLM/plugins/SmartFailureAnalysisPlugin .cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class SmartFailureAnalysisPlugin : Plugin, IScreenshotPlugin
3131
public SmartFailureAnalysisPlugin()
3232
{
3333
_screenshotOutputProvider = ServicesCollection.Current.Resolve<IScreenshotOutputProvider>();
34-
_viewSnapshotProvider = ServicesCollection.Current.Resolve<IViewSnapshotProvider>();
34+
_viewSnapshotProvider = ServicesCollection.Main.Resolve<IViewSnapshotProvider>();
3535
}
3636

3737
public static void Add()

Bellatrix.LLM/services/LocatorSelfHealingService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public static string TryHeal(string failingLocator, string newestVersionViewSumm
6969
var prompt = SemanticKernelService.Kernel.InvokeAsync("LocatorSkill", "HealBrokenLocator", new()
7070
{
7171
["failedLocator"] = failingLocator,
72-
["oldViewummary"] = known.ViewSummary,
73-
["newViewSummary"] = newestVersionViewSummary
72+
["oldSnapshot"] = known.ViewSummary,
73+
["newSnapshot"] = newestVersionViewSummary
7474
}).Result.GetValue<string>();
7575

7676
var suggestion = SemanticKernelService.Kernel.InvokePromptAsync(prompt).Result.GetValue<string>()?.Trim();

Bellatrix.LLM/services/SmartFailureAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static string Diagnose(string testName, string exceptionDetails, string c
9696
}
9797

9898
var prompt = SemanticKernelService.Kernel
99-
.InvokeAsync(nameof(FailureAnalyzerSkill), "GenerateFailureDiagnosis", arguments).Result;
99+
.InvokeAsync(nameof(FailureAnalyzerSkill), nameof(FailureAnalyzerSkill.GenerateFailureDiagnosis), arguments).Result;
100100

101101
var suggestion = SemanticKernelService.Kernel.InvokePromptAsync(prompt.GetValue<string>()).Result.GetValue<string>()?.Trim();
102102

Bellatrix.LLM/skills/LocatorMapperSkill.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@ You are an AI assistant that maps user instructions to known UI locators.
2828
User wants to: {instruction}
2929
3030
From the list of known locators below, pick the one that best matches and return its exact locator in the format:
31-
locator_strategy=locator_value
31+
xpath=...
3232
3333
Known Locators:
3434
{pageSummary}
3535
3636
Examples:
3737
For login button → return xpath=//button[@id='login']
38-
For search input → return id=input-search
38+
For search input → return xpath=//input[@id='input-search']
3939
40-
Return ONLY one valid locator in that format. If no match is found, return Unknown.
40+
Return ONLY one valid XPath locator in that format. If no match is found, return Unknown.
4141
""";
4242
}
43-
44-
4543
}

src/Bellatrix.Desktop/infrastructure/App.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
// </copyright>
1212
// <author>Anton Angelov</author>
1313
// <site>https://bellatrix.solutions/</site>
14-
using System;
15-
using System.Collections.Generic;
16-
using System.Diagnostics;
17-
using System.IO;
18-
using System.Linq;
19-
using System.Reflection;
2014
using Bellatrix;
2115
using Bellatrix.Assertions;
2216
using Bellatrix.AWS;
@@ -26,8 +20,15 @@
2620
using Bellatrix.Desktop.PageObjects;
2721
using Bellatrix.Desktop.Services;
2822
using Bellatrix.DynamicTestCases;
23+
using Bellatrix.LLM;
2924
using Bellatrix.Plugins;
3025
using Bellatrix.Utilities;
26+
using System;
27+
using System.Collections.Generic;
28+
using System.Diagnostics;
29+
using System.IO;
30+
using System.Linq;
31+
using System.Reflection;
3132

3233
namespace Bellatrix.Desktop;
3334

@@ -40,6 +41,7 @@ public class App : IDisposable
4041
public App()
4142
{
4243
_shouldStartLocalService = ConfigurationService.GetSection<DesktopSettings>().ExecutionSettings.ShouldStartLocalService;
44+
ServicesCollection.Main.RegisterInstance<IViewSnapshotProvider>(AppService);
4345
}
4446

4547
public AppService AppService => ServicesCollection.Current.Resolve<AppService>();

src/Bellatrix.Desktop/llm/FindByPrompt.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
using Microsoft.SemanticKernel;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text.RegularExpressions;
5-
using System.Threading;
6-
using System;
7-
using Bellatrix.LLM;
1+
using Bellatrix.Desktop.LLM.Plugins;
82
using Bellatrix.Desktop.Locators;
93
using Bellatrix.Desktop.Services;
4+
using Bellatrix.LLM;
5+
using Bellatrix.LLM.Plugins;
6+
using Microsoft.SemanticKernel;
107
using OpenQA.Selenium.Appium;
118
using OpenQA.Selenium.Appium.Windows;
12-
using Bellatrix.Desktop.LLM.Plugins;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Text.RegularExpressions;
13+
using System.Threading;
1314

1415
namespace Bellatrix.Desktop.LLM;
1516

@@ -65,7 +66,7 @@ private string TryResolveLocator(string location)
6566
{
6667
var pageSummary = match.Partitions.FirstOrDefault()?.Text ?? "";
6768
var mappedPrompt = SemanticKernelService.Kernel
68-
.InvokeAsync("Mapper", "MatchPromptToKnownLocator", new()
69+
.InvokeAsync(nameof(LocatorMapperSkill), nameof(LocatorMapperSkill.MatchPromptToKnownLocator), new()
6970
{
7071
["pageSummary"] = pageSummary,
7172
["instruction"] = Value

src/Bellatrix.Desktop/services/AppService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class AppService : DesktopService, IViewSnapshotProvider
2525
public AppService(WindowsDriver<WindowsElement> wrappedDriver)
2626
: base(wrappedDriver)
2727
{
28-
ServicesCollection.Current.RegisterInstance<IViewSnapshotProvider>(this);
2928
}
3029

3130
public string Title => WrappedDriver.Title;

0 commit comments

Comments
 (0)