diff options
| -rw-r--r-- | README.md | 21 | ||||
| -rw-r--r-- | devourer.py | 10 | ||||
| -rwxr-xr-x | tests.sh | 2 | 
3 files changed, 26 insertions, 7 deletions
@@ -3,7 +3,26 @@  [](https://github.com/psf/black)  # devourer -A knowledge aggregator +devourer is an api server that currently has the following endpoints and does the following things:<br/> + +## /summ +```sh +https://localhost:19019/mila/summ?url=https://dilipkumar.medium.com/standalone-mongodb-on-kubernetes-cluster-19e7b5896b27&summary=newspaper&audio=true +``` +The `/summ` endpoint optionally summarizes the article and can also optionally send the article as an audio file.<br/> +The parameters are `url`,`summary` tells the server which summarization method to use. the last parameter `audio` tells the server whether to just send the text result or an audio equivalent.<br/> + +## /wiki +```sh +https://localhost:19019/mila/wiki?term=iommu&summary=newspaper&audio=true +``` +Searches wikipedia for the given `term` parameter. Like other endpoints, can optionally summarize the result and turn it into audio with `summary` and `audio` parameters.<br/> + +## /reqs +```sh +https://localhost:19019/mila/reqs?url=https://www.ietf.org/rfc/rfc2865.txt&sourcetype=text +``` +Extracts the requirements from the contents inside a given url. The `sourcetype` parameter tells the server how to interpret the url contents. currently only `text` and `html` are supported as valid values.<br/>  ## Usage Example diff --git a/devourer.py b/devourer.py index 75f469b..8196050 100644 --- a/devourer.py +++ b/devourer.py @@ -242,7 +242,7 @@ def summarizeLinksToAudio(url, summary) -> None:          return result -def searchWikipedia(search_term: str) -> str: +def searchWikipedia(search_term: str, summary: str) -> str:      """Search wikipedia for a string and return the url.      reference: https://www.mediawiki.org/wiki/API:Opensearch @@ -259,7 +259,7 @@ def searchWikipedia(search_term: str) -> str:          res = getWithParams(os.environ["WIKI_SEARCH_URL"], searchParmas)          # FIXME-handle wiki redirects/disambiguations          source = res[3][0] -        result = summarizeLinkToAudio(source, "none") +        result = summarizeLinkToAudio(source, summary)      except Exception as e:          logging.exception(e)      finally: @@ -298,12 +298,12 @@ def extract_reqs_ep(url: str, sourcetype: str = "html"):  @app.get("/mila/wiki") -def wiki_search_ep(term: str, audio: bool = False): +def wiki_search_ep(term: str, summary: str = "none", audio: bool = False):      """search and summarizes from wikipedia""" -    text = searchWikipedia(term) +    text = searchWikipedia(term, summary)      if audio:          audio_path = textToAudio(text) -        return FastAPI( +        return APIResponse(              getAudioFromFile(audio_path) if audio_path != "" else "",              media_type="audio/mpeg",          ) @@ -1,5 +1,5 @@  #!/usr/bin/env sh  curl -k -X GET https://localhost:19019/mila/summ?url=https://dilipkumar.medium.com/standalone-mongodb-on-kubernetes-cluster-19e7b5896b27&summary=newspaper&audio=true -curl -k -X GET https://localhost:19019/mila/wiki?term=iommu +curl -k -X GET https://localhost:19019/mila/wiki?term=iommu&summary=none&audio=false  curl -k -X GET https://localhost:19019/mila/reqs?url=https://www.ietf.org/rfc/rfc2865.txt&sourcetype=text  | 
