Skip to content

Commit

Permalink
add search api
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-gee committed Nov 28, 2023
1 parent ceb7bb8 commit e5ab16f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/webtranspose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

__author__ = """Mike Gee"""
__email__ = "[email protected]"
__version__ = "0.1.0"
__version__ = "0.3.0"

from .chat import *
from .crawl import *
from .openai import *
from .scrape import *
from .search import *
38 changes: 38 additions & 0 deletions src/webtranspose/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import requests

from .webt_api import run_webt_api


def search(query):
if api_key is None:
api_key = os.environ.get("WEBTRANSPOSE_API_KEY")

if api_key is not None:
out_json = run_webt_api(
{
"query": query,
},
"/v1/search",
api_key,
)
return out_json

raise ValueError("Must provide api_key or set WEBTRANSPOSE_API_KEY in environment variables.")


def search_filter(query):
if api_key is None:
api_key = os.environ.get("WEBTRANSPOSE_API_KEY")

if api_key is not None:
out_json = run_webt_api(
{
"query": query,
},
"/v1/search/filter",
api_key,
)
return out_json

raise ValueError("Must provide api_key or set WEBTRANSPOSE_API_KEY in environment variables.")

0 comments on commit e5ab16f

Please sign in to comment.