112 Commits

Author SHA1 Message Date
Hemang 1b08b8fb66 fix: removing gemini from litellm for now, it is breaking 2025-11-06 12:19:46 +01:00
Hemang a6bed68aa5 Update gemini model name for litellm 2025-11-06 11:46:20 +01:00
Hemang 44ffbb0ee6 fix: broken anthropic tests 2025-11-06 11:32:33 +01:00
Hemang a5fe02bdf2 Change gemini-2.0-flash to gemini-2.5-flash 2025-11-06 11:06:31 +01:00
Luca Beurer-Kellner 6e7106ea26 fix: update anthropic model 2025-11-06 09:39:30 +01:00
Luca Beurer-Kellner 5ad89808a1 try: remove anthropic tests 2025-11-06 09:31:25 +01:00
Hemang 39cde09249 Fix broken Gemini tests. 2025-07-09 16:54:17 +02:00
Kristian Nielsen e0980d2661 add timestamps (#66) 2025-06-26 19:38:20 +02:00
Hemang df33199343 Use tenacity.RetryError instead of genai.errors.ClientError for gemini guardrailing errors. 2025-06-19 13:22:22 +02:00
Hemang 9f564a0401 Refactor the LLM provider routes to move common functionalities into a BaseInstrumentedResponse class and move provier specific implementations in the corresponding BaseProvider implementations. 2025-06-12 14:07:11 +02:00
Hemang 42a9c1cc30 Readability changes. 2025-06-05 11:58:12 +02:00
Hemang da03dbe7c5 Move is_stateless_http_server metadata assignment to the Streamable route from the common metadata method. 2025-06-04 14:19:19 +02:00
Hemang cc3e96c20a Clean up MCP tests and clients. 2025-06-04 11:46:35 +02:00
Hemang e8106776b4 Refactor stdio implementation to use McpSession class. 2025-06-04 11:46:35 +02:00
Hemang 96826fa06d Cleanup some code in test_mcp.py 2025-05-27 23:11:57 +02:00
Hemang ab3fb98b67 Add blocking and logging related tests for MCP streamable HTTP route. 2025-05-27 23:11:57 +02:00
Hemang 115ae5f36b Add tests for MCP streamable HTTP route for json/sse and stateless/stateful servers. 2025-05-27 23:11:57 +02:00
Hemang 6e61a76168 Add blocking and logging of guardrails for MCP Streamable http route. 2025-05-27 23:11:57 +02:00
Hemang f8bf7be405 Add mcp_streamable route and refactor some common code between sse and streamable. Update tests for 400 errors in sse. 2025-05-27 23:11:57 +02:00
Hemang 03817b005c Update metadata in MCP SSE similar to what we do in MCP stdio. 2025-05-21 22:45:59 +02:00
Hemang 169eb066b9 Small cleanups in sse and stdio MCP implementation. 2025-05-21 15:58:22 +02:00
Luca Beurer-Kellner e18c6b5bdb Add an option to add extra metadata that is pushed and passed to Guardrails during an MCP session (#47)
* use select() before readline

* support for setting static metadata for MCP sessions

* nest extra mcp metadata in metadata object

* unify session metadata

* extra metadata tests

* use empty object as parameters, if None

* list_tools as tool call

* offset indices in tests

* test: adjust addresses

* mcp: make error reporting configurable

* line logging

* log version

* verbose logging + loud exception failure

* add server and client name to policy get

* append trace even if not pushing

* port tools/list message support to SSE

* use python -m build

* adjust guardrail failure address

* support for blocking tools/list in SSE

* use error-based failure response format by default

* tools/list test

* don't list_tools in stdio connect

* flaky test: handle second possible result in anthropic streaming case

---------

Co-authored-by: knielsen404 <kristian@invariantlabs.ai>
2025-05-19 13:44:37 +02:00
Hemang 780e5f6ee7 Skip test_generate_content_with_image for gemini. Getting 500. 2025-05-16 14:33:00 +05:30
Hemang 876eb44c78 Make MCP stdio gateway fully async. With sync and async mixed behaviour for running background tasks we were running into issues. 2025-05-16 14:33:00 +05:30
Hemang Sarkar a6c1124076 Update test_mcp.py 2025-05-15 15:00:31 +05:30
Hemang Sarkar 0ffde69391 Fix test_mcp_sse_with_gateway_hybrid_guardrails so that we don't rely on order of annotations. 2025-05-15 15:00:31 +05:30
Hemang Sarkar fefc22eea0 Update test_mcp.py to include the transport parameter in the hybrid guardrails test. 2025-05-14 15:32:05 +02:00
Hemang ed50670bef Add MCP gateway tests with hybrid guardrails (both blocking and logging). Also refactor tests so that we can parameterize the transport type - stdio or sse. 2025-05-14 18:05:14 +05:30
Hemang 8eae198eb0 Add integration tests for MCP SSE via gateway with guardrails. 2025-05-14 14:21:48 +05:30
Hemang e2e004b7b1 Move dockerfiles inside gateway/ and update main CLI script to be able to run build, up, down and logs on a local gateway server instance. 2025-05-14 14:21:48 +05:30
Hemang dbab86e0ac Fix broken tests. 2025-05-09 12:17:14 +05:30
Hemang 132eedab0a Update tests_ci.yml so that the CI run fails even when unit tests fail. 2025-05-07 02:03:06 +05:30
Hemang d057aa5c37 Add httpx as unit test dependencies. 2025-05-07 01:27:13 +05:30
Hemang 1f6e2ed7fb Update streaming in anthropic route to handle chunks with incomplete events. Introduce an sse_buffer which keeps track of the current incomplete event from the last processed chunk. 2025-05-07 01:08:15 +05:30
Hemang aec7808e3e Fix broken integration tests. 2025-05-07 01:08:15 +05:30
Hemang dc9ac9c3c6 Fix broken unit tests. 2025-05-07 01:08:15 +05:30
Hemang 88ba17a803 Move MCP testing stdio server and client into a separate folder. 2025-04-29 15:56:37 +05:30
Hemang dbeb4bc660 Add blocking guardrails based test for MCP gateway. 2025-04-29 09:00:04 +02:00
Hemang d877e5a1e6 Add logging guardrails based test for MCP gateway. 2025-04-29 09:00:04 +02:00
Hemang d983b7431b Add tests for MCP integration in gateway. 2025-04-29 09:00:04 +02:00
Hemang 5bf121bbda Use pyproject.toml instead of requirements.txt and fix some broken tests. 2025-04-17 07:15:28 +02:00
Luca Beurer-Kellner c4dd3f3b19 Allow to specify different API keys for the guardrailing service (#36)
* minor refactor for getting invariant api keys for guardrailing

* allow different guardrailing api key

* tests

* fix comment + import

* improved unauthorized handling
2025-04-03 12:15:30 +02:00
Luca Beurer-Kellner e17b53b927 Extract guardrails from header if provided (#33)
* guardrails from header

* use in-file guardrails in client.py

* support case without request

* remove client script

* tests: guardrailing rule passed in header

* include checked guardrails in annotation extra metadata

* include guardrailing action

* update guardrail metadata
2025-04-03 08:56:15 +02:00
Marco Milanta 37005c03be fix: add tests (and found bug) 2025-04-02 16:03:51 +02:00
Marco Milanta 7b6d77e0a5 feat: add litellm support 2025-04-02 15:22:39 +02:00
Hemang f3a56e1e43 Add preguardrailing tests for guardrails pulled from explorer. 2025-04-02 13:40:52 +02:00
Hemang 55f0f741c0 Add tests for guardrails integration with explorer. 2025-04-02 13:40:52 +02:00
Hemang eced3755b2 Refactor tests. 2025-04-02 13:40:52 +02:00
Hemang 750c83d3f8 Add calls to execute logging guardrails before pushing to explorer. 2025-04-02 13:40:52 +02:00
Hemang 050ec1ba58 Fetch guardrails from explorer. These have higher precedence than than the guardrails from file. 2025-04-02 13:40:52 +02:00