Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -152,15 +152,16 @@ elif page == "Code Workflows":
|
|
152 |
else:
|
153 |
with st.spinner("Running AI Workflow..."):
|
154 |
lang_instruction = f" Respond in {explanation_language}." if explanation_language != "English" else ""
|
|
|
155 |
steps = [
|
156 |
("Explain", call_groq_api(get_explanation_prompt(code_input, programming_language, skill_level, user_role, explanation_language))),
|
157 |
("Refactor", call_blackbox_agent([
|
158 |
{"role": "system", "content": "You are a helpful coding assistant."},
|
159 |
-
{"role": "user", "content": f"Refactor this {programming_language} code: {code_input}{lang_instruction}"}
|
160 |
])),
|
161 |
-
("Review", call_groq_api(f"Review this {programming_language} code for errors and improvements: {code_input}")),
|
162 |
-
("ErrorDetection", call_groq_api(f"Find bugs in this {programming_language} code: {code_input}")),
|
163 |
-
("TestGeneration", call_groq_api(f"Generate tests for this {programming_language} code: {code_input}")),
|
164 |
]
|
165 |
timeline = []
|
166 |
for step, output in steps:
|
@@ -279,10 +280,10 @@ elif page == "Code Comment Generator":
|
|
279 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
280 |
else:
|
281 |
with st.spinner("Generating commented code..."):
|
|
|
|
|
282 |
prompt = (
|
283 |
-
f"Add clear, helpful comments to this {programming_language} code.
|
284 |
-
"Keep the code unchanged except for adding comments. "
|
285 |
-
"Return the full code with comments:\n\n"
|
286 |
f"{code_input}"
|
287 |
)
|
288 |
commented_code = call_blackbox_agent([
|
@@ -297,7 +298,10 @@ elif page == "Code Comment Generator":
|
|
297 |
"timestamp": str(datetime.datetime.now()),
|
298 |
"user_code": code_input,
|
299 |
"params": {
|
300 |
-
"language": programming_language
|
|
|
|
|
|
|
301 |
},
|
302 |
"commented_code": commented_code
|
303 |
})
|
|
|
152 |
else:
|
153 |
with st.spinner("Running AI Workflow..."):
|
154 |
lang_instruction = f" Respond in {explanation_language}." if explanation_language != "English" else ""
|
155 |
+
role_level_instruction = f" The user is a {skill_level} {user_role}."
|
156 |
steps = [
|
157 |
("Explain", call_groq_api(get_explanation_prompt(code_input, programming_language, skill_level, user_role, explanation_language))),
|
158 |
("Refactor", call_blackbox_agent([
|
159 |
{"role": "system", "content": "You are a helpful coding assistant."},
|
160 |
+
{"role": "user", "content": f"Refactor this {programming_language} code for a {skill_level} {user_role}: {code_input}{lang_instruction}"}
|
161 |
])),
|
162 |
+
("Review", call_groq_api(f"Review this {programming_language} code for errors and improvements for a {skill_level} {user_role}: {code_input}{lang_instruction}")),
|
163 |
+
("ErrorDetection", call_groq_api(f"Find bugs in this {programming_language} code for a {skill_level} {user_role}: {code_input}{lang_instruction}")),
|
164 |
+
("TestGeneration", call_groq_api(f"Generate tests for this {programming_language} code for a {skill_level} {user_role}: {code_input}{lang_instruction}")),
|
165 |
]
|
166 |
timeline = []
|
167 |
for step, output in steps:
|
|
|
280 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
281 |
else:
|
282 |
with st.spinner("Generating commented code..."):
|
283 |
+
lang_instruction = f" Respond in {explanation_language}." if explanation_language != "English" else ""
|
284 |
+
role_level_instruction = f" The user is a {skill_level} {user_role}."
|
285 |
prompt = (
|
286 |
+
f"Add clear, helpful comments to this {programming_language} code for a {skill_level} {user_role}.{lang_instruction}\n\n"
|
|
|
|
|
287 |
f"{code_input}"
|
288 |
)
|
289 |
commented_code = call_blackbox_agent([
|
|
|
298 |
"timestamp": str(datetime.datetime.now()),
|
299 |
"user_code": code_input,
|
300 |
"params": {
|
301 |
+
"language": programming_language,
|
302 |
+
"skill": skill_level,
|
303 |
+
"role": user_role,
|
304 |
+
"explanation_language": explanation_language
|
305 |
},
|
306 |
"commented_code": commented_code
|
307 |
})
|