whyumesh commited on
Commit
530524e
·
verified ·
1 Parent(s): a40894f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -34,22 +34,34 @@ def load_models():
34
 
35
  vision_model, vision_processor, code_model, code_tokenizer = load_models()
36
 
37
- VISION_SYSTEM_PROMPT = """You are an AI assistant specialized in analyzing images and videos of code editors. Your task is to:
38
- 1. Extract and describe any code snippets visible in the image
39
- 2. Identify any error messages, warnings, or highlighting that indicates bugs
40
- 3. Describe the programming language and context if visible.
41
- Be thorough and accurate in your description, as this will be used to fix the code.
 
 
 
 
42
  Note: In video, irrelevant frames may occur (e.g., other windows tabs, eterniq website, etc.) in video. Please focus on code-specific frames as we have to extract that content only.
43
  """
44
 
45
- CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. Based on the description of code and errors provided, your task is to:
46
- 1. Identify the bugs and issues in the code
47
- 2. Provide a corrected version of the code
48
- 3. Explain the fixes made and why they resolve the issues
49
- Be thorough in your explanation and ensure the corrected code is complete and functional.
 
 
 
 
 
 
 
 
 
50
  Note: Please provide the output in a well-structured Markdown format. Remove all unnecessary information and exclude any additional code formatting such as triple backticks or language identifiers. The response should be ready to be rendered as Markdown content.
51
  """
52
-
53
  def process_video_for_code(video_path, transcribed_text, max_frames=16, frame_interval=30):
54
  cap = cv2.VideoCapture(video_path)
55
  frames = []
 
34
 
35
  vision_model, vision_processor, code_model, code_tokenizer = load_models()
36
 
37
+ VISION_SYSTEM_PROMPT = """You are an OCR system specialized in extracting code from images and videos. Your task is to:
38
+ 1. Extract and output ONLY the exact code snippets visible in the image
39
+ 2. Maintain exact formatting, indentation, and whitespace
40
+ 3. Do not add any descriptions, analysis, or commentary
41
+ 4. If there are error messages or console outputs visible, include them exactly as shown
42
+ Output Format:
43
+ ```[language]
44
+ [extracted code here]
45
+ If multiple code sections are visible, separate them with ---
46
  Note: In video, irrelevant frames may occur (e.g., other windows tabs, eterniq website, etc.) in video. Please focus on code-specific frames as we have to extract that content only.
47
  """
48
 
49
+ CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. You will receive:
50
+ 1. Original code (extracted by OCR)
51
+ 2. User's description of the issue
52
+ 3. Additional context if any
53
+ Your task is to:
54
+ 1. Analyze the provided code considering the user's description
55
+ 2. Identify bugs and issues
56
+ 3. Provide a corrected version of the code
57
+ 4. Explain the specific fixes made
58
+ Output Format:
59
+ Fixed Code:
60
+ [corrected code here]
61
+ Original Code Issue:
62
+ [Brief description of the issues based on user input and code analysis]
63
  Note: Please provide the output in a well-structured Markdown format. Remove all unnecessary information and exclude any additional code formatting such as triple backticks or language identifiers. The response should be ready to be rendered as Markdown content.
64
  """
 
65
  def process_video_for_code(video_path, transcribed_text, max_frames=16, frame_interval=30):
66
  cap = cv2.VideoCapture(video_path)
67
  frames = []