Update app.py
Browse files
app.py
CHANGED
@@ -36,26 +36,29 @@ 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 |
|
39 |
-
1. Focus
|
40 |
-
2. Extract
|
41 |
3. Identify any error messages, warnings, or highlighting that indicates bugs within the code.
|
42 |
|
43 |
Important:
|
44 |
-
-
|
45 |
-
- Provide
|
46 |
- If multiple code snippets are visible in different frames, describe each separately.
|
|
|
47 |
|
48 |
-
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.
|
49 |
"""
|
50 |
|
51 |
CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. Based on the description of code and errors provided, your task is to:
|
|
|
52 |
1. Identify the bugs and issues in the code
|
53 |
2. Provide a corrected version of the code
|
54 |
3. Explain the fixes made and why they resolve the issues
|
|
|
55 |
Be thorough in your explanation and ensure the corrected code is complete and functional.
|
|
|
56 |
|
57 |
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.
|
58 |
-
|
59 |
"""
|
60 |
|
61 |
def process_image_for_code(image):
|
@@ -147,11 +150,18 @@ def process_video_for_code(video_path, max_frames=16, frame_interval=30):
|
|
147 |
|
148 |
cap.release()
|
149 |
|
150 |
-
# Process
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
@spaces.GPU
|
157 |
def process_content(content):
|
|
|
36 |
|
37 |
VISION_SYSTEM_PROMPT = """You are an AI assistant specialized in analyzing images and videos of code editors. Your task is to:
|
38 |
|
39 |
+
1. Focus EXCLUSIVELY on frames containing code snippets or development environments.
|
40 |
+
2. Extract and describe ONLY the visible code snippets, completely ignoring any non-code content.
|
41 |
3. Identify any error messages, warnings, or highlighting that indicates bugs within the code.
|
42 |
|
43 |
Important:
|
44 |
+
- Completely disregard any frames showing the Eterniq dashboard, other window tabs, or non-code related screens.
|
45 |
+
- Provide descriptions ONLY for code-specific content.
|
46 |
- If multiple code snippets are visible in different frames, describe each separately.
|
47 |
+
- Do not mention or describe any user interface elements, buttons, or non-code visuals.
|
48 |
|
49 |
+
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.
|
50 |
"""
|
51 |
|
52 |
CODE_SYSTEM_PROMPT = """You are an expert code debugging assistant. Based on the description of code and errors provided, your task is to:
|
53 |
+
|
54 |
1. Identify the bugs and issues in the code
|
55 |
2. Provide a corrected version of the code
|
56 |
3. Explain the fixes made and why they resolve the issues
|
57 |
+
|
58 |
Be thorough in your explanation and ensure the corrected code is complete and functional.
|
59 |
+
Focus solely on the code and its issues, ignoring any mentions of user interfaces or non-code elements.
|
60 |
|
61 |
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.
|
|
|
62 |
"""
|
63 |
|
64 |
def process_image_for_code(image):
|
|
|
150 |
|
151 |
cap.release()
|
152 |
|
153 |
+
# Process all extracted frames
|
154 |
+
vision_outputs = []
|
155 |
+
for frame in frames:
|
156 |
+
vision_output, _ = process_image_for_code(frame)
|
157 |
+
if vision_output.strip() and "no code" not in vision_output.lower():
|
158 |
+
vision_outputs.append(vision_output)
|
159 |
+
|
160 |
+
# Combine vision outputs and process with code model
|
161 |
+
combined_vision_output = "\n\n".join(vision_outputs)
|
162 |
+
_, code_output = process_image_for_code(combined_vision_output)
|
163 |
+
|
164 |
+
return combined_vision_output, code_output
|
165 |
|
166 |
@spaces.GPU
|
167 |
def process_content(content):
|