Spaces:
Runtime error
Runtime error
jess commited on
Commit ·
accbe57
1
Parent(s): bd9069b
modify dynamic renderer to use append instead of extend, add print statements for debugging purposes, fixed reformating dev components
Browse files- Project.py +6 -2
- event_handler.py +18 -22
- prompt_configs.py +1 -1
Project.py
CHANGED
|
@@ -105,12 +105,12 @@ class Project:
|
|
| 105 |
#Execute prompt with given input variables
|
| 106 |
def execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
|
| 107 |
"""Execute a prompt with given input variables"""
|
|
|
|
| 108 |
if prompt_name not in PROMPTS:
|
| 109 |
raise ValueError(f"Unknown prompt: {prompt_name}")
|
| 110 |
|
| 111 |
config = PROMPTS[prompt_name]
|
| 112 |
-
input_variables = input_variables or {}
|
| 113 |
-
|
| 114 |
# Auto-fill inputs from project attributes using INPUT_MAPPINGS
|
| 115 |
for input_name in config.inputs:
|
| 116 |
if input_name not in input_variables:
|
|
@@ -118,6 +118,7 @@ class Project:
|
|
| 118 |
raise ValueError(f"No mapping defined for required input: {input_name}")
|
| 119 |
try:
|
| 120 |
input_variables[input_name] = self.INPUT_MAPPINGS[input_name](self)
|
|
|
|
| 121 |
except Exception as e:
|
| 122 |
raise ValueError(f"Failed to get value for input {input_name}: {str(e)}")
|
| 123 |
|
|
@@ -143,6 +144,7 @@ class Project:
|
|
| 143 |
|
| 144 |
{formatted_inputs}
|
| 145 |
"""
|
|
|
|
| 146 |
|
| 147 |
# Execute prompt with appropriate model
|
| 148 |
result = (
|
|
@@ -150,11 +152,13 @@ class Project:
|
|
| 150 |
if config.model == ModelType.GPT_4O_MINI
|
| 151 |
else call_o1_mini(prompt)
|
| 152 |
)
|
|
|
|
| 153 |
|
| 154 |
# Store outputs in project attributes
|
| 155 |
for output in config.outputs:
|
| 156 |
if hasattr(self, output):
|
| 157 |
setattr(self, output, result)
|
|
|
|
| 158 |
|
| 159 |
return result
|
| 160 |
|
|
|
|
| 105 |
#Execute prompt with given input variables
|
| 106 |
def execute_prompt(self, prompt_name: str, input_variables: Dict[str, Any] = None) -> str:
|
| 107 |
"""Execute a prompt with given input variables"""
|
| 108 |
+
print(f"Attempting to execute prompt: {prompt_name}")
|
| 109 |
if prompt_name not in PROMPTS:
|
| 110 |
raise ValueError(f"Unknown prompt: {prompt_name}")
|
| 111 |
|
| 112 |
config = PROMPTS[prompt_name]
|
| 113 |
+
input_variables = input_variables or {}
|
|
|
|
| 114 |
# Auto-fill inputs from project attributes using INPUT_MAPPINGS
|
| 115 |
for input_name in config.inputs:
|
| 116 |
if input_name not in input_variables:
|
|
|
|
| 118 |
raise ValueError(f"No mapping defined for required input: {input_name}")
|
| 119 |
try:
|
| 120 |
input_variables[input_name] = self.INPUT_MAPPINGS[input_name](self)
|
| 121 |
+
# print(f"Auto-filled input {input_name} with value: {input_variables[input_name]}")
|
| 122 |
except Exception as e:
|
| 123 |
raise ValueError(f"Failed to get value for input {input_name}: {str(e)}")
|
| 124 |
|
|
|
|
| 144 |
|
| 145 |
{formatted_inputs}
|
| 146 |
"""
|
| 147 |
+
print(f"Final prompt to be executed: {prompt}")
|
| 148 |
|
| 149 |
# Execute prompt with appropriate model
|
| 150 |
result = (
|
|
|
|
| 152 |
if config.model == ModelType.GPT_4O_MINI
|
| 153 |
else call_o1_mini(prompt)
|
| 154 |
)
|
| 155 |
+
print(f"Result from executing prompt: {result[:800]}")
|
| 156 |
|
| 157 |
# Store outputs in project attributes
|
| 158 |
for output in config.outputs:
|
| 159 |
if hasattr(self, output):
|
| 160 |
setattr(self, output, result)
|
| 161 |
+
print(f"Stored output {output} with value: {result}")
|
| 162 |
|
| 163 |
return result
|
| 164 |
|
event_handler.py
CHANGED
|
@@ -68,28 +68,24 @@ def create_render_results(step, generation_results):
|
|
| 68 |
description = prompt_config.description if prompt_config else function_name
|
| 69 |
|
| 70 |
with gr.Accordion(f"{description}", open=False):
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
)
|
| 90 |
-
])
|
| 91 |
-
])
|
| 92 |
-
|
| 93 |
# Return the list of components directly
|
| 94 |
return result_components
|
| 95 |
|
|
|
|
| 68 |
description = prompt_config.description if prompt_config else function_name
|
| 69 |
|
| 70 |
with gr.Accordion(f"{description}", open=False):
|
| 71 |
+
result_components.append(
|
| 72 |
+
gr.Row(
|
| 73 |
+
[
|
| 74 |
+
gr.Textbox(
|
| 75 |
+
value=result,
|
| 76 |
+
label="Text Output",
|
| 77 |
+
lines=20,
|
| 78 |
+
interactive=True
|
| 79 |
+
),
|
| 80 |
+
gr.Markdown(
|
| 81 |
+
value=result,
|
| 82 |
+
show_copy_button=True,
|
| 83 |
+
elem_classes=["scrollable-markdown"]
|
| 84 |
+
),
|
| 85 |
+
]
|
| 86 |
+
)
|
| 87 |
+
)
|
| 88 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
# Return the list of components directly
|
| 90 |
return result_components
|
| 91 |
|
prompt_configs.py
CHANGED
|
@@ -927,7 +927,7 @@ PROMPTS = {
|
|
| 927 |
A refined, logically structured, and optimized merged component list in tabular format.
|
| 928 |
|
| 929 |
""",
|
| 930 |
-
inputs=["generated_engage_dev_components,generated_page_dev_components"],
|
| 931 |
outputs=["reformatted_hybrid_dev_components"],
|
| 932 |
model=ModelType.O1_MINI,
|
| 933 |
description="Reformat Hybird Development Components",
|
|
|
|
| 927 |
A refined, logically structured, and optimized merged component list in tabular format.
|
| 928 |
|
| 929 |
""",
|
| 930 |
+
inputs=["generated_engage_dev_components","generated_page_dev_components"],
|
| 931 |
outputs=["reformatted_hybrid_dev_components"],
|
| 932 |
model=ModelType.O1_MINI,
|
| 933 |
description="Reformat Hybird Development Components",
|