Gaurav vashistha commited on
Commit
c0af42a
·
1 Parent(s): ef27e6d

fix: resolve deployment errors (Gemini wait loop, Groq model, system deps)

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -0
  2. agent.py +19 -1
Dockerfile CHANGED
@@ -1,6 +1,8 @@
1
  FROM python:3.10-slim
2
  WORKDIR /app
3
 
 
 
4
  COPY requirements.txt .
5
  RUN pip install --no-cache-dir -r requirements.txt
6
  COPY . .
 
1
  FROM python:3.10-slim
2
  WORKDIR /app
3
 
4
+ RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0 && rm -rf /var/lib/apt/lists/*
5
+
6
  COPY requirements.txt .
7
  RUN pip install --no-cache-dir -r requirements.txt
8
  COPY . .
agent.py CHANGED
@@ -104,6 +104,20 @@ def analyze_videos(state: ContinuityState) -> dict:
104
  file_a = client.files.upload(file=path_a)
105
  file_c = client.files.upload(file=path_c)
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  prompt_text = """
108
  You are a film director.
109
  Analyze the motion, lighting, and subject of the first video (Video A) and the second video (Video C).
@@ -136,7 +150,7 @@ def analyze_videos(state: ContinuityState) -> dict:
136
  groq_client = Groq(api_key=os.environ["GROQ_API_KEY"])
137
  fallback_prompt = "Create a smooth, cinematic visual transition that bridges two scenes."
138
  completion = groq_client.chat.completions.create(
139
- model="llama-3.2-11b-vision-preview",
140
  messages=[{"role": "user", "content": f"Refine this into a video prompt: {fallback_prompt}"}]
141
  )
142
  transition_prompt = completion.choices[0].message.content
@@ -217,6 +231,10 @@ def generate_video(state: ContinuityState) -> dict:
217
  logger.warning("⚠️ GCP_PROJECT_ID not set. Skipping Veo.")
218
 
219
  except Exception as e:
 
 
 
 
220
  logger.warning(f"⚠️ Veo Failed: {e}")
221
  # Fallback to SVD below
222
 
 
104
  file_a = client.files.upload(file=path_a)
105
  file_c = client.files.upload(file=path_c)
106
 
107
+ # --- FIX: WAIT FOR ACTIVE STATE ---
108
+ logger.info("Waiting for video processing...")
109
+ while file_a.state.name == "PROCESSING":
110
+ time.sleep(2)
111
+ file_a = client.files.get(name=file_a.name)
112
+
113
+ while file_c.state.name == "PROCESSING":
114
+ time.sleep(2)
115
+ file_c = client.files.get(name=file_c.name)
116
+
117
+ if file_a.state.name != "ACTIVE" or file_c.state.name != "ACTIVE":
118
+ logger.error(f"File state issue. A: {file_a.state.name}, C: {file_c.state.name}")
119
+ raise Exception("Gemini files not active.")
120
+
121
  prompt_text = """
122
  You are a film director.
123
  Analyze the motion, lighting, and subject of the first video (Video A) and the second video (Video C).
 
150
  groq_client = Groq(api_key=os.environ["GROQ_API_KEY"])
151
  fallback_prompt = "Create a smooth, cinematic visual transition that bridges two scenes."
152
  completion = groq_client.chat.completions.create(
153
+ model="llama-3.2-90b-vision-preview",
154
  messages=[{"role": "user", "content": f"Refine this into a video prompt: {fallback_prompt}"}]
155
  )
156
  transition_prompt = completion.choices[0].message.content
 
231
  logger.warning("⚠️ GCP_PROJECT_ID not set. Skipping Veo.")
232
 
233
  except Exception as e:
234
+ # --- FIX: DETAILED LOGGING FOR 403 ---
235
+ err_str = str(e)
236
+ if "403" in err_str or "PERMISSION_DENIED" in err_str:
237
+ logger.warning("⚠️ Veo Permission Error. Please ensure the 'Vertex AI API' is enabled in your Google Cloud Console.")
238
  logger.warning(f"⚠️ Veo Failed: {e}")
239
  # Fallback to SVD below
240