Skip to content

Commit f3a0434

Browse files
authored
Merge pull request #20 from airlock-protocol/worktree-agent-acc3f57a
chore: bump to v1.0.0 and make litellm optional
2 parents 6760e43 + 56de062 commit f3a0434

4 files changed

Lines changed: 39 additions & 9 deletions

File tree

airlock/gateway/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
281281
app = FastAPI(
282282
title="Agentic Airlock",
283283
description="Open agent-to-agent trust and identity verification protocol",
284-
version="0.4.0",
284+
version="1.0.0",
285285
lifespan=lifespan,
286286
)
287287

airlock/semantic/challenge.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
from airlock.schemas.envelope import MessageEnvelope, generate_nonce
1919
from airlock.schemas.identity import AgentCapability
2020

21+
try:
22+
import litellm
23+
24+
_HAS_LITELLM = True
25+
except ImportError:
26+
litellm = None # type: ignore[assignment]
27+
_HAS_LITELLM = False
28+
2129
_CONTROL_CHAR_RE = re.compile(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]")
2230
_MAX_ANSWER_LENGTH = 2000
2331

@@ -347,9 +355,11 @@ async def _generate_question(
347355

348356
prompt = _GENERATION_PROMPT.format(capabilities=cap_text)
349357

350-
try:
351-
import litellm
358+
if not _HAS_LITELLM:
359+
logger.info("litellm not installed, using fallback question")
360+
return _select_fallback_question(session_id, capabilities)
352361

362+
try:
353363
kwargs: dict[str, Any] = {
354364
"model": model,
355365
"messages": [{"role": "user", "content": prompt}],
@@ -358,7 +368,7 @@ async def _generate_question(
358368
if api_base:
359369
kwargs["api_base"] = api_base
360370

361-
response = await asyncio.wait_for(litellm.acompletion(**kwargs), timeout=30)
371+
response = await asyncio.wait_for(litellm.acompletion(**kwargs), timeout=30) # type: ignore[union-attr]
362372
raw = response.choices[0].message.content
363373
question = (raw or "").strip()
364374
if question:
@@ -547,9 +557,10 @@ async def _evaluate_with_llm(
547557
prompt_template = _EVALUATION_PROMPT_STRUCTURED if use_structured else _EVALUATION_PROMPT
548558
prompt = prompt_template.format(question=question, answer=answer)
549559

550-
try:
551-
import litellm
560+
if not _HAS_LITELLM:
561+
return ChallengeOutcome.AMBIGUOUS, "LLM evaluation unavailable (litellm not installed)"
552562

563+
try:
553564
kwargs: dict[str, Any] = {
554565
"model": model,
555566
"messages": [{"role": "user", "content": prompt}],
@@ -562,7 +573,7 @@ async def _evaluate_with_llm(
562573
if use_structured:
563574
kwargs["response_format"] = {"type": "json_object"}
564575

565-
response = await asyncio.wait_for(litellm.acompletion(**kwargs), timeout=30)
576+
response = await asyncio.wait_for(litellm.acompletion(**kwargs), timeout=30) # type: ignore[union-attr]
566577
raw = response.choices[0].message.content
567578
content = (raw or "").strip()
568579
if not content:

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ packages = ["airlock"]
1010

1111
[project]
1212
name = "airlock-protocol"
13-
version = "0.4.0"
13+
version = "1.0.0"
1414
description = "An open protocol for agent-to-agent trust verification"
1515
readme = "README.md"
1616
license = { file = "LICENSE" }
@@ -39,7 +39,6 @@ dependencies = [
3939
"httpx>=0.27.0",
4040
"langgraph>=0.2.0,<1.0",
4141
"lancedb>=0.17.0,<1.0",
42-
"litellm>=1.50.0,<2.0",
4342
"pyarrow>=17.0.0",
4443
"PyJWT>=2.8.0,<3.0",
4544
"click>=8.1.0,<9.0",
@@ -81,6 +80,9 @@ openai = [
8180
anthropic = [
8281
"anthropic>=0.30.0",
8382
]
83+
llm = [
84+
"litellm>=1.50.0,<2.0",
85+
]
8486

8587
[tool.ruff]
8688
target-version = "py311"

tests/test_litellm_optional.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Verify app works without litellm installed."""
2+
from __future__ import annotations
3+
4+
from airlock.config import AirlockConfig
5+
6+
7+
class TestLitellmOptional:
8+
def test_config_loads(self) -> None:
9+
cfg = AirlockConfig()
10+
assert cfg.env == "development"
11+
12+
def test_app_creates(self) -> None:
13+
from airlock.gateway.app import create_app
14+
15+
app = create_app()
16+
assert app is not None
17+
assert app.version == "1.0.0"

0 commit comments

Comments
 (0)