Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.
Python agent-evaluationaiai-alignmentai-evaluationai-governanceai-safetyclidiagnostic-tooleu-ai-acthallucination-detectioniso-42001llm-evaluationllm-securitynist-ai-rmfowasp-llmprompt-injectionpythonresponsible-airisk-assessmentrisk-management
from contextlib import asynccontextmanager
import pytest
from aiohttp import web
from ifixai.core.types import ChatMessage, ProviderConfig
from ifixai.providers.base import ProviderResponseError
from ifixai.providers.langchain import LangChainProvider
@asynccontextmanager
async def endpoint(payload):
async def invoke(request):
return web.json_response(payload)
app = web.Application()
app.router.add_post('/invoke', invoke)
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, '127.0.0.1', 0)
await site.start()
try:
yield f'http://127.0.0.1:{site._server.sockets[0].getsockname()[1]}'
finally:
await runner.cleanup()
@pytest.mark.asyncio
@pytest.mark.parametrize('payload,error', [({}, ProviderResponseError), ({'output': None}, ProviderResponseError), ({'output': {'content': None}}, ProviderResponseError), ({'output': {'content': 42}}, ProviderResponseError), ({'output': ''}, ProviderResponseError), ({'output': {'content': ''}}, ProviderResponseError)])
async def test_invalid_or_empty_output_does_not_become_model_answer(payload, error):
async with endpoint(payload) as url:
with pytest.raises(error) as exc:
await LangChainProvider().send_message([ChatMessage(content='hello')], ProviderConfig(provider='langchain', endpoint=url))
assert type(exc.value) is error