Soham Waghmare commited on
Commit
02298d2
·
1 Parent(s): 27591d1

feat: format

Browse files
backend/app.py CHANGED
@@ -10,7 +10,6 @@ from fastapi.middleware.cors import CORSMiddleware
10
  from knet import KNet
11
  from scraper import CrawlForAIScraper, WebScraper
12
 
13
-
14
  load_dotenv()
15
 
16
  # Configure logging
 
10
  from knet import KNet
11
  from scraper import CrawlForAIScraper, WebScraper
12
 
 
13
  load_dotenv()
14
 
15
  # Configure logging
backend/knet.py CHANGED
@@ -12,7 +12,6 @@ from google.ai.generativelanguage_v1beta.types import content
12
 
13
  from research_node import ResearchNode
14
 
15
-
16
  # Load environment variables
17
  load_dotenv()
18
 
@@ -177,7 +176,7 @@ class KNet:
177
  return result["decision"]
178
  except Exception as e:
179
  if result["candidates"][0]["finishReason"] == "RECITATION":
180
- self.logger.error(f"Retrying branch decision: {str(e)}\nC:{retry_count/3}")
181
  self._should_branch_deeper(node, topic, retry_count + 1)
182
  self.logger.error(f"Branch decision failed: {str(e)}")
183
  raise e
@@ -277,7 +276,7 @@ class KNet:
277
 
278
  except Exception as e:
279
  if result["candidates"][0]["finishReason"] == "RECITATION" and retry_count <= 3:
280
- self.logger.error(f"Retrying analysis: {str(e)}\nC:{retry_count/3}")
281
  self._analyze_and_branch(node, topic, retry_count + 1)
282
  self.logger.error(f"Branch analysis failed: {str(e)}")
283
  raise e
@@ -337,7 +336,7 @@ class KNet:
337
  }
338
  except Exception as e:
339
  if response["candidates"][0]["finishReason"] == "RECITATION":
340
- self.logger.error(f"Retrying final report: {str(e)}\nC:{retry_count/3}")
341
  self._generate_final_report(root_node, retry_count + 1)
342
  self.logger.error(f"Error generating final report: {str(e)}")
343
  raise e
 
12
 
13
  from research_node import ResearchNode
14
 
 
15
  # Load environment variables
16
  load_dotenv()
17
 
 
176
  return result["decision"]
177
  except Exception as e:
178
  if result["candidates"][0]["finishReason"] == "RECITATION":
179
+ self.logger.error(f"Retrying branch decision: {str(e)}\nC:{retry_count / 3}")
180
  self._should_branch_deeper(node, topic, retry_count + 1)
181
  self.logger.error(f"Branch decision failed: {str(e)}")
182
  raise e
 
276
 
277
  except Exception as e:
278
  if result["candidates"][0]["finishReason"] == "RECITATION" and retry_count <= 3:
279
+ self.logger.error(f"Retrying analysis: {str(e)}\nC:{retry_count / 3}")
280
  self._analyze_and_branch(node, topic, retry_count + 1)
281
  self.logger.error(f"Branch analysis failed: {str(e)}")
282
  raise e
 
336
  }
337
  except Exception as e:
338
  if response["candidates"][0]["finishReason"] == "RECITATION":
339
+ self.logger.error(f"Retrying final report: {str(e)}\nC:{retry_count / 3}")
340
  self._generate_final_report(root_node, retry_count + 1)
341
  self.logger.error(f"Error generating final report: {str(e)}")
342
  raise e
backend/research_node.py CHANGED
@@ -1,6 +1,6 @@
 
1
  from datetime import datetime
2
  from typing import Any, Dict, List, Optional
3
- import copy
4
 
5
 
6
  class ResearchNode:
 
1
+ import copy
2
  from datetime import datetime
3
  from typing import Any, Dict, List, Optional
 
4
 
5
 
6
  class ResearchNode:
backend/scraper.py CHANGED
@@ -274,7 +274,7 @@ class CrawlForAIScraper:
274
  # Remove units from width and height: get start of the entity till the first non-digit character
275
  width = "".join([i for i in img.get("width", "0") if i.isdigit() or i == "."])
276
  height = "".join([i for i in img.get("height", "0") if i.isdigit() or i == "."])
277
- if width == '' or height == '':
278
  continue
279
  width, height = float(width), float(height)
280
  if width > 300 and height > 300 and "pixel" not in src and "icon" not in src:
 
274
  # Remove units from width and height: get start of the entity till the first non-digit character
275
  width = "".join([i for i in img.get("width", "0") if i.isdigit() or i == "."])
276
  height = "".join([i for i in img.get("height", "0") if i.isdigit() or i == "."])
277
+ if width == "" or height == "":
278
  continue
279
  width, height = float(width), float(height)
280
  if width > 300 and height > 300 and "pixel" not in src and "icon" not in src: