api keys func added
parent
dccf27e6ab
commit
16aa8cea4a
|
@ -36,15 +36,20 @@ def google_urls(query: str, links: list[str]) -> list[str]:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
"https://www.googleapis.com/customsearch/v1",
|
"https://www.googleapis.com/customsearch/v1",
|
||||||
params={
|
params={
|
||||||
"key": os.environ["API_KEY"],
|
"key": config.GOOGLE_API_KEY,
|
||||||
"q": query,
|
"q": query,
|
||||||
"cx": os.environ["SEARCH_ENGINE_ID"],
|
"cx": config.GOOGLE_SEARCH_ENGINE_ID,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
results = response.json()["items"]
|
results = response.json()["items"]
|
||||||
# Print the search results
|
# Print the search results
|
||||||
|
num_of_res: int = (
|
||||||
|
5 if config.CONF_MODE == "speed" else (20 if config.CONF_MODE else 10)
|
||||||
|
)
|
||||||
for result in results:
|
for result in results:
|
||||||
links.append(result["link"])
|
links.append(result["link"])
|
||||||
|
if len(links) == num_of_res:
|
||||||
|
break
|
||||||
return links
|
return links
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,21 @@ logging.basicConfig(
|
||||||
format="%(name)s - %(levelname)s - %(message)s",
|
format="%(name)s - %(levelname)s - %(message)s",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
GOOGLE_API_KEY: str = ""
|
||||||
|
GOOGLE_SEARCH_ENGINE_ID: str = ""
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
NLP_CONF_DEBUG: bool = True
|
NLP_CONF_DEBUG: bool = True
|
||||||
# NLP
|
# NLP
|
||||||
NLP_CONF_MODE: str = "default"
|
NLP_CONF_MODE: str = "default"
|
||||||
|
|
||||||
|
|
||||||
|
def API_CONFIG(_GOOGLE_API_KEY: str = "", _GOOGLE_SEARCH_ENGINE_ID: str = "") -> None:
|
||||||
|
global GOOGLE_SEARCH_ENGINE_ID, GOOGLE_API_KEY
|
||||||
|
GOOGLE_API_KEY = _GOOGLE_API_KEY
|
||||||
|
GOOGLE_SEARCH_ENGINE_ID = _GOOGLE_SEARCH_ENGINE_ID
|
||||||
|
|
||||||
|
|
||||||
def NLP_config(mode: str = "default", debug: bool = True) -> None:
|
def NLP_config(mode: str = "default", debug: bool = True) -> None:
|
||||||
global conf_MODE, conf_DEBUG
|
global conf_MODE, conf_DEBUG
|
||||||
NLP_CONF_DEBUG = debug
|
NLP_CONF_DEBUG = debug
|
||||||
|
|
|
@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "internet_ml"
|
name = "internet_ml"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "Internet-ML: Allowing ML to connect to the internet"
|
description = "Internet-ML: Allowing ML to connect to the internet"
|
||||||
readme = "./.github/README.md"
|
readme = "./.github/README.md"
|
||||||
authors = ["Thamognya Kodi <contact@thamognya.com>"]
|
authors = ["Thamognya Kodi <contact@thamognya.com>"]
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
|
Loading…
Reference in New Issue