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
a214837b1e
Add message to session store for MCP sse in post path before returning.
2025-05-14 15:44:52 +02:00
Hemang
edd9fd9a5c
When tool_call is blocked in MCP Post method, add the error message to a pending error messages list. Create two queues in the MCP SSE Get endpoint which correspond to the MCP server events and these pending error messages. These two queues are merged to return events back to the client.
2025-05-09 11:05:33 +05:30
Hemang
794aae0326
Add MCP guardrailing for SSE.
2025-05-08 20:40:28 +05:30
Hemang
40ec6d2db2
Add MCP SSE server proxying in gateway.
2025-05-08 14:11:22 +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
2c34205c4c
Fix asyncio and threading. Dedupe annotations before pushing. Add README.
2025-04-17 07:15:28 +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 and GitHub
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 and GitHub
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
Hemang
6d3366b91b
Add OPTIONS preflight support for routes.
2025-04-02 22:42:22 +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
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
Hemang
f45a973f51
Small formatting changes.
2025-04-02 13:40:52 +02:00
Luca Beurer-Kellner and GitHub
7c0bb957fb
Pipelined Guardrails ( #32 )
...
* initial draft: pipelined guardrails
* documentation on stream instrumentation
* more comments
* fix: return earlier
* non-streaming case
* handle non-streaming case
* fix more cases
* simplify request instrumentation
* improve comments
* fix import issues
* extend tests for input guardrailing
* anthropic integration of pipelined and pre-guardrailing
* fix gemini streamed refusal
2025-03-31 14:13:58 +02:00
Hemang
e55df73487
Add guardrails for gemini integration.
2025-03-27 12:26:17 +01:00
Hemang
8191c83c12
Revert "Add debug logs for metadata push."
...
This reverts commit f247682fa3 .
2025-03-26 19:57:00 +01:00
Hemang
f247682fa3
Add debug logs for metadata push.
2025-03-26 15:20:26 +01:00
Hemang
c9cdbd7eb5
Update metadata for gemini streaming case.
2025-03-25 11:49:07 +01:00
Hemang
3df9e73249
Add some tests for the Anthropic conversion functions. Add support for system message in Anthropic. Rename some variables.
2025-03-21 00:56:52 +01:00
Hemang
4a9930c30d
Add guardrails checks for Anthropic.
2025-03-21 00:56:52 +01:00
Hemang
781c6224d9
Anthropic with stream=False complains about content-length not matching with the response size.
2025-03-20 10:59:27 +01:00
Hemang
a4ee5f0c47
Add metadata before pushing to Explorer.
2025-03-20 10:59:27 +01:00
Hemang
ab3169938d
Add preload guardrails api call for anthropic and gemini.
2025-03-19 09:51:56 +01:00
Hemang
44988c3535
Add a preload guardrails API call.
2025-03-19 09:39:23 +01:00
Hemang
5dc9485831
Remove tool_calls modification before calling guardrails service.
2025-03-18 14:46:22 +01:00
Hemang
66973dbf30
Handle streaming with openai for guardrails. Only check guardrails on the last stream chunk.
2025-03-17 15:09:14 +01:00
Hemang
ca3c43ef76
Refactor guardrails check for openai route.
2025-03-17 07:45:45 +01:00
Hemang
a5ea86a64e
Show logs if the docker container doesn't start on doing up(). Tested when the guardrails file contained unparseable policy.
2025-03-17 07:45:45 +01:00
Hemang
e773cc9f2d
Add Guardrails verification logic for openai route.
2025-03-17 07:45:45 +01:00
Hemang
2fe0f55cb3
Don't block on push to explorer call for the routes.
2025-03-10 17:25:39 +01:00
Hemang
7d96ae7af3
Refactor Anthropic code to use RequestContextData
2025-03-10 15:45:30 +01:00
Hemang
20f8a12032
Formatting changes.
2025-03-10 15:18:13 +01:00
Hemang
5a6dd5c813
Add push to explorer support for Gemini while streaming.
2025-03-10 15:18:13 +01:00
Hemang
1e5a5ccd28
Add endpoint to push to explorer. Update image handling with gemini.
2025-03-10 15:18:13 +01:00
Hemang
7576f245bd
Add a converter module to house conversion from different LLM provider formats to Invariant API format.
2025-03-10 15:18:13 +01:00
Hemang
38504b3e45
Rename utils.explorer to integrations.explorer. The integrations module will contain API calls.
2025-03-10 15:18:13 +01:00
Hemang
e107be4fea
Add push to explorer support for Gemini for non streaming.
2025-03-10 15:18:13 +01:00
Hemang Sarkar and GitHub
adfabd5b12
Update the format where the user passes the invariant key in the llm provider key header. ( #18 )
2025-03-06 10:57:32 +01:00
Hemang
7008f73310
Rename proxy to gateway.
2025-03-05 14:35:39 +01:00