Zeggai Abdellah commited on
Commit
b436da0
·
1 Parent(s): 0d9a678

change the gemini model

Browse files
agent_direct_llm_sections.py CHANGED
@@ -31,17 +31,6 @@ except ImportError:
31
 
32
 
33
 
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
  def configure_settings():
46
  """Configure LLM and embedding settings"""
47
  print("Configuring LLM (Google GenAI)...")
@@ -49,21 +38,11 @@ def configure_settings():
49
  Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
50
  if not gemini_api_key:
51
  raise ValueError("GOOGLE_API_KEY environment variable not set! Required for Agent LLM.")
52
- Settings.llm = GoogleGenAI(model_name="models/gemini-2.5-pro-latest", api_key=gemini_api_key)
53
  print(f"LLM for Agent: {Settings.llm.model}")
54
 
55
 
56
 
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
  def query_section_directly(
68
  section_file_path: str,
69
  section_id_for_log: str,
@@ -139,21 +118,6 @@ def query_section_directly(
139
 
140
 
141
 
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
  def create_agent_instance():
158
  """Create and return an agent instance for API use"""
159
  # Section tool definitions
@@ -227,21 +191,6 @@ def create_agent_instance():
227
 
228
 
229
 
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
  print("\n--- Creating Function Tools for API Agent ---")
246
  tools_list = []
247
  section_files_dir = Path(SECTION_FILES_PATH)
@@ -276,16 +225,16 @@ def create_agent_instance():
276
  # Add API tools if available
277
  if API_CALLERS_AVAILABLE:
278
  print(" Creating .NET API Tools...")
279
- stats_api_tool = FunctionTool.from_defaults(
280
- fn=get_vaccination_statistics,
281
- name="get_vaccination_statistics_tool",
282
- description=(
283
- "Fetches current vaccination statistics for a specified Algerian Wilaya (province/state) "
284
- "from an external API, such as coverage rates. "
285
- "The input should be the name of the Wilaya (e.g., 'Algiers', 'Sétif')."
286
- )
287
- )
288
- tools_list.append(stats_api_tool)
289
 
290
  patient_record_api_tool = FunctionTool.from_defaults(
291
  fn=get_patient_vaccination_record,
@@ -297,18 +246,18 @@ def create_agent_instance():
297
  )
298
  tools_list.append(patient_record_api_tool)
299
 
300
- image_retrieval_tool = FunctionTool.from_defaults(
301
- fn=find_relevant_image_info,
302
- name="image_retrieval_tool",
303
- description=(
304
- "Searches for and provides information about relevant images, figures, diagrams, or flowcharts "
305
- "from the Algerian vaccination protocol document based on a textual description of the desired image. "
306
- "Use this if the user asks for a specific figure (e.g., 'Figure 4.1'), an illustration of a concept "
307
- "(e.g., 'diagram of cold chain levels'), or a visual representation."
308
- "the input for the tool should be a description of the image (e.g., 'Figure 4.1', 'diagram of cold chain levels')."
309
- )
310
- )
311
- tools_list.append(image_retrieval_tool)
312
 
313
  # Add WHO document tool if available
314
  who_doc_index_dir_name = "who_guidelines_index"
@@ -342,24 +291,6 @@ def create_agent_instance():
342
  raise Exception("No tools were created for the agent. Check file paths and tool definitions.")
343
 
344
 
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
  # Create custom system prompt
364
  custom_system_prompt = f"""
365
  You are an expert assistant for Algerian vaccination protocols and related health data.
@@ -398,28 +329,6 @@ def create_agent_instance():
398
 
399
 
400
 
401
-
402
-
403
-
404
-
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
  def run_direct_protocol_agent():
424
  """Original CLI function - kept for backward compatibility"""
425
  if not Path(SECTION_FILES_PATH).is_dir():
@@ -455,21 +364,6 @@ def run_direct_protocol_agent():
455
  traceback.print_exc()
456
 
457
 
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
  # Add this function for the FastAPI to use
474
  def run_direct_protocol_agent_for_api():
475
  """This function was referenced in the original FastAPI but not needed for the simple version"""
 
31
 
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
34
  def configure_settings():
35
  """Configure LLM and embedding settings"""
36
  print("Configuring LLM (Google GenAI)...")
 
38
  Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
39
  if not gemini_api_key:
40
  raise ValueError("GOOGLE_API_KEY environment variable not set! Required for Agent LLM.")
41
+ Settings.llm = GoogleGenAI(model_name="models/gemini-2.0-flash", api_key=gemini_api_key)
42
  print(f"LLM for Agent: {Settings.llm.model}")
43
 
44
 
45
 
 
 
 
 
 
 
 
 
 
 
46
  def query_section_directly(
47
  section_file_path: str,
48
  section_id_for_log: str,
 
118
 
119
 
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  def create_agent_instance():
122
  """Create and return an agent instance for API use"""
123
  # Section tool definitions
 
191
 
192
 
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  print("\n--- Creating Function Tools for API Agent ---")
195
  tools_list = []
196
  section_files_dir = Path(SECTION_FILES_PATH)
 
225
  # Add API tools if available
226
  if API_CALLERS_AVAILABLE:
227
  print(" Creating .NET API Tools...")
228
+ # stats_api_tool = FunctionTool.from_defaults(
229
+ # fn=get_vaccination_statistics,
230
+ # name="get_vaccination_statistics_tool",
231
+ # description=(
232
+ # "Fetches current vaccination statistics for a specified Algerian Wilaya (province/state) "
233
+ # "from an external API, such as coverage rates. "
234
+ # "The input should be the name of the Wilaya (e.g., 'Algiers', 'Sétif')."
235
+ # )
236
+ # )
237
+ ## tools_list.append(stats_api_tool)
238
 
239
  patient_record_api_tool = FunctionTool.from_defaults(
240
  fn=get_patient_vaccination_record,
 
246
  )
247
  tools_list.append(patient_record_api_tool)
248
 
249
+ # image_retrieval_tool = FunctionTool.from_defaults(
250
+ # fn=find_relevant_image_info,
251
+ # name="image_retrieval_tool",
252
+ # description=(
253
+ # "Searches for and provides information about relevant images, figures, diagrams, or flowcharts "
254
+ # "from the Algerian vaccination protocol document based on a textual description of the desired image. "
255
+ # "Use this if the user asks for a specific figure (e.g., 'Figure 4.1'), an illustration of a concept "
256
+ # "(e.g., 'diagram of cold chain levels'), or a visual representation."
257
+ # "the input for the tool should be a description of the image (e.g., 'Figure 4.1', 'diagram of cold chain levels')."
258
+ # )
259
+ # )
260
+ ## tools_list.append(image_retrieval_tool)
261
 
262
  # Add WHO document tool if available
263
  who_doc_index_dir_name = "who_guidelines_index"
 
291
  raise Exception("No tools were created for the agent. Check file paths and tool definitions.")
292
 
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  # Create custom system prompt
295
  custom_system_prompt = f"""
296
  You are an expert assistant for Algerian vaccination protocols and related health data.
 
329
 
330
 
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  def run_direct_protocol_agent():
333
  """Original CLI function - kept for backward compatibility"""
334
  if not Path(SECTION_FILES_PATH).is_dir():
 
364
  traceback.print_exc()
365
 
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  # Add this function for the FastAPI to use
368
  def run_direct_protocol_agent_for_api():
369
  """This function was referenced in the original FastAPI but not needed for the simple version"""
api_callers.py CHANGED
@@ -36,7 +36,6 @@ def get_vaccination_statistics(wilaya: str) -> str:
36
 
37
 
38
 
39
-
40
  def get_patient_vaccination_record(patient_id: str) -> str:
41
  """
42
  Retrieves the vaccination record for a specific patient using their unique ID.
 
36
 
37
 
38
 
 
39
  def get_patient_vaccination_record(patient_id: str) -> str:
40
  """
41
  Retrieves the vaccination record for a specific patient using their unique ID.
ingest_and_index_supplementary_doc.py CHANGED
@@ -20,12 +20,6 @@ SUPPLEMENTARY_INDEXES_BASE_PATH_FOR_AGENT = "./storage/supplementary_indices"
20
 
21
 
22
 
23
-
24
-
25
-
26
-
27
-
28
-
29
  def configure_indexing_settings():
30
  """Configures global Embedding model and optional LLM settings."""
31
 
@@ -37,7 +31,7 @@ def configure_indexing_settings():
37
 
38
  gemini_api_key = os.getenv("GOOGLE_API_KEY")
39
  if gemini_api_key:
40
- Settings.llm = GoogleGenAI(model_name="models/gemini-1.5-flash-latest", api_key=gemini_api_key)
41
  print(f"LLM (Optional for indexing): {Settings.llm.model}")
42
  else:
43
  Settings.llm = None
@@ -45,20 +39,6 @@ def configure_indexing_settings():
45
 
46
 
47
 
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
  def process_and_index_document(doc_file_path_str: str, index_persist_path_str: str):
63
  """
64
  Ingests a single document, creates a VectorStoreIndex (in memory first),
@@ -118,18 +98,6 @@ def process_and_index_document(doc_file_path_str: str, index_persist_path_str: s
118
 
119
 
120
 
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
  if __name__ == "__main__":
134
  parser = argparse.ArgumentParser(description="Ingest a single supplementary document and create its VectorStoreIndex.")
135
  parser.add_argument("document_path", help="Full path to the supplementary document file (e.g., PDF).")
 
20
 
21
 
22
 
 
 
 
 
 
 
23
  def configure_indexing_settings():
24
  """Configures global Embedding model and optional LLM settings."""
25
 
 
31
 
32
  gemini_api_key = os.getenv("GOOGLE_API_KEY")
33
  if gemini_api_key:
34
+ Settings.llm = GoogleGenAI(model_name="models/gemini-2.0-flash", api_key=gemini_api_key)
35
  print(f"LLM (Optional for indexing): {Settings.llm.model}")
36
  else:
37
  Settings.llm = None
 
39
 
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  def process_and_index_document(doc_file_path_str: str, index_persist_path_str: str):
43
  """
44
  Ingests a single document, creates a VectorStoreIndex (in memory first),
 
98
 
99
 
100
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  if __name__ == "__main__":
102
  parser = argparse.ArgumentParser(description="Ingest a single supplementary document and create its VectorStoreIndex.")
103
  parser.add_argument("document_path", help="Full path to the supplementary document file (e.g., PDF).")