Spaces:
Build error
Build error
File size: 1,198 Bytes
8c85c78 3eb6edd 8c85c78 3eb6edd 8c85c78 94c52e3 3eb6edd 94c52e3 3eb6edd 8c85c78 3eb6edd 94c52e3 8c85c78 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | from .parse import parse_csharp
from .mapper import load_mapping
from .synth import synthesize_cpp, synthesize_blueprint_python
from .llm_client import generate_with_hf, generate_with_openai
class TranslationAgent:
def __init__(self, mapping_path="mapping_table.json"):
self.mapping = load_mapping(mapping_path)
def translate(self, csharp_code: str, target_format="both", model_choice="hf"):
"""
Convert Unity C# code into Unreal C++ and/or Blueprint Python.
Args:
csharp_code: Unity source
target_format: "cpp", "blueprint", or "both"
model_choice: "hf" or "openai"
"""
parsed = parse_csharp(csharp_code)
results = {"cpp": "", "blueprint_py": ""}
# choose model backend
backend = "hf" if model_choice == "hf" else "openai"
if target_format in ("cpp", "both"):
results["cpp"] = synthesize_cpp(parsed, self.mapping, model_backend=backend)
if target_format in ("blueprint", "both"):
results["blueprint_py"] = synthesize_blueprint_python(parsed, self.mapping, model_backend=backend)
return results["cpp"], results["blueprint_py"]
|