|
|
@@ -1,145 +0,0 @@
|
|
|
-––– comment –––
|
|
|
-This test verifies intent classification and conversation flow in the ConversationalRag plugin.
|
|
|
-Tests various user intents: NEW_SEARCH, TOPIC_CHANGE, INTEREST, REJECTION, ALTERNATIVES.
|
|
|
-Based on issue #3978 - conversational RAG with intent classification.
|
|
|
-Uses rich document content based on internal test data (schema.sql).
|
|
|
-––– block: ../base/start-searchd-with-buddy –––
|
|
|
-––– comment –––
|
|
|
-Setup: Create test table with documents about AI, programming, and entertainment
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 << EOF
|
|
|
-CREATE TABLE docs (
|
|
|
- id BIGINT,
|
|
|
- content TEXT,
|
|
|
- title TEXT,
|
|
|
- category TEXT,
|
|
|
- embedding_vector FLOAT_VECTOR
|
|
|
- knn_type='hnsw'
|
|
|
- hnsw_similarity='cosine'
|
|
|
- model_name='sentence-transformers/all-MiniLM-L6-v2'
|
|
|
- from='content'
|
|
|
- api_key='\${OPENAI_API_KEY}'
|
|
|
-) TYPE='rt';
|
|
|
-EOF
|
|
|
-––– output –––
|
|
|
-––– comment –––
|
|
|
-Insert rich test documents based on internal test data (schema.sql)
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 << 'EOF'
|
|
|
-INSERT INTO docs (id, content, title, category) VALUES
|
|
|
-(1, 'Artificial intelligence is the capability of computational systems to perform tasks typically associated with human intelligence such as learning, reasoning, problem-solving, perception and decision-making. High-profile applications include advanced web search engines, recommendation systems, virtual assistants, autonomous vehicles and generative AI tools. The field was founded as an academic discipline in 1956 and has gone through multiple cycles of optimism and disappointment known as AI winters.', 'Artificial Intelligence', 'AI'),
|
|
|
-(2, 'Machine learning is a field of study in artificial intelligence concerned with the development of statistical algorithms that can learn from data and generalize to unseen data. It finds application in natural language processing, computer vision, speech recognition, email filtering, agriculture and medicine. Deep learning, a subset of machine learning, has allowed neural networks to surpass many previous approaches in performance.', 'Machine Learning', 'AI'),
|
|
|
-(3, 'Retrieval-augmented generation (RAG) is a technique that enables large language models to retrieve and incorporate new information. RAG improves LLMs by incorporating information retrieval before generating responses, pulling relevant text from databases, uploaded documents or web sources. This method helps reduce AI hallucinations and allows LLMs to include sources in their responses for greater transparency.', 'Retrieval-Augmented Generation', 'AI'),
|
|
|
-(4, 'PHP is a general-purpose scripting language geared towards web development created by Rasmus Lerdorf in 1993. PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or a Common Gateway Interface executable. The language has evolved without a written formal specification with the original implementation acting as the de facto standard.', 'PHP', 'Programming'),
|
|
|
-(5, 'Python is a high-level general-purpose programming language designed by Guido van Rossum. Its design philosophy emphasizes code readability with the use of significant indentation. Python supports multiple programming paradigms including structured, object-oriented and functional programming. It consistently ranks as one of the most popular programming languages and has gained widespread use in the machine learning community.', 'Python', 'Programming'),
|
|
|
-(6, 'Breaking Bad is an American neo-Western crime drama television series created by Vince Gilligan for AMC. The series follows Walter White, an underpaid high school chemistry teacher who turns to producing methamphetamine after being diagnosed with lung cancer. The show stars Bryan Cranston as Walter White, Aaron Paul as Jesse Pinkman, Anna Gunn as Skyler White, Dean Norris as Hank Schrader, and Bob Odenkirk as Saul Goodman. It premiered in 2008 and has been praised as one of the greatest television series of all time.', 'Breaking Bad', 'Entertainment'),
|
|
|
-(7, 'The Mandalorian is an American space Western television series created by Jon Favreau for Disney Plus. It is the first live-action series in the Star Wars franchise and follows Din Djarin, a lone bounty hunter played by Pedro Pascal, who protects a Force-sensitive child named Grogu. The series premiered with the launch of Disney Plus on November 12, 2019 and has received largely positive reviews from critics.', 'The Mandalorian', 'Entertainment'),
|
|
|
-(8, 'Stranger Things is an American television series created by the Duffer Brothers for Netflix. Set in the 1980s, the series centers on the residents of the fictional small town of Hawkins, Indiana, after a nearby facility opens a gateway to a hostile alternate dimension known as the Upside Down. The show stars Winona Ryder, David Harbour, Millie Bobby Brown and Finn Wolfhard.', 'Stranger Things', 'Entertainment'),
|
|
|
-(9, 'Game of Thrones is an American fantasy drama television series created by David Benioff for HBO. It is an adaptation of A Song of Ice and Fire novels. Set on the fictional continents of Westeros and Essos, the show follows several story arcs throughout eight seasons including the Iron Throne succession and the threat from the North.', 'Game of Thrones', 'Entertainment'),
|
|
|
-(10, 'The Office is an American mockumentary sitcom television series adapted for NBC by Greg Daniels. The show depicts the everyday work lives of office employees at the Scranton Pennsylvania branch of the fictional Dunder Mifflin Paper Company. It stars Steve Carell, Rainn Wilson, John Krasinski, Jenna Fischer and B.J. Novak.', 'The Office', 'Entertainment');
|
|
|
-EOF
|
|
|
-––– output –––
|
|
|
-––– comment –––
|
|
|
-Wait for auto-embeddings generation (async via Buddy)
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "debug sleep 30;" > /dev/null 2>&1
|
|
|
-––– output –––
|
|
|
-––– comment –––
|
|
|
-Create RAG model
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CREATE RAG MODEL test_assistant (llm_provider='openai', llm_model='gpt-4o-mini');"
|
|
|
-––– output –––
|
|
|
-+--------------------------------------+
|
|
|
-| uuid |
|
|
|
-+--------------------------------------+
|
|
|
-| #!/[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}/!# |
|
|
|
-+--------------------------------------+
|
|
|
-––– comment –––
|
|
|
-Test 1: Initial question about RAG (NEW_SEARCH intent)
|
|
|
-Expected: Search for RAG/AI-related documents, response contains RAG keywords
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('What is RAG?', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | tee /tmp/rag_intent_test1.txt | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.*(RAG|[Rr]etrieval|[Gg]eneration|[Aa]ugmented).*/!#
|
|
|
- sources: #!/\[.*/!#
|
|
|
-––– comment –––
|
|
|
-Verify sources contain AI category documents
|
|
|
-––– input –––
|
|
|
-grep -c '"category":"AI"' /tmp/rag_intent_test1.txt
|
|
|
-––– output –––
|
|
|
-#!/[1-9][0-9]*/!#
|
|
|
-––– comment –––
|
|
|
-Test 2: User expresses rejection (REJECTION intent - "Its boring")
|
|
|
-Expected: System acknowledges rejection, maintains conversation
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('Its boring', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.+/!#
|
|
|
- sources: #!/\[.*/!#
|
|
|
-––– comment –––
|
|
|
-Test 3: Topic change to movies (TOPIC_CHANGE intent)
|
|
|
-Expected: Search for Entertainment category
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('what about movies?', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | tee /tmp/rag_intent_test3.txt | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.+/!#
|
|
|
- sources: #!/\[.*/!#
|
|
|
-––– comment –––
|
|
|
-Verify sources contain Entertainment category after topic change
|
|
|
-––– input –––
|
|
|
-grep -c '"category":"Entertainment"' /tmp/rag_intent_test3.txt
|
|
|
-––– output –––
|
|
|
-#!/[1-9][0-9]*/!#
|
|
|
-––– comment –––
|
|
|
-Test 4: User shows interest in specific show (INTEREST intent)
|
|
|
-Expected: Should find Breaking Bad in sources
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('I like Breaking Bad', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.+/!#
|
|
|
- sources: #!/.*Breaking Bad.*/!#
|
|
|
-––– comment –––
|
|
|
-Test 5: Emotional response (conversational)
|
|
|
-Expected: Responds conversationally, uses previous context
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('omg thats amazing', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.+/!#
|
|
|
- sources: #!/\[.*/!#
|
|
|
-––– comment –––
|
|
|
-Test 6: Request for more content (ALTERNATIVES intent)
|
|
|
-Expected: Returns more entertainment results
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('show me more entertainment', 'docs', 'test_assistant', 'content', 'test-conv-intent-001')\G;" | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-001
|
|
|
- response: #!/.+/!#
|
|
|
- sources: #!/\[.*/!#
|
|
|
-––– comment –––
|
|
|
-Test 7: New independent conversation - Programming topic
|
|
|
-Expected: Fresh context, should find Python
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "CALL CONVERSATIONAL_RAG('Tell me about Python', 'docs', 'test_assistant', 'content', 'test-conv-intent-002')\G;" | tee /tmp/rag_intent_test8.txt | grep -E "conversation_uuid:|response:|sources:"
|
|
|
-––– output –––
|
|
|
-conversation_uuid: test-conv-intent-002
|
|
|
- response: #!/.*[Pp]ython.*/!#
|
|
|
- sources: #!/.*Python.*/!#
|
|
|
-––– comment –––
|
|
|
-Verify sources contain Programming category (new conversation context)
|
|
|
-––– input –––
|
|
|
-grep -c '"category":"Programming"' /tmp/rag_intent_test8.txt
|
|
|
-––– output –––
|
|
|
-#!/[1-9][0-9]*/!#
|
|
|
-––– comment –––
|
|
|
-Cleanup
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "DROP RAG MODEL test_assistant;"
|
|
|
-––– output –––
|
|
|
-––– input –––
|
|
|
-mysql -h0 -P9306 -e "DROP TABLE IF EXISTS docs;"
|
|
|
-––– output –––
|