GuglielmoTor commited on
Commit
fd8976c
·
verified ·
1 Parent(s): a8afa39

Update chatbot_handler.py

Browse files
Files changed (1) hide show
  1. chatbot_handler.py +3 -11
chatbot_handler.py CHANGED
@@ -10,8 +10,7 @@ import asyncio
10
  GEMINI_API_KEY = os.getenv('GEMINI_API_KEY', '')
11
 
12
  client = None
13
- model_name = "gemini-1.5-flash-latest" # Using a more recent Flash model
14
- # model_name = "gemini-2.0-flash" # As per user's documentation snippet, ensure this model is available with their API key type
15
 
16
  # This will be used to create genai_types.GenerateContentConfig
17
  generation_config_params = {
@@ -23,13 +22,6 @@ generation_config_params = {
23
  # "system_instruction": "You are a helpful AI assistant providing insights on LinkedIn analytics."
24
  }
25
 
26
- # Safety settings list
27
- common_safety_settings = [
28
- {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
29
- {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
30
- {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
31
- {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
32
- ]
33
 
34
  try:
35
  if GEMINI_API_KEY:
@@ -98,8 +90,8 @@ async def generate_llm_response(user_message: str, plot_id: str, plot_label: str
98
  client.models.generate_content,
99
  model=model_name, # Use model_name directly
100
  contents=gemini_formatted_history,
101
- config=gen_config_obj, # Corrected keyword argument
102
- safety_settings=common_safety_settings
103
  )
104
  else:
105
  logging.error(f"Gemini client (genai.Client) does not have 'models.generate_content' method. Type: {type(client)}")
 
10
  GEMINI_API_KEY = os.getenv('GEMINI_API_KEY', '')
11
 
12
  client = None
13
+ model_name = "gemini-2.0-flash" # As per user's documentation snippet, ensure this model is available with their API key type
 
14
 
15
  # This will be used to create genai_types.GenerateContentConfig
16
  generation_config_params = {
 
22
  # "system_instruction": "You are a helpful AI assistant providing insights on LinkedIn analytics."
23
  }
24
 
 
 
 
 
 
 
 
25
 
26
  try:
27
  if GEMINI_API_KEY:
 
90
  client.models.generate_content,
91
  model=model_name, # Use model_name directly
92
  contents=gemini_formatted_history,
93
+ config=gen_config_obj # Corrected keyword argument
94
+
95
  )
96
  else:
97
  logging.error(f"Gemini client (genai.Client) does not have 'models.generate_content' method. Type: {type(client)}")