bpHigh commited on
Commit
f063810
Β·
1 Parent(s): dc3aaaa

comment certain stuff

Browse files
Files changed (1) hide show
  1. app.py +42 -42
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
- 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():
 
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():