AC2513 commited on
Commit
ce78f65
·
1 Parent(s): 80d03f7
Files changed (1) hide show
  1. utils.py +19 -32
utils.py CHANGED
@@ -12,6 +12,19 @@ MAX_VIDEO_SIZE = 100 * 1024 * 1024 # 100 MB
12
  MAX_IMAGE_SIZE = 10 * 1024 * 1024 # 10 MB
13
  MAX_AUDIO_SIZE = 50 * 1024 * 1024 # 50 MB
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  def check_file_size(file_path: str) -> bool:
17
  """Check if a file meets the size requirements."""
@@ -231,39 +244,13 @@ def process_history(history: list[dict]) -> list[dict]:
231
  return messages
232
 
233
 
234
- def update_custom_prompt(preset_choice):
235
  """Update the custom prompt based on preset selection."""
236
- preset_prompts = {
237
- "General Assistant": "You are a helpful AI assistant capable of analyzing images, videos, and PDF documents. Provide clear, accurate, and helpful responses to user queries.",
238
-
239
- "Document Analyzer": "You are a specialized document analysis assistant. Focus on extracting key information, summarizing content, and answering specific questions about uploaded documents. For PDFs, provide structured analysis including main topics, key points, and relevant details. For images containing text, perform OCR-like analysis.",
240
-
241
- "Visual Content Expert": "You are an expert in visual content analysis. When analyzing images, provide detailed descriptions of visual elements, composition, colors, objects, people, and scenes. For videos, describe the sequence of events, movements, and changes between frames. Identify artistic techniques, styles, and visual storytelling elements.",
242
-
243
- "Educational Tutor": "You are a patient and encouraging educational tutor. Break down complex concepts into simple, understandable explanations. When analyzing educational materials (images, videos, or documents), focus on learning objectives, key concepts, and provide additional context or examples to enhance understanding.",
244
-
245
- "Technical Reviewer": "You are a technical expert specializing in analyzing technical documents, diagrams, code screenshots, and instructional videos. Provide detailed technical insights, identify potential issues, suggest improvements, and explain technical concepts with precision and accuracy.",
246
-
247
- "Creative Storyteller": "You are a creative storyteller who brings visual content to life through engaging narratives. When analyzing images or videos, create compelling stories, describe scenes with rich detail, and help users explore the creative and emotional aspects of visual content.",
248
-
249
- "Custom Prompt": ""
250
- }
251
-
252
- return preset_prompts.get(preset_choice, "")
253
 
254
 
255
- def get_preset_prompts():
256
  """Return the dictionary of preset prompts for the main application."""
257
- return {
258
- "General Assistant": "You are a helpful AI assistant capable of analyzing images, videos, and PDF documents. Provide clear, accurate, and helpful responses to user queries.",
259
-
260
- "Document Analyzer": "You are a specialized document analysis assistant. Focus on extracting key information, summarizing content, and answering specific questions about uploaded documents. For PDFs, provide structured analysis including main topics, key points, and relevant details. For images containing text, perform OCR-like analysis.",
261
-
262
- "Visual Content Expert": "You are an expert in visual content analysis. When analyzing images, provide detailed descriptions of visual elements, composition, colors, objects, people, and scenes. For videos, describe the sequence of events, movements, and changes between frames. Identify artistic techniques, styles, and visual storytelling elements.",
263
-
264
- "Educational Tutor": "You are a patient and encouraging educational tutor. Break down complex concepts into simple, understandable explanations. When analyzing educational materials (images, videos, or documents), focus on learning objectives, key concepts, and provide additional context or examples to enhance understanding.",
265
-
266
- "Technical Reviewer": "You are a technical expert specializing in analyzing technical documents, diagrams, code screenshots, and instructional videos. Provide detailed technical insights, identify potential issues, suggest improvements, and explain technical concepts with precision and accuracy.",
267
-
268
- "Creative Storyteller": "You are a creative storyteller who brings visual content to life through engaging narratives. When analyzing images or videos, create compelling stories, describe scenes with rich detail, and help users explore the creative and emotional aspects of visual content.",
269
- }
 
12
  MAX_IMAGE_SIZE = 10 * 1024 * 1024 # 10 MB
13
  MAX_AUDIO_SIZE = 50 * 1024 * 1024 # 50 MB
14
 
15
+ PRESET_PROMPTS = {
16
+ "General Assistant": "You are a helpful AI assistant capable of analyzing images, videos, and PDF documents. Provide clear, accurate, and helpful responses to user queries.",
17
+
18
+ "Document Analyzer": "You are a specialized document analysis assistant. Focus on extracting key information, summarizing content, and answering specific questions about uploaded documents. For PDFs, provide structured analysis including main topics, key points, and relevant details. For images containing text, perform OCR-like analysis.",
19
+
20
+ "Visual Content Expert": "You are an expert in visual content analysis. When analyzing images, provide detailed descriptions of visual elements, composition, colors, objects, people, and scenes. For videos, describe the sequence of events, movements, and changes between frames. Identify artistic techniques, styles, and visual storytelling elements.",
21
+
22
+ "Educational Tutor": "You are a patient and encouraging educational tutor. Break down complex concepts into simple, understandable explanations. When analyzing educational materials (images, videos, or documents), focus on learning objectives, key concepts, and provide additional context or examples to enhance understanding.",
23
+
24
+ "Technical Reviewer": "You are a technical expert specializing in analyzing technical documents, diagrams, code screenshots, and instructional videos. Provide detailed technical insights, identify potential issues, suggest improvements, and explain technical concepts with precision and accuracy.",
25
+
26
+ "Creative Storyteller": "You are a creative storyteller who brings visual content to life through engaging narratives. When analyzing images or videos, create compelling stories, describe scenes with rich detail, and help users explore the creative and emotional aspects of visual content.",
27
+ }
28
 
29
  def check_file_size(file_path: str) -> bool:
30
  """Check if a file meets the size requirements."""
 
244
  return messages
245
 
246
 
247
+ def update_custom_prompt(preset_choice: str) -> str:
248
  """Update the custom prompt based on preset selection."""
249
+ if preset_choice == "Custom Prompt":
250
+ return ""
251
+ return PRESET_PROMPTS.get(preset_choice, "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
 
254
+ def get_preset_prompts() -> dict[str, str]:
255
  """Return the dictionary of preset prompts for the main application."""
256
+ return PRESET_PROMPTS.copy()