ramyaa1113 commited on
Commit
40789e9
·
1 Parent(s): 4705a6e

translate updated

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -16,9 +16,19 @@ def do_translate(csharp_code, target_format, model_choice):
16
  class_name = extract_class_name(csharp_code)
17
  outputs = agent.translate(csharp_code, target_format=target_format, model_choice=model_choice)
18
 
19
- cpp_code = outputs.get("cpp_code", "")
20
- header_code = outputs.get("header_code", "")
21
- blueprint_code = outputs.get("blueprint_code", "")
 
 
 
 
 
 
 
 
 
 
22
 
23
  # Save files with class name
24
  header_path = f"{class_name}.h"
@@ -32,6 +42,7 @@ def do_translate(csharp_code, target_format, model_choice):
32
  return header_code, cpp_code, blueprint_code, header_path, cpp_path
33
 
34
 
 
35
  title = "Unity → Unreal Code Translator"
36
  description = """
37
  ### 🧩 Unity → Unreal Translator
 
16
  class_name = extract_class_name(csharp_code)
17
  outputs = agent.translate(csharp_code, target_format=target_format, model_choice=model_choice)
18
 
19
+ # Handle if the agent returns tuple instead of dict
20
+ if isinstance(outputs, tuple):
21
+ # Assuming structure like (header_code, cpp_code, blueprint_code)
22
+ if len(outputs) == 3:
23
+ header_code, cpp_code, blueprint_code = outputs
24
+ else:
25
+ header_code, cpp_code, blueprint_code = outputs[0], "", ""
26
+ elif isinstance(outputs, dict):
27
+ cpp_code = outputs.get("cpp_code", "")
28
+ header_code = outputs.get("header_code", "")
29
+ blueprint_code = outputs.get("blueprint_code", "")
30
+ else:
31
+ header_code = cpp_code = blueprint_code = ""
32
 
33
  # Save files with class name
34
  header_path = f"{class_name}.h"
 
42
  return header_code, cpp_code, blueprint_code, header_path, cpp_path
43
 
44
 
45
+
46
  title = "Unity → Unreal Code Translator"
47
  description = """
48
  ### 🧩 Unity → Unreal Translator