api keys func added

main
Thamognya Kodi 2022-12-26 22:58:47 +07:00
parent dccf27e6ab
commit 16aa8cea4a
4 changed files with 20 additions and 3 deletions

View File

@ -36,15 +36,20 @@ def google_urls(query: str, links: list[str]) -> list[str]:
response = requests.get(
"https://www.googleapis.com/customsearch/v1",
params={
"key": os.environ["API_KEY"],
"key": config.GOOGLE_API_KEY,
"q": query,
"cx": os.environ["SEARCH_ENGINE_ID"],
"cx": config.GOOGLE_SEARCH_ENGINE_ID,
},
)
results = response.json()["items"]
# 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:
links.append(result["link"])
if len(links) == num_of_res:
break
return links

View File

@ -7,12 +7,21 @@ logging.basicConfig(
format="%(name)s - %(levelname)s - %(message)s",
)
GOOGLE_API_KEY: str = ""
GOOGLE_SEARCH_ENGINE_ID: str = ""
# Global
NLP_CONF_DEBUG: bool = True
# NLP
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:
global conf_MODE, conf_DEBUG
NLP_CONF_DEBUG = debug

View File

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "internet_ml"
version = "0.1.1"
version = "0.1.2"
description = "Internet-ML: Allowing ML to connect to the internet"
readme = "./.github/README.md"
authors = ["Thamognya Kodi <contact@thamognya.com>"]

View File

@ -0,0 +1,3 @@
#!/bin/sh
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD