Anustup commited on
Commit
0f63318
·
verified ·
1 Parent(s): fb200df

Update summarizer.py

Browse files
Files changed (1) hide show
  1. summarizer.py +22 -1
summarizer.py CHANGED
@@ -9,7 +9,8 @@ import nltk
9
  import openai
10
 
11
  nltk.download('punkt')
12
- OPENAI_API_KEY = ""
 
13
 
14
 
15
  def create_brand_html(brand_link):
@@ -34,3 +35,23 @@ def create_langchain_openai_query(docs):
34
  map_reduce_chain = load_summarize_chain(llm, chain_type="map_reduce")
35
  output = map_reduce_chain.run(docs)
36
  return output
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import openai
10
 
11
  nltk.download('punkt')
12
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
13
+ SCRAP_API_KEY = os.getenv("SCRAP_API_KEY")
14
 
15
 
16
  def create_brand_html(brand_link):
 
35
  map_reduce_chain = load_summarize_chain(llm, chain_type="map_reduce")
36
  output = map_reduce_chain.run(docs)
37
  return output
38
+
39
+
40
+ def create_screenshot_from_scrap_fly(link_to_fetch):
41
+ import requests
42
+ import random
43
+ try:
44
+ params = {
45
+ 'key': SCRAP_API_KEY,
46
+ 'url': link_to_fetch,
47
+ 'auto_scroll': True,
48
+ 'capture': 'fullpage',
49
+ 'options': 'block_banners'
50
+ }
51
+ response = requests.get('https://api.scrapfly.io/screenshot', params=params)
52
+ location = f"brand_ss_{random.randint(1, 100000000)}.png"
53
+ with open('screenshot.jpg', 'wb') as file:
54
+ file.write(response.content)
55
+ return {"location": location, "success": True}
56
+ except Exception as e:
57
+ return {"success": False, "error": e}