Examples / Specifications / Fuzzy Matching
Fuzzy Matching
Has SpecsRequires API Keys
Focused demonstration of fuzzy matching for AI output validation. This example shows: - High-threshold fuzzy matching (0.95) for near-exact matches - Medium-threshold fuzzy matching (0.45) for semantic similarity - Default threshold behavior when not specified - Using fuzzy matching to handle natural language variation
Source Code
World = Agent {
model = "openai/gpt-4o-mini",
system_prompt = "Your name is World."
}
Specification([[
Feature: Fuzzy Matching
Scenario: High-threshold fuzzy match (nearly exact)
Given the procedure has started
And the message is "Hello, World!"
And the agent "World" responds with "Hello! I'm World, nice to meet you!"
When the procedure runs
Then the output should fuzzy match "Hello! I'm World, nice to meet you!" with threshold 0.95
Scenario: Medium-threshold fuzzy match (allows variation)
Given the procedure has started
And the message is "Hello, World!"
And the agent "World" responds with "Hello! How can I assist you today?"
When the procedure runs
Then the output should fuzzy match "Hello! I'm World, nice to meet you!" with threshold 0.45
Scenario: Default fuzzy match threshold
Given the procedure has started
And the message is "Hello, World!"
And the agent "World" responds with "Hello! I'm World, nice to meet you!"
When the procedure runs
Then the output should fuzzy match "Hello! I'm World, nice to meet you!"
]])
local result = World({message = "Hello, World!"})
return (result and (result.output or result)) or ""
Quick Start
Run the example:
$tactus run 04-specifications/03-fuzzy-matching.tacTest with mocks:
$tactus test 04-specifications/03-fuzzy-matching.tac --mockNote
This example requires API keys. Set your OPENAI_API_KEY environment variable before running.
Explore more examples
Learn Tactus through practical, runnable examples organized by topic.