Update gemini_utility.py
Browse files- gemini_utility.py +21 -27
gemini_utility.py
CHANGED
@@ -1,27 +1,21 @@
|
|
1 |
-
import os
|
2 |
-
import json
|
3 |
-
import google.generativeai as genai
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
def gemini_pro_vision_responce(prompt, image):
|
23 |
-
gemini_pro_vision_model = genai.GenerativeModel("gemini-1.5-pro")
|
24 |
-
responce = gemini_pro_vision_model.generate_content([prompt, image])
|
25 |
-
result = responce.text
|
26 |
-
return result
|
27 |
-
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
import google.generativeai as genai
|
4 |
+
from PIL import Image
|
5 |
+
|
6 |
+
#loading the API key
|
7 |
+
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
8 |
+
genai.configure(api_key= GOOGLE_API_KEY)
|
9 |
+
|
10 |
+
#function to load gemini pro model
|
11 |
+
def load_gemini_pro():
|
12 |
+
gemini_pro_model = genai.GenerativeModel("gemini-1.5-flash")
|
13 |
+
return gemini_pro_model
|
14 |
+
|
15 |
+
# Function to load image vision model
|
16 |
+
def gemini_pro_vision_responce(prompt, image):
|
17 |
+
gemini_pro_vision_model = genai.GenerativeModel("gemini-1.5-pro")
|
18 |
+
responce = gemini_pro_vision_model.generate_content([prompt, image])
|
19 |
+
result = responce.text
|
20 |
+
return result
|
21 |
+
|
|
|
|
|
|
|
|
|
|
|
|