Yadvendra commited on
Commit
88e692a
·
verified ·
1 Parent(s): a36d2f3

Update gemini_utility.py

Browse files
Files changed (1) hide show
  1. 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
- #to get the working directory
7
- working_directory = os.path.dirname(os.path.abspath(__file__))
8
- config_file_path = f"{working_directory}/config.json"
9
- config_data = json.load(open(config_file_path))
10
-
11
-
12
- #loading the API key
13
- GOOGLE_API_KEY = config_data["GOOGLE_API_KEY"]
14
- genai.configure(api_key= GOOGLE_API_KEY)
15
-
16
- #function to load gemini pro model
17
- def load_gemini_pro():
18
- gemini_pro_model = genai.GenerativeModel("gemini-1.5-flash")
19
- return gemini_pro_model
20
-
21
- # Function to load image vision model
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
+