Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -95,9 +95,7 @@ def is_coding_question(question):
|
|
95 |
return False
|
96 |
|
97 |
def get_explanation_prompt(code, programming_language, skill_level, user_role, explanation_language, question=None):
|
98 |
-
lang_instruction = ""
|
99 |
-
if explanation_language != "English":
|
100 |
-
lang_instruction = f" Respond in {explanation_language}."
|
101 |
if question:
|
102 |
return f"{question}\n\nCode:\n{code}\n{lang_instruction}"
|
103 |
return (
|
@@ -153,11 +151,12 @@ elif page == "Code Workflows":
|
|
153 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
154 |
else:
|
155 |
with st.spinner("Running AI Workflow..."):
|
|
|
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: {code_input}"}
|
161 |
])),
|
162 |
("Review", call_groq_api(f"Review this {programming_language} code for errors and improvements: {code_input}")),
|
163 |
("ErrorDetection", call_groq_api(f"Find bugs in this {programming_language} code: {code_input}")),
|
|
|
95 |
return False
|
96 |
|
97 |
def get_explanation_prompt(code, programming_language, skill_level, user_role, explanation_language, question=None):
|
98 |
+
lang_instruction = f" Respond in {explanation_language}." if explanation_language != "English" else ""
|
|
|
|
|
99 |
if question:
|
100 |
return f"{question}\n\nCode:\n{code}\n{lang_instruction}"
|
101 |
return (
|
|
|
151 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
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}")),
|