AIencoder commited on
Commit
5a61b94
·
verified ·
1 Parent(s): 9cb16d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -36
app.py CHANGED
@@ -87,15 +87,15 @@ def generate_code(prompt, language, model_name, temperature, max_tokens):
87
  return "⚠️ Please describe what you want to build."
88
 
89
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
90
- full_prompt = f"""Write {language} code for the following task:
91
-
92
- {prompt}
93
-
94
- Requirements:
95
- - Clean, production-ready code
96
- - Add helpful comments
97
- - Handle edge cases
98
- - Output ONLY the code in a markdown code block"""
99
 
100
  try:
101
  r = requests.post(
@@ -129,8 +129,7 @@ def explain_code(code, model_name, detail_level, max_tokens):
129
  "Detailed": "Give a detailed explanation including: purpose, how it works step-by-step, time/space complexity, and potential improvements."
130
  }
131
 
132
- prompt = f"""{detail_prompts[detail_level]}
133
- {code}
134
 
135
  try:
136
  r = requests.post(
@@ -147,19 +146,16 @@ def fix_code(code, error, model_name, max_tokens):
147
  return "⚠️ Paste code to fix."
148
 
149
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
150
- prompt = f"""Fix the following code and explain what was wrong.
151
-
152
- Code:
153
- ```
154
- {code}
155
- ```
156
-
157
- Error/Problem: {error or 'Code is not working as expected'}
158
-
159
- Provide:
160
- 1. The fixed code
161
- 2. Brief explanation of what was wrong
162
- 3. Any suggestions to prevent similar issues"""
163
 
164
  try:
165
  r = requests.post(
@@ -176,14 +172,15 @@ def review_code(code, model_name, max_tokens):
176
  return "⚠️ Paste code to review."
177
 
178
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
179
- prompt = f"""Review this code and provide feedback on:
180
-
181
- 1. **Code Quality** - Is it clean, readable, well-structured?
182
- 2. **Bugs/Issues** - Any potential bugs or problems?
183
- 3. **Performance** - Any performance concerns?
184
- 4. **Security** - Any security issues?
185
- 5. **Suggestions** - How could it be improved?
186
- {code}
 
187
 
188
  try:
189
  r = requests.post(
@@ -202,10 +199,7 @@ footer { display: none !important; }
202
 
203
  with gr.Blocks(title="Axon v6", css=css, theme=gr.themes.Soft(primary_hue="violet", secondary_hue="blue")) as demo:
204
 
205
- gr.Markdown("""
206
- # 🔥 Axon v6
207
- ### AI Coding Assistant • 10 Models • 100% Local • No Rate Limits
208
- """)
209
 
210
  status = gr.Markdown(value=get_status, every=5)
211
 
 
87
  return "⚠️ Please describe what you want to build."
88
 
89
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
90
+ full_prompt = (
91
+ f"Write {language} code for the following task:\n\n"
92
+ f"{prompt}\n\n"
93
+ "Requirements:\n"
94
+ "- Clean, production-ready code\n"
95
+ "- Add helpful comments\n"
96
+ "- Handle edge cases\n"
97
+ "- Output ONLY the code in a markdown code block"
98
+ )
99
 
100
  try:
101
  r = requests.post(
 
129
  "Detailed": "Give a detailed explanation including: purpose, how it works step-by-step, time/space complexity, and potential improvements."
130
  }
131
 
132
+ prompt = detail_prompts[detail_level] + "\n\n" + code
 
133
 
134
  try:
135
  r = requests.post(
 
146
  return "⚠️ Paste code to fix."
147
 
148
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
149
+ error_msg = error if error else "Code is not working as expected"
150
+ prompt = (
151
+ "Fix the following code and explain what was wrong.\n\n"
152
+ "Code:\n" + code + "\n\n"
153
+ "Error/Problem: " + error_msg + "\n\n"
154
+ "Provide:\n"
155
+ "1. The fixed code\n"
156
+ "2. Brief explanation of what was wrong\n"
157
+ "3. Any suggestions to prevent similar issues"
158
+ )
 
 
 
159
 
160
  try:
161
  r = requests.post(
 
172
  return "⚠️ Paste code to review."
173
 
174
  model = MODELS.get(model_name, "qwen2.5-coder:3b")
175
+ prompt = (
176
+ "Review this code and provide feedback on:\n\n"
177
+ "1. **Code Quality** - Is it clean, readable, well-structured?\n"
178
+ "2. **Bugs/Issues** - Any potential bugs or problems?\n"
179
+ "3. **Performance** - Any performance concerns?\n"
180
+ "4. **Security** - Any security issues?\n"
181
+ "5. **Suggestions** - How could it be improved?\n\n"
182
+ "Code:\n" + code
183
+ )
184
 
185
  try:
186
  r = requests.post(
 
199
 
200
  with gr.Blocks(title="Axon v6", css=css, theme=gr.themes.Soft(primary_hue="violet", secondary_hue="blue")) as demo:
201
 
202
+ gr.Markdown("# 🔥 Axon v6\n### AI Coding Assistant • 10 Models • 100% Local • No Rate Limits")
 
 
 
203
 
204
  status = gr.Markdown(value=get_status, every=5)
205