Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ import requests
|
|
| 4 |
import datetime
|
| 5 |
|
| 6 |
# --- CONFIG ---
|
| 7 |
-
# Place your API keys here or use Streamlit secrets
|
| 8 |
GROQ_API_KEY = st.secrets.get('GROQ_API_KEY', 'YOUR_GROQ_API_KEY')
|
| 9 |
BLACKBOX_API_KEY = st.secrets.get('BLACKBOX_API_KEY', 'YOUR_BLACKBOX_API_KEY')
|
| 10 |
|
|
@@ -42,20 +41,17 @@ def call_blackbox_agent(prompt):
|
|
| 42 |
}
|
| 43 |
response = requests.post(url, headers=headers, json=data)
|
| 44 |
if response.status_code == 200:
|
| 45 |
-
# Adjust this if the response structure is different
|
| 46 |
return response.json().get("response", response.json())
|
| 47 |
else:
|
| 48 |
return f"[Blackbox.ai API Error] {response.status_code}: {response.text}"
|
| 49 |
|
| 50 |
# --- UTILS ---
|
| 51 |
def code_matches_language(code, language):
|
| 52 |
-
# Simple heuristic, can be improved
|
| 53 |
if language.lower() in code.lower():
|
| 54 |
return True
|
| 55 |
-
return True
|
| 56 |
|
| 57 |
def calculate_code_complexity(code):
|
| 58 |
-
# Dummy complexity metric
|
| 59 |
lines = code.count('\n') + 1
|
| 60 |
return f"{lines} lines"
|
| 61 |
|
|
@@ -71,7 +67,7 @@ def get_inline_diff(original, modified):
|
|
| 71 |
|
| 72 |
# --- STREAMLIT APP ---
|
| 73 |
st.set_page_config(page_title="AI Workflow App", layout="wide")
|
| 74 |
-
st.title("
|
| 75 |
|
| 76 |
# Navigation
|
| 77 |
page = st.sidebar.radio("Navigate", ["Home", "AI Workflow", "Semantic Search"])
|
|
@@ -109,7 +105,6 @@ elif page == "AI Workflow":
|
|
| 109 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
| 110 |
else:
|
| 111 |
with st.spinner("Running AI Workflow..."):
|
| 112 |
-
# Simulate workflow steps
|
| 113 |
steps = [
|
| 114 |
("Explain", call_groq_api(f"Explain this {programming_language} code for a {skill_level} {user_role} in {explanation_language}:\n{code_input}")),
|
| 115 |
("Refactor", call_blackbox_agent(f"Refactor this {programming_language} code: {code_input}")),
|
|
|
|
| 4 |
import datetime
|
| 5 |
|
| 6 |
# --- CONFIG ---
|
|
|
|
| 7 |
GROQ_API_KEY = st.secrets.get('GROQ_API_KEY', 'YOUR_GROQ_API_KEY')
|
| 8 |
BLACKBOX_API_KEY = st.secrets.get('BLACKBOX_API_KEY', 'YOUR_BLACKBOX_API_KEY')
|
| 9 |
|
|
|
|
| 41 |
}
|
| 42 |
response = requests.post(url, headers=headers, json=data)
|
| 43 |
if response.status_code == 200:
|
|
|
|
| 44 |
return response.json().get("response", response.json())
|
| 45 |
else:
|
| 46 |
return f"[Blackbox.ai API Error] {response.status_code}: {response.text}"
|
| 47 |
|
| 48 |
# --- UTILS ---
|
| 49 |
def code_matches_language(code, language):
|
|
|
|
| 50 |
if language.lower() in code.lower():
|
| 51 |
return True
|
| 52 |
+
return True
|
| 53 |
|
| 54 |
def calculate_code_complexity(code):
|
|
|
|
| 55 |
lines = code.count('\n') + 1
|
| 56 |
return f"{lines} lines"
|
| 57 |
|
|
|
|
| 67 |
|
| 68 |
# --- STREAMLIT APP ---
|
| 69 |
st.set_page_config(page_title="AI Workflow App", layout="wide")
|
| 70 |
+
st.title("CodeGenie")
|
| 71 |
|
| 72 |
# Navigation
|
| 73 |
page = st.sidebar.radio("Navigate", ["Home", "AI Workflow", "Semantic Search"])
|
|
|
|
| 105 |
st.error(f"Language mismatch. Please check your code and language selection.")
|
| 106 |
else:
|
| 107 |
with st.spinner("Running AI Workflow..."):
|
|
|
|
| 108 |
steps = [
|
| 109 |
("Explain", call_groq_api(f"Explain this {programming_language} code for a {skill_level} {user_role} in {explanation_language}:\n{code_input}")),
|
| 110 |
("Refactor", call_blackbox_agent(f"Refactor this {programming_language} code: {code_input}")),
|