Update app.py
Browse files
app.py
CHANGED
@@ -35,15 +35,11 @@ def load_models():
|
|
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.
|
39 |
-
2.
|
40 |
-
3.
|
41 |
-
|
42 |
-
|
43 |
-
- Provide descriptions ONLY for code-specific content.
|
44 |
-
- If multiple code snippets are visible in different frames, describe each separately.
|
45 |
-
- Do not mention or describe any user interface elements, buttons, or non-code visuals.
|
46 |
-
Your analysis will be used to understand and potentially fix the code, so maintain a high level of detail and accuracy in your descriptions of code-related content only.
|
47 |
"""
|
48 |
|
49 |
CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. Based on the description of code and errors provided, your task is to:
|
@@ -51,7 +47,6 @@ CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. Based on the
|
|
51 |
2. Provide a corrected version of the code
|
52 |
3. Explain the fixes made and why they resolve the issues
|
53 |
Be thorough in your explanation and ensure the corrected code is complete and functional.
|
54 |
-
Focus solely on the code and its issues, ignoring any mentions of user interfaces or non-code elements.
|
55 |
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.
|
56 |
"""
|
57 |
|
@@ -144,18 +139,11 @@ def process_video_for_code(video_path, max_frames=16, frame_interval=30):
|
|
144 |
|
145 |
cap.release()
|
146 |
|
147 |
-
# Process
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
vision_outputs.append(vision_output)
|
153 |
-
|
154 |
-
# Combine vision outputs and process with code model
|
155 |
-
combined_vision_output = "\n\n".join(vision_outputs)
|
156 |
-
_, code_output = process_image_for_code(combined_vision_output)
|
157 |
-
|
158 |
-
return combined_vision_output, code_output
|
159 |
|
160 |
@spaces.GPU
|
161 |
def process_content(content):
|
|
|
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, irrelevent frames may be occur (eg. 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:
|
|
|
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 |
|
|
|
139 |
|
140 |
cap.release()
|
141 |
|
142 |
+
# Process the first frame for now (you could extend this to handle multiple frames)
|
143 |
+
if frames:
|
144 |
+
return process_image_for_code(frames[0])
|
145 |
+
else:
|
146 |
+
return "No frames could be extracted from the video.", "No code could be analyzed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
@spaces.GPU
|
149 |
def process_content(content):
|