File tree Expand file tree Collapse file tree 4 files changed +13
-8
lines changed
src/seclab_taskflow_agent Expand file tree Collapse file tree 4 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: GitHub, Inc.
22# SPDX-License-Identifier: MIT
3- __version__ = "0.2 .0"
3+ __version__ = "0.3 .0"
Original file line number Diff line number Diff line change 1414import json
1515import logging
1616import os
17+ from collections .abc import Mapping
1718from dataclasses import dataclass , field
1819from types import MappingProxyType
1920from typing import Any
@@ -47,11 +48,15 @@ class APIProvider:
4748 base_url : str
4849 models_catalog : str = "models"
4950 default_model : str = "gpt-4.1"
50- extra_headers : dict [str , str ] = field (default_factory = dict )
51+ extra_headers : Mapping [str , str ] = field (default_factory = dict )
5152
5253 def __post_init__ (self ) -> None :
54+ # Ensure base_url ends with / so httpx URL.join() preserves the path
55+ if self .base_url and not self .base_url .endswith ("/" ):
56+ object .__setattr__ (self , "base_url" , self .base_url + "/" )
5357 # Freeze mutable headers so singleton providers can't be mutated
54- object .__setattr__ (self , "extra_headers" , MappingProxyType (self .extra_headers ))
58+ if isinstance (self .extra_headers , dict ):
59+ object .__setattr__ (self , "extra_headers" , MappingProxyType (self .extra_headers ))
5560
5661 # -- response parsing -----------------------------------------------------
5762
Original file line number Diff line number Diff line change @@ -41,9 +41,9 @@ def test_api_endpoint_env_override(self):
4141
4242 def test_provider_base_urls (self ):
4343 """Test that providers resolve to expected base URLs."""
44- assert get_provider ("https://models.github.ai/inference" ).base_url == "https://models.github.ai/inference"
45- assert get_provider ("https://api.githubcopilot.com" ).base_url == "https://api.githubcopilot.com"
46- assert get_provider ("https://api.openai.com/v1" ).base_url == "https://api.openai.com/v1"
44+ assert get_provider ("https://models.github.ai/inference" ).base_url == "https://models.github.ai/inference/ "
45+ assert get_provider ("https://api.githubcopilot.com" ).base_url == "https://api.githubcopilot.com/ "
46+ assert get_provider ("https://api.openai.com/v1" ).base_url == "https://api.openai.com/v1/ "
4747
4848 def test_unsupported_endpoint (self , monkeypatch ):
4949 """Test that unsupported API endpoint falls back gracefully."""
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ class TestGetProvider:
104104 def test_copilot_provider (self ):
105105 p = get_provider ("https://api.githubcopilot.com" )
106106 assert p .name == "copilot"
107- assert p .base_url == "https://api.githubcopilot.com"
107+ assert p .base_url == "https://api.githubcopilot.com/ "
108108 assert "Copilot-Integration-Id" in p .extra_headers
109109
110110 def test_github_models_provider (self ):
@@ -121,5 +121,5 @@ def test_openai_provider(self):
121121 def test_custom_endpoint (self ):
122122 p = get_provider ("https://my-custom-llm.example.com/v1" )
123123 assert p .name == "custom"
124- assert p .base_url == "https://my-custom-llm.example.com/v1"
124+ assert p .base_url == "https://my-custom-llm.example.com/v1/ "
125125 assert not p .extra_headers
You can’t perform that action at this time.
0 commit comments