from .llm_client import generate_with_hf, generate_with_openai def synthesize_cpp(parsed: dict, mapping: dict, prompt_context: str = "", model_backend="hf") -> str: """ Converts Unity C# parsed structure into Unreal Engine C++ (header + source). Always returns code with clear file markers: ---FILE: ClassName.h--- ---FILE: ClassName.cpp--- """ class_name = parsed.get("classes", [{}])[0].get("name", "MyActor") prompt = f""" You are an expert Unreal Engine C++ developer. Translate the following Unity C# class into idiomatic Unreal C++. ✅ Follow these rules: - Create TWO files with exact markers: ---FILE: {class_name}.h--- (Header file) ---FILE: {class_name}.cpp--- (Implementation file) - Use Unreal macros like UCLASS(), UPROPERTY(), and UFUNCTION() appropriately. - Include necessary Unreal headers. - Ensure code compiles cleanly. - Use PascalCase for class and method names. - Avoid Unity-specific APIs; map them via given rules. Mapping rules: {mapping} Parsed structure: {parsed} {prompt_context} """ if model_backend == "openai": return generate_with_openai(prompt, model="gpt-4o-mini") else: return generate_with_hf(prompt, model="mistralai/Mistral-7B-Instruct-v0.3") def synthesize_blueprint_python(parsed: dict, mapping: dict, model_backend="hf") -> str: """ Generates Unreal Python Editor script that creates a Blueprint equivalent of the Unity class (BP_). """ class_name = parsed.get("classes", [{}])[0].get("name", "MyActor") prompt = f""" You are an Unreal Engine Python scripting expert. Convert the given Unity C# class into an Unreal Python Editor script that generates a Blueprint Actor named BP_{class_name}. Requirements: - Use Unreal Python API (unreal module). - Create Blueprint under /Game/Blueprints/BP_{class_name}. - Add StaticMeshComponent as root. - Add float property 'RotationSpeed' exposed to Blueprint. - Implement a Tick method to rotate actor: RotationSpeed * DeltaTime. - Include import statements and comments for clarity. - Output only the full Python script (no explanations). Parsed structure: {parsed} Mapping rules: {mapping} """ if model_backend == "openai": return generate_with_openai(prompt, model="gpt-4o-mini") else: return generate_with_hf(prompt, model="mistralai/Mistral-7B-Instruct-v0.3")