Skip to content

Commit 5c62436

Browse files
committed
Docs: Add 'See it in action' section for NLGenerationAndChatbotTest demo with links to class and output.
1 parent 250cf70 commit 5c62436

File tree

1 file changed

+107
-9
lines changed

1 file changed

+107
-9
lines changed

RAG_Demo.md

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
2+
# 🌟 Full AI Workflow Demo: NLGenerationAndChatbotTest.java
3+
4+
Start with the comprehensive demonstration in `NLGenerationAndChatbotTest.java` to see the entire AI-enhanced test automation workflow in action—including natural language test generation, RAG-powered chatbot, conversation context/memory, and advanced integration.
5+
6+
**Test class:**
7+
`src/test/java/org/k11techlab/framework_unittests/aiTests/NLGenerationAndChatbotTest.java`
8+
9+
**Key features demonstrated:**
10+
- Natural language to TestNG test generation (with code patching and file output)
11+
- RAG-powered chatbot Q&A, debugging, and code review
12+
- Multi-turn conversation with context and memory
13+
- Advanced integration: multi-step test generation, knowledge base retrieval, and performance assessment
14+
- End-to-end assertions and debug output for each step
15+
16+
**Generated output:**
17+
- All generated test code and conversation logs are saved in `src/test/ai_generated_tests/` for review and reuse.
18+
19+
**How to run:**
20+
1. Build the project:
21+
```sh
22+
mvn clean package
23+
```
24+
2. Run the test suite (from your IDE or with Maven):
25+
```sh
26+
mvn test -Dtest=org.k11techlab.framework_unittests.aiTests.NLGenerationAndChatbotTest
27+
```
28+
3. Review the console output and generated files in `src/test/ai_generated_tests/`.
29+
30+
31+
## See it in action:
32+
* [NLGenerationAndChatbotTest.java (Full AI Workflow Demo)](src/test/java/org/k11techlab/framework_unittests/aiTests/NLGenerationAndChatbotTest.java)
33+
* [Generated Output Folder](src/test/ai_generated_tests/)
34+
35+
Explore this class to see how RAG and NLP can supercharge your test automation workflow!
36+
137
# How to Run the RAG Embedding Cache Demo
238

339
1. **Build the project:**
@@ -7,7 +43,6 @@
743
2. **Run the demo:**
844
```sh
945
java -cp target/classes org.k11techlab.framework.ai.rag.demo.RAGComponentsDemo
10-
```
1146
Or, if using Maven:
1247
```sh
1348
mvn exec:java -Dexec.mainClass="org.k11techlab.framework.ai.rag.demo.RAGComponentsDemo"
@@ -16,16 +51,8 @@
1651
- Output will be printed to the console.
1752
- To save output to a file:
1853
```sh
19-
java -cp target/classes org.k11techlab.framework.ai.rag.demo.RAGComponentsDemo > RAGComponentsDemo_output.txt
20-
```
21-
4. **Check the embedding cache:**
22-
- The file `embedding_cache.json` will be created/updated in your project directory.
23-
- On subsequent runs, you should see `[EMBED] Cache HIT` for all unchanged chunks.
2454

2555
# 🚀 How I Optimized RAG Embedding Efficiency in Java (with Live Demo Output!)
26-
27-
Retrieval-Augmented Generation (RAG) is a game-changer for AI-powered search and Q&A, but embedding computation can be slow and costly if not managed well. In my latest project, I implemented a persistent embedding cache for our Java-based RAG pipeline—ensuring embeddings are only computed once per document chunk and reused on every run.
28-
2956
## What’s the impact?
3057
- ⚡️ Massive speedup on repeated queries
3158
- 💸 Reduced API costs (no redundant embedding calls)
@@ -59,3 +86,74 @@ With a simple file-based cache, you can make your RAG pipeline blazing fast and
5986

6087
---
6188

89+
# 🧪 More RAG Test Samples
90+
91+
Below are additional sample queries and outputs to showcase the RAG pipeline’s power for framework Q&A and test automation:
92+
93+
## 1. Framework Q&A
94+
**Query:**
95+
```
96+
How do I implement a self-healing Selenium locator?
97+
```
98+
**Sample Output:**
99+
```
100+
Top relevant docs for: How do I implement a self-healing Selenium locator?
101+
- testartifacts/docs/AI_Testing_Assistant/SELENIUM_SELF_HEALING.md
102+
...
103+
===== Synthesized Answer =====
104+
To implement a self-healing Selenium locator, use a wrapper that tries alternative locators when the primary one fails. For example, maintain a list of XPaths or CSS selectors and attempt each in order. See the Self-Healing module in the framework docs for code samples.
105+
```
106+
107+
## 2. Test Case Generation
108+
**Query:**
109+
```
110+
Generate a TestNG test for login functionality.
111+
```
112+
**Sample Output:**
113+
```
114+
Top relevant docs for: Generate a TestNG test for login functionality.
115+
- testartifacts/docs/AI_Testing_Assistant/TEST_AUTOMATION_GUIDE.md
116+
...
117+
===== Synthesized Answer =====
118+
@Test
119+
public void testLogin() {
120+
driver.get("https://example.com/login");
121+
driver.findElement(By.id("username")).sendKeys("user");
122+
driver.findElement(By.id("password")).sendKeys("pass");
123+
driver.findElement(By.id("loginBtn")).click();
124+
Assert.assertTrue(driver.findElement(By.id("welcomeMsg")).isDisplayed());
125+
}
126+
```
127+
128+
## 3. Troubleshooting
129+
**Query:**
130+
```
131+
Why am I getting StaleElementReferenceException in Selenium?
132+
```
133+
**Sample Output:**
134+
```
135+
Top relevant docs for: Why am I getting StaleElementReferenceException in Selenium?
136+
- testartifacts/docs/AI_Testing_Assistant/SELENIUM_EXCEPTIONS.md
137+
...
138+
===== Synthesized Answer =====
139+
StaleElementReferenceException occurs when the element you are interacting with is no longer attached to the DOM. This can happen after a page reload or dynamic content update. Solution: Re-locate the element before interacting, or use explicit waits.
140+
```
141+
142+
## 4. Framework Usage
143+
**Query:**
144+
```
145+
How do I configure the AI provider order for RAG?
146+
```
147+
**Sample Output:**
148+
```
149+
Top relevant docs for: How do I configure the AI provider order for RAG?
150+
- config/chatbot.ai.properties
151+
...
152+
===== Synthesized Answer =====
153+
Set the provider order in config/chatbot.ai.properties:
154+
ai.provider.priority=OPENAI,OLLAMA,SIMPLE
155+
This determines the fallback order for LLMs in your RAG pipeline.
156+
```
157+
158+
---
159+

0 commit comments

Comments
 (0)