#!/usr/bin/env python3 """ Integration test for softmax selection with backend word service. """ import os def test_backend_integration(): """Test how the backend would use the softmax selection""" print("๐Ÿงช Testing backend integration with softmax selection...") # Simulate backend environment variables os.environ['SIMILARITY_TEMPERATURE'] = '0.7' os.environ['USE_SOFTMAX_SELECTION'] = 'true' # Test the interface that backend services would use from thematic_word_generator import UnifiedThematicWordGenerator generator = UnifiedThematicWordGenerator() print("โœ… Generator created with softmax enabled") # Test the key parameters print(f"๐Ÿ“Š Configuration:") print(f" Temperature: {generator.similarity_temperature}") print(f" Softmax enabled: {generator.use_softmax_selection}") # Test different temperature values test_temperatures = [0.3, 0.7, 1.0, 1.5] print(f"\n๐ŸŒก๏ธ Testing different temperatures:") for temp in test_temperatures: generator.similarity_temperature = temp if temp == 0.3: print(f" {temp}: More deterministic (favors high similarity)") elif temp == 0.7: print(f" {temp}: Balanced (recommended default)") elif temp == 1.0: print(f" {temp}: Standard softmax") elif temp == 1.5: print(f" {temp}: More random (flatter distribution)") print(f"\n๐Ÿ“ Backend usage example:") print(f" # Set environment variables:") print(f" export SIMILARITY_TEMPERATURE=0.7") print(f" export USE_SOFTMAX_SELECTION=true") print(f" ") print(f" # Use in backend:") print(f" generator = UnifiedThematicWordGenerator()") print(f" words = generator.generate_thematic_words(['animals'], num_words=15)") print(f" # Words will be selected using softmax-weighted sampling") print("โœ… Backend integration test completed!") if __name__ == "__main__": test_backend_integration()