Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/seclab_taskflow_agent/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""AI API endpoint and token management.

Supports multiple API providers (GitHub Copilot, GitHub Models, OpenAI, and
Supports multiple API providers (GitHub Copilot, OpenAI, and
custom endpoints). All provider-specific behaviour is captured in a single
``APIProvider`` dataclass so that adding a new provider only requires one
registry entry instead of changes scattered across multiple match/case blocks.
Expand Down Expand Up @@ -91,19 +91,6 @@ def check_tool_calls(self, _model: str, model_info: dict) -> bool:
)


class _GitHubModelsProvider(APIProvider):
"""GitHub Models API (models.github.ai)."""

def parse_models_list(self, body: Any) -> list[dict]:
# Models API returns a bare list, not {"data": [...]}
if isinstance(body, list):
return body
return super().parse_models_list(body)

def check_tool_calls(self, _model: str, model_info: dict) -> bool:
return "tool-calling" in model_info.get("capabilities", [])


class _OpenAIProvider(APIProvider):
"""OpenAI API (api.openai.com).

Expand All @@ -127,12 +114,6 @@ def check_tool_calls(self, _model: str, model_info: dict) -> bool:
default_model="gpt-4.1",
extra_headers={"Copilot-Integration-Id": COPILOT_INTEGRATION_ID},
),
"models.github.ai": _GitHubModelsProvider(
name="github-models",
base_url="https://models.github.ai/inference",
models_catalog="/catalog/models",
default_model="openai/gpt-4.1",
),
"api.openai.com": _OpenAIProvider(
name="openai",
base_url="https://api.openai.com/v1",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_api_endpoint_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestAPIEndpoint:
"""Test API endpoint configuration."""

def test_default_api_endpoint(self):
"""Test that default API endpoint is set to models.github.ai/inference."""
"""Test that the default API endpoint is GitHub Copilot."""
try:
original_env = os.environ.pop("AI_API_ENDPOINT", None)
endpoint = get_AI_endpoint()
Expand All @@ -41,7 +41,6 @@ def test_api_endpoint_env_override(self):

def test_provider_base_urls(self):
"""Test that providers resolve to expected base URLs."""
assert get_provider("https://models.github.ai/inference").base_url == "https://models.github.ai/inference/"
assert get_provider("https://api.githubcopilot.com").base_url == "https://api.githubcopilot.com/"
assert get_provider("https://api.openai.com/v1").base_url == "https://api.openai.com/v1/"

Expand Down
28 changes: 0 additions & 28 deletions tests/test_capi_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,6 @@ def test_copilot_endpoint_without_capabilities(self, monkeypatch):
}
assert supports_tool_calls("text-only", models) is False

def test_models_github_endpoint(self, monkeypatch):
"""models.github.ai checks for 'tool-calling' in capabilities list."""
monkeypatch.setenv("AI_API_ENDPOINT", "https://models.github.ai/inference")
models = {
"openai/gpt-4o": {
"id": "openai/gpt-4o",
"capabilities": ["tool-calling", "chat"],
}
}
assert supports_tool_calls("openai/gpt-4o", models) is True

def test_models_github_endpoint_no_tool_calling(self, monkeypatch):
"""models.github.ai returns False when 'tool-calling' not in list."""
monkeypatch.setenv("AI_API_ENDPOINT", "https://models.github.ai/inference")
models = {
"some-model": {
"id": "some-model",
"capabilities": ["chat"],
}
}
assert supports_tool_calls("some-model", models) is False

def test_openai_endpoint_model_in_catalog(self, monkeypatch):
"""OpenAI endpoint returns True for known chat model families."""
monkeypatch.setenv("AI_API_ENDPOINT", "https://api.openai.com/v1")
Expand Down Expand Up @@ -118,12 +96,6 @@ def test_copilot_provider(self):
assert p.base_url == "https://api.githubcopilot.com/"
assert "Copilot-Integration-Id" in p.extra_headers

def test_github_models_provider(self):
p = get_provider("https://models.github.ai/inference")
assert p.name == "github-models"
assert p.models_catalog == "/catalog/models"
assert p.default_model == "openai/gpt-4.1"

def test_openai_provider(self):
p = get_provider("https://api.openai.com/v1")
assert p.name == "openai"
Expand Down
5 changes: 1 addition & 4 deletions tests/test_sdk_anthropic_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,12 @@ def test_call_tool_result_to_text_preserves_empty_among_nonempty():


def test_known_provider_uses_bearer_auth():
"""Known providers (CAPI, GitHub Models) should have bearer_auth=True."""
"""Known providers like CAPI should have bearer_auth=True."""
from seclab_taskflow_agent.capi import get_provider

provider = get_provider("https://api.githubcopilot.com")
assert provider.bearer_auth is True
Comment on lines 224 to 229

provider = get_provider("https://models.github.ai/inference")
assert provider.bearer_auth is True


def test_unknown_endpoint_uses_native_auth():
"""Unknown endpoints should default to native SDK auth (bearer_auth=False)."""
Expand Down