mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
## Problem The JS/TS language handler (`core/languages/js_ts/`) was importing models, schemas, config, prompts, and helpers directly from the Python language handler. This created a confusing architectural dependency and risked serving wrong language-specific prompt content. ## What Changed - Created `core/shared/` for genuinely language-agnostic code (optimizer schemas, models, config, testgen models, context helpers) - Moved JS/TS-specific prompts and context helpers into `core/languages/js_ts/` - Updated all consumers (20+ files) to import from the correct locations - Removed backwards-compat re-exports from the Python module ## Result - **Before:** 11 imports from `core.languages.python` in `core/languages/js_ts/` - **After:** 0
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Shared optimizer models used across language handlers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import enum
|
|
|
|
from ninja import Schema
|
|
|
|
|
|
class OptimizedCandidateSource(str, enum.Enum):
|
|
OPTIMIZE = "OPTIMIZE"
|
|
OPTIMIZE_LP = "OPTIMIZE_LP"
|
|
REFINE = "REFINE"
|
|
REPAIR = "REPAIR"
|
|
ADAPTIVE = "ADAPTIVE"
|
|
JIT_REWRITE = "JIT_REWRITE"
|
|
|
|
|
|
class OptimizeSchema(Schema):
|
|
source_code: str
|
|
dependency_code: str | None
|
|
trace_id: str
|
|
python_version: str | None = None # Made optional for multi-language support
|
|
language: str = "python" # NEW: language identifier (python, javascript, typescript)
|
|
language_version: str | None = None # NEW: e.g., "ES2022", "Node 20", or Python version
|
|
experiment_metadata: dict[str, str] | None = None
|
|
codeflash_version: str | None = None
|
|
current_username: str | None = None
|
|
repo_owner: str | None = None
|
|
repo_name: str | None = None
|
|
is_async: bool | None = False
|
|
model: str | None = None # Deprecated: multi-model is now handled by get_model_distribution
|
|
call_sequence: int | None = None # Deprecated: call_sequence is now auto-assigned
|
|
n_candidates: int = 5 # default value for backward compatibility
|
|
is_numerical_code: bool | None = None
|
|
|
|
|
|
class OptimizeSchemaLP(Schema):
|
|
source_code: str
|
|
dependency_code: str | None
|
|
line_profiler_results: str | None
|
|
trace_id: str
|
|
python_version: str | None = None # Made optional for multi-language support
|
|
language: str = "python" # NEW: language identifier (python, javascript, typescript)
|
|
language_version: str | None = None # NEW: e.g., "ES2022", "Node 20", or Python version
|
|
experiment_metadata: dict[str, str] | None = None
|
|
codeflash_version: str | None = None
|
|
n_candidates: int = 6 # default value for backward compatibility
|
|
model: str | None = None
|
|
call_sequence: int | None = None
|
|
is_numerical_code: bool | None = None
|