Gemini: google-generativeai + Cloud Dataflow

Hello everyone!

Summary:

Is the google-generativeai module tested on Cloud Dataflow? Please advice on how to integrate both.

Context:

I'm working with Dataflow's flex-templates and Python SDK. I've installed the aforementioned library using this line in my Dockerfile:

 

 

RUN pip install --no-cache-dir google-generativeai

 

 
This is also referenced in my requirements.txt file:
 

 

google-generativeai

 

 
That configuration gives me this error:
 
File "/template/src/processors/functions.py", line 304, in generate_content
model = genai.GenerativeModel('gemini-pro', generation_config=generation_config, safety_settings=safety_settings)
AttributeError: module 'google.generativeai' has no attribute 'GenerativeModel'
 
After reading this issue and this other one, I've tried the following in my requirements.txt file:
 

 

google-generativeai>=0.3.1

 

 
Which gives me the following error: 
 
Screenshot 2024-02-16 at 22.23.10.pngERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python >=3.9; 0.1.0rc3 Requires-Python >=3.9; 0.2.0 Requires-Python >=3.9; 0.2.1 Requires-Python >=3.9; 0.2.2 Requires-Python >=3.9; 0.3.0 Requires-Python >=3.9; 0.3.1 Requires-Python >=3.9; 0.3.2 Requires-Python >=3.9; 2.10.0 Requires-Python >=2.7,<3.0; 2.3.0 Requires-Python >=2.7,<3.0; 2.4.0 Requires-Python >=2.7,<3.0; 2.5.0 Requires-Python >=2.7,<3.0; 2.6.0 Requires-Python >=2.7,<3.0; 2.7.0 Requires-Python >=2.7,<3.0; 2.8.0 Requires-Python >=2.7,<3.0; 2.9.0 Requires-Python >=2.7,<3.0

ERROR: Could not find a version that satisfies the requirement google-generativeai>=0.3.1 (from versions: 0.1.0rc1, 0.1.0rc2)
ERROR: No matching distribution found for google-generativeai>=0.3.1

[notice] A new release of pip is available: 23.0 -> 24.0
[notice] To update, run: pip install --upgrade pip
The command '/bin/sh -c apt-get update && apt-get install -y libffi-dev git && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir -U -r /template/requirements.txt' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

 
 
--
Best regards
David Regalado
Web | Linkedin | Cloudskillsboost
1 2 789
2 REPLIES 2

Could anyone see this topic?

--
Best regards
David Regalado
Web | Linkedin | Cloudskillsboost

Can you share the Flex Template build command? What version of Python did you use?