-
Notifications
You must be signed in to change notification settings - Fork 6
Change default API endpoint to models.github.ai/inference and rename COPILOT_API_ENDPOINT to AI_API_ENDPOINT #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4f92519
Initial plan
Copilot 6e73c3c
Change default API endpoint to models.github.ai/inference and rename …
Copilot e29ab42
Refactor test to remove code duplication
Copilot 9ac4db3
Improvements to the code written by Copilot.
kevinbackhouse 3a9f546
Remove unused imports
kevinbackhouse 6df166d
Change import style to work around CodeQL alert.
kevinbackhouse f16f1dc
Fix test error
kevinbackhouse 90724ab
Remove unused import
kevinbackhouse f0c4ef1
Use Enum
kevinbackhouse 5acf9fa
Add comment
kevinbackhouse 0aad227
Update src/seclab_taskflow_agent/capi.py
kevinbackhouse 218e478
Merge branch 'main' into copilot/change-default-api-endpoint
kevinbackhouse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # SPDX-FileCopyrightText: 2025 GitHub | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """ | ||
| Test API endpoint configuration. | ||
| """ | ||
|
|
||
| import pytest | ||
| import os | ||
| from urllib.parse import urlparse | ||
|
|
||
| class TestAPIEndpoint: | ||
| """Test API endpoint configuration.""" | ||
|
|
||
| @staticmethod | ||
| def _reload_capi_module(): | ||
| """Helper method to reload the capi module.""" | ||
| import importlib | ||
| import seclab_taskflow_agent.capi | ||
|
||
| importlib.reload(seclab_taskflow_agent.capi) | ||
|
|
||
| def test_default_api_endpoint(self): | ||
| """Test that default API endpoint is set to models.github.ai/inference.""" | ||
| import seclab_taskflow_agent.capi | ||
| # When no env var is set, it should default to models.github.ai/inference | ||
| # Note: We can't easily test this without manipulating the environment | ||
| # so we'll just import and verify the constant exists | ||
| endpoint = seclab_taskflow_agent.capi.AI_API_ENDPOINT | ||
| assert endpoint is not None | ||
| assert isinstance(endpoint, str) | ||
| assert urlparse(endpoint).netloc == seclab_taskflow_agent.capi.AI_API_ENDPOINT_ENUM.AI_API_MODELS_GITHUB | ||
kevinbackhouse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def test_api_endpoint_env_override(self): | ||
| """Test that AI_API_ENDPOINT can be overridden by environment variable.""" | ||
| # Save original env | ||
| original_env = os.environ.get('AI_API_ENDPOINT') | ||
|
|
||
| try: | ||
| # Set custom endpoint | ||
| test_endpoint = 'https://test.example.com' | ||
| os.environ['AI_API_ENDPOINT'] = test_endpoint | ||
|
|
||
| # Reload the module to pick up the new env var | ||
| self._reload_capi_module() | ||
|
|
||
| import seclab_taskflow_agent.capi | ||
| assert seclab_taskflow_agent.capi.AI_API_ENDPOINT == test_endpoint | ||
| finally: | ||
| # Restore original env | ||
| if original_env is None: | ||
| os.environ.pop('AI_API_ENDPOINT', None) | ||
| else: | ||
| os.environ['AI_API_ENDPOINT'] = original_env | ||
| # Reload again to restore original state | ||
| self._reload_capi_module() | ||
|
|
||
| if __name__ == '__main__': | ||
| pytest.main([__file__, '-v']) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-FileCopyrightText: 2025 GitHub | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| """ | ||
| Test CLI global variable parsing. | ||
| """ | ||
|
|
||
| import pytest | ||
| from seclab_taskflow_agent.available_tools import AvailableTools | ||
|
|
||
| class TestCliGlobals: | ||
| """Test CLI global variable parsing.""" | ||
|
|
||
| def test_parse_single_global(self): | ||
| """Test parsing a single global variable from command line.""" | ||
| from seclab_taskflow_agent.__main__ import parse_prompt_args | ||
| available_tools = AvailableTools() | ||
|
|
||
| p, t, l, cli_globals, user_prompt, _ = parse_prompt_args( | ||
| available_tools, "-t example -g fruit=apples") | ||
|
|
||
| assert t == "example" | ||
| assert cli_globals == {"fruit": "apples"} | ||
| assert p is None | ||
| assert l is False | ||
|
|
||
| def test_parse_multiple_globals(self): | ||
| """Test parsing multiple global variables from command line.""" | ||
| from seclab_taskflow_agent.__main__ import parse_prompt_args | ||
| available_tools = AvailableTools() | ||
|
|
||
| p, t, l, cli_globals, user_prompt, _ = parse_prompt_args( | ||
| available_tools, "-t example -g fruit=apples -g color=red") | ||
|
|
||
| assert t == "example" | ||
| assert cli_globals == {"fruit": "apples", "color": "red"} | ||
| assert p is None | ||
| assert l is False | ||
|
|
||
| def test_parse_global_with_spaces(self): | ||
| """Test parsing global variables with spaces in values.""" | ||
| from seclab_taskflow_agent.__main__ import parse_prompt_args | ||
| available_tools = AvailableTools() | ||
|
|
||
| p, t, l, cli_globals, user_prompt, _ = parse_prompt_args( | ||
| available_tools, "-t example -g message=hello world") | ||
|
|
||
| assert t == "example" | ||
| # "world" becomes part of the prompt, not the value | ||
| assert cli_globals == {"message": "hello"} | ||
| assert "world" in user_prompt | ||
|
|
||
| def test_parse_global_with_equals_in_value(self): | ||
| """Test parsing global variables with equals sign in value.""" | ||
| from seclab_taskflow_agent.__main__ import parse_prompt_args | ||
| available_tools = AvailableTools() | ||
|
|
||
| p, t, l, cli_globals, user_prompt, _ = parse_prompt_args( | ||
| available_tools, "-t example -g equation=x=5") | ||
|
|
||
| assert t == "example" | ||
| assert cli_globals == {"equation": "x=5"} | ||
|
|
||
| def test_globals_in_taskflow_file(self): | ||
| """Test that globals can be read from taskflow file.""" | ||
| available_tools = AvailableTools() | ||
|
|
||
| taskflow = available_tools.get_taskflow("tests.data.test_globals_taskflow") | ||
| assert 'globals' in taskflow | ||
| assert taskflow['globals']['test_var'] == 'default_value' | ||
|
|
||
| if __name__ == '__main__': | ||
| pytest.main([__file__, '-v']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.