-
Notifications
You must be signed in to change notification settings - Fork 36
Re-organize into "agents" and "servers" folder, update READMEs to match current repo state #8
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
5 commits
Select commit
Hold shift + click to select a range
45e5ad3
Reorganize files and update READMEs
pamelafox 60ea5db
Revert expenses changes
pamelafox 5e39684
Revert expenses changes
pamelafox ef389de
Apply suggestions from code review
pamelafox ad8b409
Apply suggestions from code review
pamelafox 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
| import logging | ||
| import os | ||
|
|
||
| from azure.identity import DefaultAzureCredential | ||
| from dotenv import load_dotenv | ||
| from rich import print | ||
| from rich.logging import RichHandler | ||
|
|
||
| from agent_framework import ChatAgent, MCPStreamableHTTPTool | ||
| from agent_framework.azure import AzureOpenAIChatClient | ||
| from agent_framework.openai import OpenAIChatClient | ||
|
|
||
| # Configure logging | ||
| logging.basicConfig( | ||
| level=logging.WARNING, | ||
| format="%(message)s", | ||
| datefmt="[%X]", | ||
| handlers=[RichHandler()] | ||
| ) | ||
| logger = logging.getLogger("agentframework_mcp_http") | ||
|
|
||
| # Load environment variables | ||
| load_dotenv(override=True) | ||
|
|
||
| # Constants | ||
| MCP_SERVER_URL = "http://localhost:8000/mcp/" | ||
|
|
||
| # Configure chat client based on API_HOST | ||
| API_HOST = os.getenv("API_HOST", "github") | ||
|
|
||
| if API_HOST == "azure": | ||
| client = AzureOpenAIChatClient( | ||
| credential=DefaultAzureCredential(), | ||
| deployment_name=os.environ.get("AZURE_OPENAI_CHAT_DEPLOYMENT"), | ||
| endpoint=os.environ.get("AZURE_OPENAI_ENDPOINT"), | ||
| api_version=os.environ.get("AZURE_OPENAI_VERSION"), | ||
| ) | ||
| elif API_HOST == "github": | ||
| client = OpenAIChatClient( | ||
| base_url="https://models.github.ai/inference", | ||
| api_key=os.environ["GITHUB_TOKEN"], | ||
| model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"), | ||
| ) | ||
| elif API_HOST == "ollama": | ||
| client = OpenAIChatClient( | ||
| base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), | ||
| api_key="none", | ||
| model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"), | ||
| ) | ||
| else: | ||
| client = OpenAIChatClient( | ||
| api_key=os.environ.get("OPENAI_API_KEY"), model_id=os.environ.get("OPENAI_MODEL", "gpt-4o") | ||
| ) | ||
|
|
||
|
|
||
| async def http_mcp_example() -> None: | ||
| """ | ||
| Demonstrate MCP integration with the local Expenses MCP server. | ||
|
|
||
| Creates an agent that can help users log expenses | ||
| using the Expenses MCP server at http://localhost:8000/mcp/. | ||
| """ | ||
| async with ( | ||
| MCPStreamableHTTPTool( | ||
| name="Expenses MCP Server", | ||
| url=MCP_SERVER_URL | ||
| ) as mcp_server, | ||
| ChatAgent( | ||
| chat_client=client, | ||
| name="Expenses Agent", | ||
| instructions="You help users to log expenses.", | ||
| ) as agent, | ||
| ): | ||
| user_query = "yesterday I bought a laptop for $1200 using my visa." | ||
| result = await agent.run(user_query, tools=mcp_server) | ||
| print(result) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(http_mcp_example()) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.
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.