[Forge] Image generation service with MiniMax + GLM providers

← All Specs

[Forge] Image generation service with MiniMax + GLM providers

ID: d8fbc165-807 Priority: 80 Type: one_shot Status: done

Goal

Build image_generator.py: provider abstraction over MiniMax image-01 (primary, free subscription) and GLM CogView-4 (fallback). Core generate_image() function saves to site/figures/, registers as artifact. Error handling with automatic fallback. CLI interface for testing.

Acceptance Criteria

☑ Concrete deliverables created
☑ Work log updated with timestamped entry

Work Log

  • 2026-04-20 12:50:00Z — Verified: implementation already on origin/main at scidex/forge/image_generator.py (blob c9cc7b06). Contains:
- MiniMax image-01 provider (_minimax_generate()) as primary (free subscription)
- GLM CogView-4 provider (_glm_generate()) as fallback
- Core generate_image() saves to site/figures/, registers via register_artifact()
- Automatic fallback on provider failure
- CLI interface via if __name__ == "__main__" argparse
- Scientific image types: pathway_infographic, hypothesis_visual, protocol_illustration, debate_card, entity_portrait
- Quality evaluation via evaluate_image_quality()
- Batch operations via batch_generate_for_analysis() and batch_generate_entity_portraits()
- Evidence: git ls-tree origin/main:scidex/forge/ | grep image confirms file exists

2026-04-21 01:10 PT — Slot minimax:62

  • Issue found: image_generator.py on main uses SQLite patterns incompatible with PostgreSQL (sqlite3 import, row_factory, ? placeholders, PRAGMA journal_mode, kg_edges table name vs knowledge_edges, CURRENT_TIMESTAMP)
  • Fix applied (scidex/forge/image_generator.py):
- Replaced import sqlite3 + from scidex.core.database import get_db (top-level) with lazy imports inside each function using get_db()
- Removed db.row_factory = sqlite3.Row (not needed for dict(row) access in PostgreSQL)
- Changed ? placeholders to %s (PostgreSQL)
- Replaced CURRENT_TIMESTAMP with NOW()
- Renamed kg_edges table → knowledge_edges (correct SciDEX table name)
- Fixed _fetch_kg_edges: uses source_id, relation, target_id columns instead of old subject, predicate, object
- Fixed _fetch_hypothesis and _fetch_analysis to use %s placeholders
- Fixed evaluate_and_update_artifact: removed PRAGMA journal_mode = WAL
- Fixed import: from artifact_registry importfrom scidex.atlas.artifact_registry import
- Removed unused psycopg2.sql import
  • Tested: python3 tests/test_image_generator_prompts.py → 8/8 passed
  • Commit: [Forge] Fix image_generator.py PostgreSQL compatibility [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]
  • Result: Done — PostgreSQL compatibility fix applied, all tests pass

Tasks using this spec (1)
[Forge] Image generation service with MiniMax + GLM provider
File: d8fbc165_807_spec.md
Modified: 2026-04-25 23:40
Size: 2.7 KB