From 69a75b9329dbfb187412e1409aa4f8bc307bb382 Mon Sep 17 00:00:00 2001 From: Nirupam Bhowmick <48842933+heydryft@users.noreply.github.com> Date: Sun, 1 Nov 2026 10:42:10 +0000 Subject: [PATCH] feat: add Runcrate preset to LLM specs --- agentic_security/routes/_specs.py | 12 +++++++++ agentic_security/static/base.js | 13 ++++++++++ tests/unit/test_runcrate_spec.py | 42 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/unit/test_runcrate_spec.py diff --git a/agentic_security/routes/_specs.py b/agentic_security/routes/_specs.py index 52446a5..34b334e 100644 --- a/agentic_security/routes/_specs.py +++ b/agentic_security/routes/_specs.py @@ -175,6 +175,17 @@ Content-Type: application/json "frequency_penalty": 0, "presence_penalty": 0 } +""", + """POST https://api.runcrate.ai/v1/chat/completions +Authorization: Bearer $RUNCRATE_API_KEY +Content-Type: application/json + +{ +"model": "deepseek-ai/DeepSeek-V4-Flash", +"messages": [ +{"role": "user", "content": "<>"} +] +} """, ] @@ -392,6 +403,7 @@ LLM_CONFIGS = [ {"name": "Azure OpenAI", "prompts": 40000, "logo": "/icons/azureai.png"}, {"name": "assemblyai", "prompts": 40000, "logo": "/icons/myshell.png"}, {"name": "OpenRouter.ai", "prompts": 40000, "logo": "/icons/openrouter.png"}, + {"name": "Runcrate", "prompts": 40000, "logo": "/icons/myshell.png"}, ] LLM_SPECS = [dict(spec=spec, **d) for spec, d in zip(_SPECS, LLM_CONFIGS)] diff --git a/agentic_security/static/base.js b/agentic_security/static/base.js index ee5166d..0afcb24 100644 --- a/agentic_security/static/base.js +++ b/agentic_security/static/base.js @@ -185,6 +185,18 @@ Content-Type: application/json "frequency_penalty": 0, "presence_penalty": 0 } +`, + + `POST https://api.runcrate.ai/v1/chat/completions +Authorization: Bearer $RUNCRATE_API_KEY +Content-Type: application/json + +{ +"model": "deepseek-ai/DeepSeek-V4-Flash", +"messages": [ +{"role": "user", "content": "<>"} +] +} `, ] @@ -206,6 +218,7 @@ let LLM_CONFIGS = [ { name: 'Azure OpenAI', prompts: 40000, logo: '/icons/azureai.png' }, { name: 'assemblyai', prompts: 40000, logo: fallbackIcon }, { name: 'OpenRouter.ai', prompts: 40000, logo: '/icons/openrouter.png' }, + { name: 'Runcrate', prompts: 40000, logo: fallbackIcon }, ]; function has_image(spec) { diff --git a/tests/unit/test_runcrate_spec.py b/tests/unit/test_runcrate_spec.py new file mode 100644 index 0000000..93b372b --- /dev/null +++ b/tests/unit/test_runcrate_spec.py @@ -0,0 +1,42 @@ +import json + +import httpx +import pytest + +from agentic_security.http_spec import LLMSpec, Modality +from agentic_security.routes._specs import LLM_SPECS + + +def runcrate_spec() -> LLMSpec: + entry = next(item for item in LLM_SPECS if item["name"] == "Runcrate") + return LLMSpec.from_string(entry["spec"]) + + +def test_runcrate_preset_parses_to_chat_completions(): + spec = runcrate_spec() + + assert spec.method == "POST" + assert spec.url == "https://api.runcrate.ai/v1/chat/completions" + assert spec.headers["Authorization"] == "Bearer $RUNCRATE_API_KEY" + assert spec.model_name == "deepseek-ai/DeepSeek-V4-Flash" + assert spec.modality == Modality.TEXT + + +@pytest.mark.asyncio +async def test_runcrate_preset_probe_sends_prompt_as_user_message(monkeypatch): + captured = {} + + async def fake_request(self, method, url, headers=None, content=None, timeout=None): + captured.update(method=method, url=url, content=content) + return httpx.Response(200, json={"choices": [{"message": {"content": "ok"}}]}) + + monkeypatch.setattr(httpx.AsyncClient, "request", fake_request) + + response = await runcrate_spec().probe('Say "hi"') + + assert response.status_code == 200 + assert captured["method"] == "POST" + assert captured["url"] == "https://api.runcrate.ai/v1/chat/completions" + body = json.loads(captured["content"]) + assert body["model"] == "deepseek-ai/DeepSeek-V4-Flash" + assert body["messages"] == [{"role": "user", "content": 'Say "hi"'}]