Update app.py
Browse files
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
|
38 |
-
1. Extract and
|
39 |
-
2.
|
40 |
-
3.
|
41 |
-
|
|
|
|
|
|
|
|
|
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.
|
46 |
-
1.
|
47 |
-
2.
|
48 |
-
3.
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = []
|