comment certain stuff
Browse files
app.py
CHANGED
|
@@ -302,50 +302,50 @@ def generate_code_with_devstral(plan_text, history, file_cache):
|
|
| 302 |
if not plan_text or not plan_text.strip():
|
| 303 |
return "β Please generate a plan first before generating code."
|
| 304 |
|
| 305 |
-
try:
|
| 306 |
# Extract user query from conversation history
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
|
| 348 |
-
|
| 349 |
|
| 350 |
# # Call Modal inference using the proper app.run() context
|
| 351 |
# with devstral_app.run():
|
|
|
|
| 302 |
if not plan_text or not plan_text.strip():
|
| 303 |
return "β Please generate a plan first before generating code."
|
| 304 |
|
| 305 |
+
# try:
|
| 306 |
# Extract user query from conversation history
|
| 307 |
+
user_query = ""
|
| 308 |
+
if history:
|
| 309 |
+
# Get the latest user message as the main query
|
| 310 |
+
for user_msg, ai_msg in reversed(history):
|
| 311 |
+
if user_msg and user_msg.strip():
|
| 312 |
+
user_query = user_msg.strip()
|
| 313 |
+
break
|
| 314 |
+
|
| 315 |
+
if not user_query:
|
| 316 |
+
user_query = "Generate Python code based on the provided plan and context."
|
| 317 |
+
|
| 318 |
+
# Build context from file cache and conversation
|
| 319 |
+
context = ""
|
| 320 |
+
if file_cache:
|
| 321 |
+
context += "Available Data Files:\n"
|
| 322 |
+
for cache_key, file_info in file_cache.items():
|
| 323 |
+
context += f"- {file_info.get('file_name', 'Unknown file')}\n"
|
| 324 |
+
if 'stats' in file_info:
|
| 325 |
+
context += f" {file_info['stats']}\n"
|
| 326 |
+
|
| 327 |
+
# Add conversation context
|
| 328 |
+
if history:
|
| 329 |
+
context += "\nConversation Context:\n"
|
| 330 |
+
for user_msg, ai_msg in history[-3:]: # Last 3 exchanges
|
| 331 |
+
context += f"User: {user_msg}\n"
|
| 332 |
+
if ai_msg:
|
| 333 |
+
context += f"Assistant: {ai_msg}\n"
|
| 334 |
+
|
| 335 |
+
# Format the user prompt with variables
|
| 336 |
+
formatted_user_prompt = devstral_code_gen_user_prompt.format(
|
| 337 |
+
user_query=user_query,
|
| 338 |
+
plan=plan_text,
|
| 339 |
+
context=context
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
# Use Modal app.run() pattern like in the examples
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
print(f"π Generating code using Devstral...")
|
| 346 |
+
print(f"π‘ Connecting to: {base_url}")
|
| 347 |
|
| 348 |
+
return ""
|
| 349 |
|
| 350 |
# # Call Modal inference using the proper app.run() context
|
| 351 |
# with devstral_app.run():
|