Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app/agents/analyzer.py +0 -8
- app/agents/generator.py +9 -0
- app/agents/refactor.py +19 -0
- app/agents/reviewer.py +25 -0
app/agents/analyzer.py
CHANGED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
from app.services.llm_service import call_gpt
|
| 2 |
-
|
| 3 |
-
def analyzer_node(state):
|
| 4 |
-
response = call_gpt(
|
| 5 |
-
"You are a software architect. Return structured JSON.",
|
| 6 |
-
state["prompt"]
|
| 7 |
-
)
|
| 8 |
-
return {"structured_prompt": response}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/agents/generator.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.services.llm_service import call_gpt
|
| 2 |
+
|
| 3 |
+
def generator_node(state):
|
| 4 |
+
response = call_gpt(
|
| 5 |
+
"Generate production-ready code.",
|
| 6 |
+
state["structured_prompt"],
|
| 7 |
+
temperature=0.2
|
| 8 |
+
)
|
| 9 |
+
return {"code": response}
|
app/agents/refactor.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.services.llm_service import call_gpt
|
| 2 |
+
|
| 3 |
+
def refactor_node(state):
|
| 4 |
+
response = call_gpt(
|
| 5 |
+
"Fix and improve code based on review.",
|
| 6 |
+
f"""
|
| 7 |
+
Code:
|
| 8 |
+
{state['code']}
|
| 9 |
+
|
| 10 |
+
Review:
|
| 11 |
+
{state['review']}
|
| 12 |
+
""",
|
| 13 |
+
temperature=0.2
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
return {
|
| 17 |
+
"code": response,
|
| 18 |
+
"iteration": state["iteration"] + 1
|
| 19 |
+
}
|
app/agents/reviewer.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from app.services.llm_service import call_gpt
|
| 2 |
+
from app.services.code_tools import run_pylint, run_bandit
|
| 3 |
+
|
| 4 |
+
def reviewer_node(state):
|
| 5 |
+
code = state["code"]
|
| 6 |
+
|
| 7 |
+
pylint_report = run_pylint(code)
|
| 8 |
+
bandit_report = run_bandit(code)
|
| 9 |
+
|
| 10 |
+
response = call_gpt(
|
| 11 |
+
"Review code with lint + security insights. Return JSON.",
|
| 12 |
+
f"""
|
| 13 |
+
Code:
|
| 14 |
+
{code}
|
| 15 |
+
|
| 16 |
+
Pylint:
|
| 17 |
+
{pylint_report}
|
| 18 |
+
|
| 19 |
+
Bandit:
|
| 20 |
+
{bandit_report}
|
| 21 |
+
""",
|
| 22 |
+
temperature=0
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
return {"review": response}
|