Skip to content

Commit 407fb30

Browse files
authored
Python: Add BaseAgent implementation for GitHub Copilot SDK (#3404)
* Added GithubCopilotAgent * Fixed errors * Updated examples * Updated naming and tests * Resolved comments and more tests * Updated tool handling * Updated tool handling * Small fixes * Removed default permission handler * Resolved comments * Updated positional args * Updated docstrings * Small fixes and more examples * Added example with MCP
1 parent a3a9147 commit 407fb30

21 files changed

+2207
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Microsoft. All rights reserved.
2+
3+
import importlib
4+
from typing import Any
5+
6+
_IMPORTS: dict[str, tuple[str, str]] = {
7+
"GithubCopilotAgent": ("agent_framework_github_copilot", "agent-framework-github-copilot"),
8+
"GithubCopilotOptions": ("agent_framework_github_copilot", "agent-framework-github-copilot"),
9+
"GithubCopilotSettings": ("agent_framework_github_copilot", "agent-framework-github-copilot"),
10+
"__version__": ("agent_framework_github_copilot", "agent-framework-github-copilot"),
11+
}
12+
13+
14+
def __getattr__(name: str) -> Any:
15+
if name in _IMPORTS:
16+
import_path, package_name = _IMPORTS[name]
17+
try:
18+
return getattr(importlib.import_module(import_path), name)
19+
except ModuleNotFoundError as exc:
20+
raise ModuleNotFoundError(
21+
f"The package {package_name} is required to use `{name}`. "
22+
f"Please use `pip install {package_name}`, or update your requirements.txt or pyproject.toml file."
23+
) from exc
24+
raise AttributeError(f"Module `agent_framework.github` has no attribute {name}.")
25+
26+
27+
def __dir__() -> list[str]:
28+
return list(_IMPORTS.keys())
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) Microsoft. All rights reserved.
2+
3+
from agent_framework_github_copilot import (
4+
GithubCopilotAgent,
5+
GithubCopilotOptions,
6+
GithubCopilotSettings,
7+
__version__,
8+
)
9+
10+
__all__ = [
11+
"GithubCopilotAgent",
12+
"GithubCopilotOptions",
13+
"GithubCopilotSettings",
14+
"__version__",
15+
]

python/packages/core/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ all = [
5050
"agent-framework-copilotstudio",
5151
"agent-framework-declarative",
5252
"agent-framework-devui",
53+
"agent-framework-github-copilot",
5354
"agent-framework-lab",
5455
"agent-framework-mem0",
5556
"agent-framework-ollama",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Get Started with Microsoft Agent Framework GitHub Copilot
2+
3+
Please install this package via pip:
4+
5+
```bash
6+
pip install agent-framework-github-copilot --pre
7+
```
8+
9+
## GitHub Copilot Agent
10+
11+
The GitHub Copilot agent enables integration with GitHub Copilot, allowing you to interact with Copilot's agentic capabilities through the Agent Framework.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) Microsoft. All rights reserved.
2+
3+
import importlib.metadata
4+
5+
from ._agent import GithubCopilotAgent, GithubCopilotOptions
6+
from ._settings import GithubCopilotSettings
7+
8+
try:
9+
__version__ = importlib.metadata.version(__name__)
10+
except importlib.metadata.PackageNotFoundError:
11+
__version__ = "0.0.0"
12+
13+
__all__ = [
14+
"GithubCopilotAgent",
15+
"GithubCopilotOptions",
16+
"GithubCopilotSettings",
17+
"__version__",
18+
]

0 commit comments

Comments
 (0)