From 6b5767a344c2d8ed75a8846966bc9edc0a0176d1 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:19:01 -0700 Subject: [PATCH 01/12] Support `region` in stock search requests (#17) # Description Add `region` to stock symbol lookup requests to narrow results to a market Include `service` in responses to attribute API provider (currently Alpha Vantage) # Issues Closes #16 # Other Notes --------- Co-authored-by: Daniel McKnight --- neon_hana/mq_service_api.py | 11 +++++++++-- neon_hana/schema/api_requests.py | 4 +++- neon_hana/schema/api_responses.py | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/neon_hana/mq_service_api.py b/neon_hana/mq_service_api.py index c74a1ad..eb2414b 100644 --- a/neon_hana/mq_service_api.py +++ b/neon_hana/mq_service_api.py @@ -52,10 +52,17 @@ def __init__(self, config: dict): self.sessions_by_id = dict() @staticmethod - def _validate_api_proxy_response(response: dict): + def _validate_api_proxy_response(response: dict, query_params: dict): if response['status_code'] == 200: try: resp = json.loads(response['content']) + if query_params.get('service') == "alpha_vantage": + resp['service'] = query_params['service'] + if query_params.get("region") and resp.get('bestMatches'): + filtered = [ + stock for stock in resp.get("bestMatches") + if stock.get("4. region") == query_params["region"]] + resp['bestMatches'] = filtered if isinstance(resp, dict): return resp # Reverse Geocode API returns a list; reformat that to a dict @@ -87,7 +94,7 @@ def query_api_proxy(self, service_name: str, query_params: dict, query_params['service'] = service_name response = send_mq_request("/neon_api", query_params, "neon_api_input", "neon_api_output", timeout) - return self._validate_api_proxy_response(response) + return self._validate_api_proxy_response(response, query_params) def query_llm(self, llm_name: str, query: str, history: List[tuple]): response = send_mq_request("/llm", {"query": query, diff --git a/neon_hana/schema/api_requests.py b/neon_hana/schema/api_requests.py index 3d652b8..95ea29e 100644 --- a/neon_hana/schema/api_requests.py +++ b/neon_hana/schema/api_requests.py @@ -52,9 +52,11 @@ class WeatherAPIRequest(BaseModel): class StockAPISymbolRequest(BaseModel): company: Optional[str] = None + region: Optional[str] = None model_config = { "json_schema_extra": { - "examples": [{"company": "microsoft"}]}} + "examples": [{"company": "microsoft", + "region": "United States"}]}} class StockAPIQuoteRequest(BaseModel): diff --git a/neon_hana/schema/api_responses.py b/neon_hana/schema/api_responses.py index 4b0ca73..d987cb1 100644 --- a/neon_hana/schema/api_responses.py +++ b/neon_hana/schema/api_responses.py @@ -1749,6 +1749,7 @@ class StockAPIQuoteResponse(BaseModel): "json_schema_extra": { "examples": [ { + "provider": "alpha_vantage", "Global Quote": { "01. symbol": "GOOG", "02. open": "144.8950", @@ -1771,6 +1772,7 @@ class StockAPISearchResponse(BaseModel): "json_schema_extra": { "examples": [ { + "provider": "alpha_vantage", "bestMatches": [ { "1. symbol": "MSF0.FRK", From af42e88331cf19c4bcab0551d71d9c0fddbd7572 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Tue, 9 Apr 2024 22:19:14 +0000 Subject: [PATCH 02/12] Increment Version to 0.0.2a1 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index ef7228e..5ef4f7a 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.1" +__version__ = "0.0.2a1" From 30bb9e1b1a4ab325602138790b49620bfeb076d1 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:15:27 -0700 Subject: [PATCH 03/12] Add `lang_code` optional param to weather endpoint (#18) # Description Add `lang_code` option to weather endpoint Replaces `lang_code` with `lang` for api consistency and OWM compat. # Issues Closes #15 # Other Notes --------- Co-authored-by: Daniel McKnight --- neon_hana/app/routers/api_proxy.py | 4 +++- neon_hana/schema/api_requests.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/neon_hana/app/routers/api_proxy.py b/neon_hana/app/routers/api_proxy.py index de37194..25135f1 100644 --- a/neon_hana/app/routers/api_proxy.py +++ b/neon_hana/app/routers/api_proxy.py @@ -36,7 +36,9 @@ @proxy_route.post("/weather") async def api_proxy_weather(query: WeatherAPIRequest) -> WeatherAPIOnecallResponse: - return mq_connector.query_api_proxy("open_weather_map", dict(query)) + query = dict(query) + query["lang"] = query.pop("lang_code") + return mq_connector.query_api_proxy("open_weather_map", query) @proxy_route.post("/stock/symbol") diff --git a/neon_hana/schema/api_requests.py b/neon_hana/schema/api_requests.py index 95ea29e..7ccd67b 100644 --- a/neon_hana/schema/api_requests.py +++ b/neon_hana/schema/api_requests.py @@ -34,7 +34,7 @@ class WeatherAPIRequest(BaseModel): lat: float lon: float unit: str = "metric" - + lang_code: str = "en" model_config = { "json_schema_extra": { "examples": [{ @@ -42,11 +42,12 @@ class WeatherAPIRequest(BaseModel): "lat": 47.6815, "lon": -122.2087, "unit": "imperial", + "lang_code": "en" }, { "api": "onecall", "lat": 47.6815, "lon": -122.2087, - "unit": "metric", + "unit": "metric" }]}} From 36f635665526c48e70f4c7ca31f28e923501404c Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Wed, 10 Apr 2024 00:15:44 +0000 Subject: [PATCH 04/12] Increment Version to 0.0.2a2 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index 5ef4f7a..d2529a5 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.2a1" +__version__ = "0.0.2a2" From 100a1c4b2ec7d99724d2b656fb33cfb0db5e1371 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 9 Apr 2024 18:34:34 -0700 Subject: [PATCH 05/12] Include email API error responses in HTTP response (#19) # Description Include response error messages in email error responses # Issues Response messages updated in https://github.com/NeonGeckoCom/neon_email_proxy/pull/28 # Other Notes Co-authored-by: Daniel McKnight --- neon_hana/mq_service_api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neon_hana/mq_service_api.py b/neon_hana/mq_service_api.py index eb2414b..ddd7dfa 100644 --- a/neon_hana/mq_service_api.py +++ b/neon_hana/mq_service_api.py @@ -119,7 +119,8 @@ def send_email(self, recipient: str, subject: str, body: str, response = send_mq_request("/neon_emails", request_data, "neon_emails_input") if not response.get("success"): - raise APIError(status_code=500, detail="Email failed to send") + error = response.get("error") or "Email failed to send" + raise APIError(status_code=500, detail=error) def upload_metric(self, metric_name: str, timestamp: str, metric_data: Dict[str, Any]): From 31064f62d38f2ec476a0cea5b7e20e231eccce75 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Wed, 10 Apr 2024 01:34:49 +0000 Subject: [PATCH 06/12] Increment Version to 0.0.2a3 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index d2529a5..fd8a88a 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.2a2" +__version__ = "0.0.2a3" From abfdb2dcd5fe3350a3b6fb9e30e2f14565c9426e Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Mon, 6 May 2024 13:44:10 -0700 Subject: [PATCH 07/12] Fix kwarg handling for backend compat. (#22) # Description Fix `unit`/`units` compat. issue with API proxy service # Issues # Other Notes As noted [on Matrix](https://matrix.to/#/!ZhEZYNzKBfpEAhtQIz:matrix.org/$FunTJOligMlv8gr_ewqKKaMOrTKje7RaK6xiFeC0cEc?via=matrix.org&via=nitro.chat&via=rx.haunted.computer) Co-authored-by: Daniel McKnight --- neon_hana/mq_service_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neon_hana/mq_service_api.py b/neon_hana/mq_service_api.py index ddd7dfa..032e800 100644 --- a/neon_hana/mq_service_api.py +++ b/neon_hana/mq_service_api.py @@ -92,6 +92,9 @@ def get_session(self, node_data: NodeData) -> dict: def query_api_proxy(self, service_name: str, query_params: dict, timeout: int = 10): query_params['service'] = service_name + if service_name in ("open_weather_map", "wolfram_alpha"): + query_params['units'] = query_params.pop('unit', + query_params.get('units')) response = send_mq_request("/neon_api", query_params, "neon_api_input", "neon_api_output", timeout) return self._validate_api_proxy_response(response, query_params) From 79ea637251416902fd39a368c7a048de9a21d583 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Mon, 6 May 2024 20:44:27 +0000 Subject: [PATCH 08/12] Increment Version to 0.0.2a4 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index fd8a88a..4b63ed1 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.2a3" +__version__ = "0.0.2a4" From 777c8d5782a8f29a65a208b49d514ad983f219f5 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Mon, 6 May 2024 13:51:00 -0700 Subject: [PATCH 09/12] Update config documentation and resolve security warning (#24) # Description Update example config to include all options Update requirements to resolve dependabot warning # Issues # Other Notes Co-authored-by: Daniel McKnight --- README.md | 2 ++ requirements/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02e3cd1..54cf77c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ User configuration belongs in `diana.yaml`, mounted in the container path MQ: server: mq.mydomain.com hana: + server_host: '0.0.0.0' + port: 8080 mq_default_timeout: 10 access_token_ttl: 86400 # 1 day refresh_token_ttl: 604800 # 1 week diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 1948175..0e5f1c8 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,5 +1,5 @@ pyyaml>=5.4,<7.0 -fastapi~=0.95 +fastapi~=0.95,>=0.109.1 uvicorn~=0.25 pydantic~=2.5 pyjwt~=2.8 From 0da236ea952edefb985730312fcf40661593edbe Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Mon, 6 May 2024 20:51:15 +0000 Subject: [PATCH 10/12] Increment Version to 0.0.2a5 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index 4b63ed1..f338673 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.2a4" +__version__ = "0.0.2a5" From ff26579c6d06ed59d068a1666aa2c1b44d529f33 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Mon, 6 May 2024 21:13:20 +0000 Subject: [PATCH 11/12] Increment Version to 0.1.0 --- neon_hana/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neon_hana/version.py b/neon_hana/version.py index f338673..4488dcb 100644 --- a/neon_hana/version.py +++ b/neon_hana/version.py @@ -26,4 +26,4 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -__version__ = "0.0.2a5" +__version__ = "0.1.0" From c57270bdcd899fbd769d4a0841612dd1064b4937 Mon Sep 17 00:00:00 2001 From: NeonDaniel Date: Mon, 6 May 2024 21:13:45 +0000 Subject: [PATCH 12/12] Update Changelog --- CHANGELOG.md | 55 ++++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 135f22d..89d7bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,69 +1,52 @@ # Changelog -## [0.0.1a9](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a9) (2024-02-26) +## [0.0.2a5](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.2a5) (2024-05-06) -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a8...0.0.1a9) +[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.2a4...0.0.2a5) **Merged pull requests:** -- Cleanup comments and prep for release [\#13](https://github.com/NeonGeckoCom/neon-hana/pull/13) ([NeonDaniel](https://github.com/NeonDaniel)) +- Update config documentation and resolve security warning [\#24](https://github.com/NeonGeckoCom/neon-hana/pull/24) ([NeonDaniel](https://github.com/NeonDaniel)) -## [0.0.1a8](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a8) (2024-01-26) +## [0.0.2a4](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.2a4) (2024-05-06) -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a7...0.0.1a8) +[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.2a3...0.0.2a4) **Merged pull requests:** -- Update to use client-provided public IP address when available [\#12](https://github.com/NeonGeckoCom/neon-hana/pull/12) ([NeonDaniel](https://github.com/NeonDaniel)) +- Fix kwarg handling for backend compat. [\#22](https://github.com/NeonGeckoCom/neon-hana/pull/22) ([NeonDaniel](https://github.com/NeonDaniel)) -## [0.0.1a7](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a7) (2024-01-26) +## [0.0.2a3](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.2a3) (2024-04-10) -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a6...0.0.1a7) +[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.2a2...0.0.2a3) **Merged pull requests:** -- Add Node data model and Session support [\#11](https://github.com/NeonGeckoCom/neon-hana/pull/11) ([NeonDaniel](https://github.com/NeonDaniel)) +- Include email API error responses in HTTP response [\#19](https://github.com/NeonGeckoCom/neon-hana/pull/19) ([NeonDaniel](https://github.com/NeonDaniel)) -## [0.0.1a6](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a6) (2024-01-26) +## [0.0.2a2](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.2a2) (2024-04-10) -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a5...0.0.1a6) +[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.2a1...0.0.2a2) -**Merged pull requests:** - -- Configurable Authorization Request Limits [\#9](https://github.com/NeonGeckoCom/neon-hana/pull/9) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [0.0.1a5](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a5) (2024-01-23) +**Implemented enhancements:** -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a4...0.0.1a5) +- \[FEAT\] Weather API Language Support [\#15](https://github.com/NeonGeckoCom/neon-hana/issues/15) **Merged pull requests:** -- JWT server cache fix and client response update [\#8](https://github.com/NeonGeckoCom/neon-hana/pull/8) ([NeonDaniel](https://github.com/NeonDaniel)) +- Add `lang_code` optional param to weather endpoint [\#18](https://github.com/NeonGeckoCom/neon-hana/pull/18) ([NeonDaniel](https://github.com/NeonDaniel)) -## [0.0.1a4](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a4) (2024-01-22) - -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a3...0.0.1a4) - -**Merged pull requests:** - -- Default disable email service with note in docs explaining rationale [\#4](https://github.com/NeonGeckoCom/neon-hana/pull/4) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [0.0.1a3](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a3) (2024-01-22) - -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1a2...0.0.1a3) - -**Merged pull requests:** +## [0.0.2a1](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.2a1) (2024-04-09) -- Add `assist` route for HTTP requests [\#3](https://github.com/NeonGeckoCom/neon-hana/pull/3) ([NeonDaniel](https://github.com/NeonDaniel)) +[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/0.0.1...0.0.2a1) -## [0.0.1a2](https://github.com/NeonGeckoCom/neon-hana/tree/0.0.1a2) (2024-01-19) +**Implemented enhancements:** -[Full Changelog](https://github.com/NeonGeckoCom/neon-hana/compare/885ec6ef0f8ddcaa8127f60730ef7b4011127554...0.0.1a2) +- \[FEAT\] Stock API region support [\#16](https://github.com/NeonGeckoCom/neon-hana/issues/16) **Merged pull requests:** -- Fix path errors in test build automation [\#2](https://github.com/NeonGeckoCom/neon-hana/pull/2) ([NeonDaniel](https://github.com/NeonDaniel)) -- Initial Implementation [\#1](https://github.com/NeonGeckoCom/neon-hana/pull/1) ([NeonDaniel](https://github.com/NeonDaniel)) +- Support `region` in stock search requests [\#17](https://github.com/NeonGeckoCom/neon-hana/pull/17) ([NeonDaniel](https://github.com/NeonDaniel))