Spaces:
Runtime error
Runtime error
Update src/services/utils.py
Browse files- src/services/utils.py +28 -3
src/services/utils.py
CHANGED
@@ -6,7 +6,15 @@ import nltk
|
|
6 |
from nltk.stem import *
|
7 |
nltk.download("punkt_tab")
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
def set_prompt(problem):
|
12 |
prompt = """
|
@@ -48,7 +56,7 @@ def load_technologies_excel():
|
|
48 |
return df
|
49 |
|
50 |
def load_technologies():
|
51 |
-
EMBEDDINGS_FILE =
|
52 |
|
53 |
try:
|
54 |
with open(EMBEDDINGS_FILE, 'rb') as f:
|
@@ -147,4 +155,21 @@ def save_to_pickle(result_similarites):
|
|
147 |
pickle.dump(data_to_save, f)
|
148 |
|
149 |
print(f"\nMatrix and labels saved to {output_filename}")
|
150 |
-
return output_filename
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
from nltk.stem import *
|
7 |
nltk.download("punkt_tab")
|
8 |
|
9 |
+
from pathlib import Path
|
10 |
+
import os
|
11 |
+
import google.generativeai as genai
|
12 |
+
import json
|
13 |
+
from google.genai import Client, types
|
14 |
+
|
15 |
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
16 |
+
|
17 |
+
FILE_PATH = BASE_DIR / 'ressources' / 'global_tech_embeddings.pkl'
|
18 |
|
19 |
def set_prompt(problem):
|
20 |
prompt = """
|
|
|
56 |
return df
|
57 |
|
58 |
def load_technologies():
|
59 |
+
EMBEDDINGS_FILE = FILE_PATH
|
60 |
|
61 |
try:
|
62 |
with open(EMBEDDINGS_FILE, 'rb') as f:
|
|
|
155 |
pickle.dump(data_to_save, f)
|
156 |
|
157 |
print(f"\nMatrix and labels saved to {output_filename}")
|
158 |
+
return output_filename
|
159 |
+
|
160 |
+
|
161 |
+
def set_gemini():
|
162 |
+
gemini_api = os.getenv("GEMINI_API")
|
163 |
+
client = Client(api_key=gemini_api)
|
164 |
+
|
165 |
+
# Define the grounding tool
|
166 |
+
grounding_tool = types.Tool(
|
167 |
+
google_search=types.GoogleSearch()
|
168 |
+
)
|
169 |
+
|
170 |
+
# Configure generation settings
|
171 |
+
config = types.GenerateContentConfig(
|
172 |
+
tools=[grounding_tool]
|
173 |
+
)
|
174 |
+
|
175 |
+
return client,config
|