Commit graph

208 commits

Author SHA1 Message Date
ccedf063a0
Fix action buttons position - insert after <pre> not inside it (#36)
Problem:
- Buttons were being inserted as children of <pre> element
- This caused buttons to appear inside code blocks with wrong styling
- Template caching made changes appear to require "two commits"

Solution:
- Change insertion point from block.parentNode to preElement.parentNode
- This places buttons as siblings of <pre>, not children
- Add TEMPLATES_AUTO_RELOAD=True to prevent Flask template caching

Technical Details:
- block is the <code> element
- block.parentNode is the <pre> element
- preElement.parentNode.insertBefore puts buttons after <pre>
- Previous code put buttons inside <pre> after <code>

DOM Structure Before:
  <pre>
    <code>...</code>
    <buttons> <!-- Wrong: inside pre -->
  </pre>

DOM Structure After:
  <pre>
    <code>...</code>
  </pre>
  <buttons> <!-- Correct: after pre -->

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-11 13:38:03 -05:00
Claude
39e39e80f1
Fix flake8 F824 errors - remove unused global declarations
Remove unnecessary global declarations for MODEL_CLIENT_MAP that are never reassigned
2025-11-10 19:39:36 +00:00
Claude
22db7a9a8a
Run black formatter on all Python files
Format code according to black style guidelines for consistency
2025-11-10 19:37:05 +00:00
Claude
fd78927e7c
Fix MODEL_X references to use dynamic model registry
When MODEL_X references (MODEL_0, MODEL_1, etc.) are used, the code now
properly looks up actual model names from the dynamic registry (MODEL_CLIENT_MAP)
instead of hardcoding "model" or requiring MODEL_NAME_X environment variables.

Changes:
- app.py: Look up models from MODEL_CLIENT_MAP for the specified endpoint
- guarded_ai.py: Query endpoints for actual model names at initialization
- guarded_ai.py: Use dynamic registry for MODEL_X lookups

This fixes the "model not found" error when using activities with MODEL_X
references like activity37.
2025-11-08 19:58:21 +00:00
Claude
8cebcbf118
Add MODEL_X reference support to app.py
Critical fix for activity model configuration:
- Handle MODEL_1, MODEL_2, MODEL_3 references in get_openai_client_and_model()
- Look up MODEL_ENDPOINT_{n}, MODEL_API_KEY_{n}, MODEL_NAME_{n} from environment
- Fall back gracefully to default model if MODEL_{n} not configured
- Matches implementation in research/guarded_ai.py

Fixes error: 'NoneType' object has no attribute 'chat'
This error occurred when activities tried to use classifier_model="MODEL_1"
but the app didn't know how to resolve the MODEL_X reference.

Now activity37 (programming languages) will work correctly with:
- classifier_model: "MODEL_1" (Hermes for classification)
- feedback_model: "MODEL_3" (Qwen3-Coder for code generation)
2025-11-08 19:47:32 +00:00
2811dad67b Refactor activity functions into separate activity.py module
Moved all activity-related functions from app.py to a new activity.py
module to improve code organization and maintainability. This reduces
app.py from 2852 lines to 1552 lines.

Changes:
- Created activity.py with 16 activity-related functions
- Updated app.py to import and initialize activity module
- Updated test_app.py to import activity module
- All 34 unit tests pass successfully
2025-10-22 20:23:06 -04:00
77e2c04ec0 Use selected model for activity AI operations
Pass the selected model parameter through the entire activity workflow
to ensure all AI operations (categorization, translation, feedback
generation, and grading) use the user's chosen model instead of
defaulting to the system default. Falls back to default when no model
is selected.
2025-10-22 20:04:20 -04:00
8a6170d57b Remove STFU system from feedback filtering
- Remove STFU check from app.py feedback filtering logic
- Update tests to remove STFU-specific test cases
- Simplify empty content filtering to just check for actual content
2025-08-11 17:20:59 -04:00
fca7addaa5 Fix battleship AI hallucination bug with skip_condition system
Add skip_condition logic to feedback prompts to prevent AI from generating
false ship destruction messages when no ships were actually destroyed.

Changes:
- Add skip_condition parameter support in provide_feedback_prompts()
- Support all_null, all_false, and all_true condition types
- Apply skip_condition to battleship Ship Status and Game Over prompts
- Add comprehensive unit tests covering all skip condition scenarios
- Test real battleship scenario that was causing hallucinations

This prevents the AI from creating false positive ship destruction messages
when metadata indicates no ships were actually sunk (all null values).
2025-08-11 17:04:17 -04:00
acdf653eaa Enhance user experience with multiple improvements
- Add username field to right sidebar and mobile modal with 'guest' default
- Implement real-time username sync with URL query string updates
- Add opencompletion.com button and new room creation in left sidebar
- Implement room name slugification (e.g. "a whole new world" → "a-whole-new-world")
- Create shared utils.js for common functions like slugify
- Add single search result auto-redirect functionality
- Remove redundant UI elements ("Create New Room" header, docs link)
- Preserve user settings (username, model, voice) across redirects and room creation

Technical improvements:
- Consolidated duplicate code into shared utility functions
- Enhanced search logic with parameter preservation
- Improved mobile/desktop sync for all input fields
- Better URL handling and query string management
2025-08-11 16:01:51 -04:00
dada6b3f22 Add comprehensive integration tests for streaming protocol
- Created test_streaming_protocol_simple.py with 3 passing tests
- Created test_streaming_protocol.py with comprehensive test suite
- Tests verify new protocol format with separate username/model fields
- Tests confirm content separation from metadata for clean TTS processing
- Added debug logging for Game Over feedback prompt
- All tests validate the streaming refactoring works correctly
2025-08-11 14:13:36 -04:00
4e122e708c Refactor streaming protocol to separate username/model from content
Backend changes:
- Send username, model_name, and is_first_chunk as separate fields
- Keep actual content separate from header formatting
- Cleaner separation of concerns in streaming protocol

Frontend changes:
- Build display content with header only for visual rendering
- Keep messageBuffers clean (content only) for TTS processing
- TTS now processes pure content without username headers

This fixes the issue where TTS was reading 'fxhp (model):' prefix
2025-08-11 13:46:51 -04:00
1808c915e1 Automatically return to activity chooser when activity completes
- Added activity_status emit with active: false when activity ends
- Now matches behavior of activity cancellation
- Users will automatically see activity chooser when activity finishes
2025-08-11 13:10:28 -04:00
f3d4dd89bc Add debug output for Game Over metadata filtering to investigate STFU bug when game actually ends 2025-08-11 12:47:25 -04:00
f90df2ae57 modified: activity_yaml_validator.py
modified:   app.py
	modified:   research/activity29-battleship.yaml
	modified:   research/activity29-testship.yaml
	modified:   research/guarded_ai.py
	modified:   tests/functional/test_activity_flows.py
	modified:   tests/functional/test_battleship_pre_script.py
	modified:   tests/functional/test_guarded_ai.py
	modified:   tests/unit/test_activity_yaml_validator.py
	modified:   tests/unit/test_app_feedback.py
	modified:   tests/unit/test_guarded_ai.py
2025-08-11 12:39:42 -04:00
d4d697db59 Implement per-prompt metadata filtering and fix battleship feedback system
Major improvements to battleship game feedback accuracy and user experience:

## New Multi-Prompt Feedback System
- Replaced single feedback with 3 specialized prompts: Shot Report, Ship Status, Game Over
- Each prompt has individual metadata filtering to see only relevant data
- Shot Report only sees hit/miss data, Ship Status only sees ship destruction data
- Added STFU token system to suppress empty messages (filtered out automatically)

## Technical Implementation
- Added per-prompt metadata_filter support in YAML structure
- Updated app.py and guarded_ai.py to handle prompt-specific filtering
- Legacy single-prompt system still works with transition-level filtering
- Added comprehensive test suite for feedback system validation

## User Experience Fixes
- Fixed TTS queue blocking JavaScript execution (async promises instead of await)
- Ship Status now correctly reports who destroyed which ship (role confusion fixed)
- Game Over only appears when game actually ends (no more random messages)
- Maintained dramatic storytelling while ensuring factual accuracy

## Battleship-Specific Improvements
- Ship destruction messages only appear when ships actually sink
- Clear separation of concerns: hits/misses vs ship destruction vs game over
- Eliminated false positive ship destruction reports
- Fixed role reversal where wrong player got credit for destruction

The battleship narrator now provides accurate, contextual feedback while preserving the dramatic naval warfare atmosphere.
2025-08-11 11:39:49 -04:00
e28dc11f04 Improve user experience with battleship feedback and auto-play TTS
- Fix battleship feedback perspective confusion with better Hermes prompting
- Add auto-play TTS button with localStorage persistence and queueing system
- Move activity controls below model/voice selectors in sidebar
- Add activity controls to mobile hamburger menu
- Fix model/activity dropdowns to stay within container bounds
- Filter activities API to only show .yaml/.yml files
- Clean up system message labels by moving to usernames (System (Feedback), System (Question))
- Apply black formatting to app.py
2025-08-11 09:34:29 -04:00
45a8f60cd2 Significantly improve test coverage with comprehensive integration tests
Major improvements:
- app.py coverage: 15% → 25% (+10 percentage points)
- research/guarded_ai.py coverage: 68% → 81% (+13 percentage points)
- Overall project coverage: 68% → 72% (+4 percentage points)

Key changes:
- Add comprehensive Flask integration tests for app.py activity functions
- Test real database operations with in-memory SQLite
- Add extensive guarded_ai.py error handling and client management tests
- Enhanced Makefile with comprehensive test targets
- Updated requirements-test.txt with flake8
- All 135 tests now passing with proper test coverage

The integration tests use real Flask environment, actual YAML processing,
and genuine database operations instead of mocks for accurate coverage.
2025-08-10 20:52:56 -04:00
1ca6f67c3d Fix code quality issues from PR review
- Add matplotlib.use("Agg") backend configuration to prevent runtime errors in headless environments
- Add error handling guards for script results that might return None
- Fix AI targeting logic to exclude already-fired cells in super hunter and hunter modes
- Update CLAUDE.md with matplotlib best practices
2025-08-10 16:01:58 -04:00
29573eaa75 Enhance battleship activity with improved user input handling and feedback
- Add user_response to pre-script metadata for better game state management
- Implement metadata_feedback_filter to control feedback data exposure
- Improve ship destruction announcements and game over messaging
- Add debug logging for ship sinking events
- Include test ship configuration file
2025-08-10 14:49:03 -04:00
368c7d290e Add Hermes Reasoner mode to battleship with game ending fixes
- Add new Hermes Reasoner AI mode that combines probability analysis with LLM reasoning
- Implement pre-script and post-script architecture in app.py for flexible YAML processing
- Fix game ending detection by adding transition override mechanism
- Add probability matrix visualization and strategic move analysis
- Support both legacy processing_script and new pre_script/post_script naming
- Restore full ship complement for complete battleship gameplay
2025-08-10 11:57:22 -04:00
38f414c5a9 Fix critical security vulnerabilities in Flask application
- Prevent SQL injection in search functionality with input sanitization
- Add path traversal protection for local file operations
- Replace hardcoded secret key with environment variable
- Escape HTML output to prevent XSS attacks in image generation
- Restrict file access to research/ directory with .yaml extension only
- Add comprehensive input validation and error handling

Security improvements maintain full application functionality while
protecting against common web application vulnerabilities.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 00:00:54 -04:00
8011649abc fix all the o1-o4 models
modified:   app.py
2025-06-01 23:28:05 -04:00
Russell Ballestrini
9bfd1c9b5a dynamic models for all the platforms!
modified:   .gitignore
	modified:   README.rst
	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
	new file:   vars.sh.sample
2025-03-11 21:15:13 -04:00
00eba1b150 gemini is actually tested and working
modified:   app.py
	new file:   models.py
2025-02-23 17:11:00 -05:00
2cd434c291
Update app.py 2025-02-16 15:56:32 -05:00
44170459fe dynamically register models to endpoints
modified:   app.py
2025-02-10 16:46:02 -05:00
381588d6bc mistral upgrades
modified:   README.rst
	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2025-02-08 16:03:22 -05:00
0250bf77b1
mistral ai upgrades 2025-02-08 15:48:23 -05:00
748649d98a o3-mini and hermes 8b 8fp!
modified:   README.rst
	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2025-02-01 15:58:01 -05:00
0492d5b329 r1 llm support:
modified:   README.rst
	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2025-01-25 14:37:26 -05:00
06d5167628 make port configurable for demo2.opencompletion.com 2025-01-25 07:46:11 -05:00
2e7fd18ba1 more openai models
modified:   README.rst
	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-12-31 12:18:03 -05:00
91d6192192 bunch more models.
modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-12-09 18:25:37 -05:00
b01311a825 inactive uesrs now collected.
modified:   app.py
	new file:   migrations/versions/5d93cdf18549_room_inactive_users_column.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-11-24 14:16:25 -05:00
96c10fc6d6 announce when a username leaves the room.
modified:   app.py
	modified:   templates/chat.html
2024-11-24 13:32:08 -05:00
5fa37da991 sort active users, validate models and voices, fix room links
modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-11-23 12:04:48 -05:00
0f82305087 feature complete. "sorry for the convenience"
modified:   app.py
	new file:   migrations/versions/1ac5a8e0f577_user_session_table.py
2024-11-23 11:32:49 -05:00
fab40ba60d w00t! active user list working, now we need disconnect to remove logic.
modified:   app.py
	modified:   templates/chat.html
2024-11-23 10:31:38 -05:00
f9f7da6ffc incremental progress
modified:   app.py
	modified:   templates/chat.html
2024-11-23 09:39:39 -05:00
3b3714f527 Fix defect with TTS after stream.
modified:   app.py
	modified:   templates/chat.html
2024-11-23 08:34:23 -05:00
Russell Ballestrini
185ebbcb59 ollama Hermes
ollama run hf.co/NousResearch/Hermes-3-Llama-3.1-8B-GGUF:Q8_0

	modified:   README.rst
	modified:   app.py
2024-11-22 14:15:44 -05:00
c8ffe15e66 fix all openai_client.chat calls to have n=1 for google api
modified:   app.py
2024-11-21 10:33:32 -05:00
b0aee48352 google gemini has entered the chat.
modified:   README.rst
	modified:   app.py
2024-11-21 10:16:46 -05:00
d316831a45 grok-beta
modified:   README.rst
	modified:   app.py
2024-11-21 08:57:29 -05:00
6d008a964f fixes for o1-mini but streaming is not supported...
modified:   app.py
2024-10-01 19:05:29 -04:00
75e637002b download markdown of conversation useful for github or jira
modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-09-18 16:27:40 -04:00
0fae1eb910 hooray for open source! new hermes 3 llama 3.1 tested
http://home.foxhop.net:5001/chat/hermes-3-llama-3.1-chain-of-thought?username=changeme
2024-09-15 17:54:56 -04:00
6086d65f9b uses the openai syntax for the conversation dump including content & role
* user
* system

	modified:   app.py
	modified:   templates/base.html
	modified:   templates/chat.html
2024-09-15 08:57:34 -04:00
Russell Ballestrini
e310217166 gpt-o1-mini and mistral-nemo
You'll have to do `pip install --upgrade -r requirements.txt` to install latest:

* mistralai client
* openai client

	modified:   app.py
2024-09-13 09:04:35 -04:00