Spaces:
Runtime error
Runtime error
gamingflexer
commited on
Commit
•
9b39647
1
Parent(s):
9169c2a
Add Google search functionality to scrapper/extractor.py
Browse files- src/scrapper/extractor.py +13 -1
src/scrapper/extractor.py
CHANGED
@@ -3,8 +3,20 @@ from langchain import PromptTemplate, LLMChain
|
|
3 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
4 |
import tiktoken
|
5 |
from typing import Union
|
6 |
-
from config import OPENAI_API_KEY
|
7 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def init_extractor(
|
10 |
template: str,
|
|
|
3 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
4 |
import tiktoken
|
5 |
from typing import Union
|
6 |
+
from config import OPENAI_API_KEY, SERP_API_KEY
|
7 |
import os
|
8 |
+
from serpapi import GoogleSearch
|
9 |
+
|
10 |
+
def get_google_scrape(query, api_key = SERP_API_KEY, num = 25):
|
11 |
+
search = GoogleSearch({
|
12 |
+
"q": query,
|
13 |
+
"api_key": api_key,
|
14 |
+
"start": "1",
|
15 |
+
"end": "10",
|
16 |
+
"num": num,
|
17 |
+
})
|
18 |
+
result = search.get_dict()
|
19 |
+
return result
|
20 |
|
21 |
def init_extractor(
|
22 |
template: str,
|