mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-07-08 11:57:52 +02:00
Use pyproject.toml instead of requirements.txt and fix some broken tests.
This commit is contained in:
@@ -24,8 +24,8 @@ services:
|
||||
invariant-gateway:
|
||||
container_name: invariant-gateway-test
|
||||
build:
|
||||
context: ${GATEWAY_PATH}
|
||||
dockerfile: ${GATEWAY_PATH}/Dockerfile.gateway
|
||||
context: ${GATEWAY_ROOT_PATH}
|
||||
dockerfile: ${GATEWAY_ROOT_PATH}/Dockerfile.gateway
|
||||
depends_on:
|
||||
app-api:
|
||||
condition: service_healthy
|
||||
@@ -38,7 +38,7 @@ services:
|
||||
- ${INVARIANT_API_KEY:+INVARIANT_API_KEY=${INVARIANT_API_KEY}}
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ${GATEWAY_PATH}
|
||||
source: ${GATEWAY_ROOT_PATH}/gateway
|
||||
target: /srv/gateway
|
||||
- type: bind
|
||||
source: ${GUARDRAILS_FILE_PATH:-/dev/null}
|
||||
|
||||
@@ -457,12 +457,12 @@ async def test_with_guardrails_from_explorer(explorer_api_url, gateway_url, do_s
|
||||
assert (
|
||||
annotations[0]["content"] == "ogre detected in response"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
)
|
||||
assert (
|
||||
annotations[1]["content"] == "Fiona detected in response"
|
||||
and annotations[1]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[1]["extra_metadata"]["guardrail-action"] == "log"
|
||||
and annotations[1]["extra_metadata"]["guardrail"]["action"] == "log"
|
||||
)
|
||||
|
||||
|
||||
@@ -584,7 +584,7 @@ async def test_preguardrailing_with_guardrails_from_explorer(
|
||||
assert (
|
||||
annotations[0]["content"] == "pun detected in user message"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
if is_block_action
|
||||
else "log"
|
||||
)
|
||||
|
||||
@@ -435,12 +435,12 @@ async def test_with_guardrails_from_explorer(explorer_api_url, gateway_url, do_s
|
||||
assert (
|
||||
annotations[0]["content"] == "ogre detected in response"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
)
|
||||
assert (
|
||||
annotations[1]["content"] == "Fiona detected in response"
|
||||
and annotations[1]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[1]["extra_metadata"]["guardrail-action"] == "log"
|
||||
and annotations[1]["extra_metadata"]["guardrail"]["action"] == "log"
|
||||
)
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ async def test_preguardrailing_with_guardrails_from_explorer(
|
||||
assert (
|
||||
annotations[0]["content"] == "pun detected in user message"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
if is_block_action
|
||||
else "log"
|
||||
)
|
||||
|
||||
@@ -457,12 +457,12 @@ async def test_with_guardrails_from_explorer(explorer_api_url, gateway_url, do_s
|
||||
assert (
|
||||
annotations[0]["content"] == "ogre detected in response"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
)
|
||||
assert (
|
||||
annotations[1]["content"] == "Fiona detected in response"
|
||||
and annotations[1]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[1]["extra_metadata"]["guardrail-action"] == "log"
|
||||
and annotations[1]["extra_metadata"]["guardrail"]["action"] == "log"
|
||||
)
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ async def test_preguardrailing_with_guardrails_from_explorer(
|
||||
assert (
|
||||
annotations[0]["content"] == "pun detected in user message"
|
||||
and annotations[0]["extra_metadata"]["source"] == "guardrails-error"
|
||||
and annotations[0]["extra_metadata"]["guardrail-action"] == "block"
|
||||
and annotations[0]["extra_metadata"]["guardrail"]["action"] == "block"
|
||||
if is_block_action
|
||||
else "log"
|
||||
)
|
||||
|
||||
@@ -7,10 +7,6 @@ import random
|
||||
import string
|
||||
import pytest
|
||||
|
||||
from gateway.common.config_manager import GatewayConfig
|
||||
from gateway.common.request_context import RequestContext
|
||||
|
||||
|
||||
# Add root folder (parent) to sys.path
|
||||
sys.path.append(
|
||||
os.path.dirname(
|
||||
@@ -18,6 +14,8 @@ sys.path.append(
|
||||
)
|
||||
)
|
||||
|
||||
from gateway.common.config_manager import GatewayConfig
|
||||
from gateway.common.request_context import RequestContext
|
||||
from gateway.common.authorization import (
|
||||
INVARIANT_GUARDRAIL_SERVICE_AUTHORIZATION_HEADER,
|
||||
extract_authorization_from_headers,
|
||||
|
||||
Reference in New Issue
Block a user