acadiaway commited on
Commit
3ddd1c3
·
1 Parent(s): f148cdc

adjust safety settings to allo responses

Browse files
Files changed (1) hide show
  1. pipeline.py +22 -15
pipeline.py CHANGED
@@ -14,7 +14,7 @@ def query_gemini_api(prompt, max_retries=3):
14
 
15
  # Gemini API endpoint
16
  url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={api_key}"
17
- print(f"=== DEBUG: API URL: {url[:50]}...") # Fixed: Proper f-string syntax
18
 
19
  headers = {
20
  "Content-Type": "application/json"
@@ -32,7 +32,25 @@ def query_gemini_api(prompt, max_retries=3):
32
  "topP": 0.8,
33
  "maxOutputTokens": 200,
34
  "stopSequences": ["```", "\n\n"]
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
  print(f"=== DEBUG: Payload: {json.dumps(payload, indent=2)}")
38
 
@@ -67,7 +85,7 @@ def query_gemini_api(prompt, max_retries=3):
67
  if attempt == max_retries - 1:
68
  raise Exception(error_msg)
69
 
70
- except requests.exceptions.Timeout: # Previous fix retained
71
  print(f"=== DEBUG: Timeout on attempt {attempt + 1}")
72
  if attempt == max_retries - 1:
73
  raise Exception("Request timed out after multiple attempts")
@@ -189,15 +207,4 @@ SQL Query:"""
189
  return f"Error: Invalid SQL generated: {sql}", []
190
 
191
  # Execute SQL
192
- print(f"=== DEBUG: Executing SQL...")
193
- try:
194
- results = execute_sql(sql)
195
- print(f"=== DEBUG: SQL executed successfully, {len(results)} results")
196
- return sql, results
197
- except Exception as e:
198
- print(f"=== DEBUG: SQL execution error: {e}")
199
- return f"Error: SQL execution failed: {str(e)}", []
200
-
201
- except Exception as e:
202
- print(f"=== DEBUG: General error in text_to_sql: {e}")
203
- return f"Error: {str(e)}", []
 
14
 
15
  # Gemini API endpoint
16
  url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={api_key}"
17
+ print(f"=== DEBUG: API URL: {url[:50]}...")
18
 
19
  headers = {
20
  "Content-Type": "application/json"
 
32
  "topP": 0.8,
33
  "maxOutputTokens": 200,
34
  "stopSequences": ["```", "\n\n"]
35
+ },
36
+ "safetySettings": [
37
+ {
38
+ "category": "HARM_CATEGORY_HARASSMENT",
39
+ "threshold": "BLOCK_NONE"
40
+ },
41
+ {
42
+ "category": "HARM_CATEGORY_HATE_SPEECH",
43
+ "threshold": "BLOCK_NONE"
44
+ },
45
+ {
46
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
47
+ "threshold": "BLOCK_NONE"
48
+ },
49
+ {
50
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
51
+ "threshold": "BLOCK_NONE"
52
+ }
53
+ ]
54
  }
55
  print(f"=== DEBUG: Payload: {json.dumps(payload, indent=2)}")
56
 
 
85
  if attempt == max_retries - 1:
86
  raise Exception(error_msg)
87
 
88
+ except requests.exceptions.Timeout:
89
  print(f"=== DEBUG: Timeout on attempt {attempt + 1}")
90
  if attempt == max_retries - 1:
91
  raise Exception("Request timed out after multiple attempts")
 
207
  return f"Error: Invalid SQL generated: {sql}", []
208
 
209
  # Execute SQL
210
+ print(f"=== DEBUG