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
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ authors = [
]
dependencies = [
"python-dotenv",
"stream-agents-plugins-openai",
"stream-agents-plugins-anthropic",
"stream-agents-plugins-gemini",
"stream-agents",
"vision-agents-plugins-openai",
"vision-agents-plugins-anthropic",
"vision-agents-plugins-gemini",
"vision-agents",
]
requires-python = ">=3.10"

Expand All @@ -22,7 +22,7 @@ build-backend = "hatchling.build"
packages = ["."]

[tool.uv.sources]
"stream-agents-plugins-openai" = {path = "../../plugins/openai", editable=true}
"stream-agents-plugins-anthropic" = {path = "../../plugins/anthropic", editable=true}
"stream-agents-plugins-gemini" = {path = "../../plugins/gemini", editable=true}
"stream-agents" = {path = "../../agents-core", editable=true}
"vision-agents-plugins-openai" = {path = "../../../plugins/openai", editable=true}
"vision-agents-plugins-anthropic" = {path = "../../../plugins/anthropic", editable=true}
"vision-agents-plugins-gemini" = {path = "../../../plugins/gemini", editable=true}
"vision-agents" = {path = "../../../agents-core", editable=true}
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ async def on_participant_joined(event: CallSessionParticipantJoinedEvent):

# Create a call
call = agent.edge.client.video.call("default", str(uuid4()))
await call.get_or_create()

# Open the demo UI
logger.info("🌐 Opening browser with demo UI...")
agent.edge.open_demo(call)

# Have the agent join the call/room
logger.info("🎤 Agent joining call...")
with await agent.join(call):
# Open the demo UI
logger.info("🌐 Opening browser with demo UI...")
await agent.edge.open_demo(call)
logger.info("✅ Agent is now live with Gemini Realtime! You can talk to it in the browser.")
logger.info("Try asking:")
logger.info(" - 'What repositories do I have?'")
Expand Down
8 changes: 3 additions & 5 deletions examples/other_examples/09_github_mcp_demo/github_mcp_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ async def on_participant_joined(event: CallSessionParticipantJoinedEvent):

# Create a call
call = agent.edge.client.video.call("default", str(uuid4()))
await call.get_or_create()

# Open the demo UI
logger.info("🌐 Opening browser with demo UI...")
agent.edge.open_demo(call)

# Have the agent join the call/room
logger.info("🎤 Agent joining call...")
with await agent.join(call):
# Open the demo UI
logger.info("🌐 Opening browser with demo UI...")
agent.edge.open_demo(call)
logger.info("✅ Agent is now live! You can talk to it in the browser.")
logger.info("Try asking: 'What repositories do I have?' or 'Create a new issue'")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""OpenAI Realtime GitHub MCP Demo - Demonstrate function calling with OpenAI Realtime and GitHub MCP.

This demo shows how OpenAI Realtime can use GitHub MCP tools for real-time function calling
during live conversations. The agent can interact with GitHub repositories, issues, and more
using voice commands through the OpenAI Realtime API.
"""

import asyncio
import logging
import os
from uuid import uuid4
from dotenv import load_dotenv

from vision_agents.core.agents import Agent
from vision_agents.core.mcp import MCPServerRemote
from vision_agents.plugins.openai.openai_realtime import Realtime
from vision_agents.plugins import getstream
from vision_agents.core import cli
from vision_agents.core.events import CallSessionParticipantJoinedEvent
from vision_agents.core.edge.types import User

# Load environment variables from .env file
load_dotenv()

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


async def main():
"""Demonstrate OpenAI Realtime with GitHub MCP server integration."""

# Get GitHub PAT from environment
github_pat = os.getenv("GITHUB_PAT")
if not github_pat:
logger.error("GITHUB_PAT environment variable not found!")
logger.error("Please set GITHUB_PAT in your .env file or environment")
return

# Check OpenAI API key from environment
openai_api_key = os.getenv("OPENAI_API_KEY")
if not openai_api_key:
logger.error("OPENAI_API_KEY environment variable not found!")
logger.error("Please set OPENAI_API_KEY in your .env file or environment")
return

# Create GitHub MCP server
github_server = MCPServerRemote(
url="https://api.githubcopilot.com/mcp/",
headers={"Authorization": f"Bearer {github_pat}"},
timeout=10.0, # Shorter connection timeout
session_timeout=300.0
)

# Create OpenAI Realtime LLM (uses OPENAI_API_KEY from environment)
llm = Realtime(
model="gpt-4o-realtime-preview-2024-12-17"
)

# Create real edge transport and agent user
edge = getstream.Edge()
agent_user = User(name="GitHub AI Assistant", id="github-agent")

# Create agent with GitHub MCP server and Gemini Realtime LLM
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the copy-paste error in the comment.

The comment mentions "Gemini Realtime LLM" but the code creates an agent with OpenAI Realtime (defined on lines 56-58).

Apply this diff to correct the comment:

-    # Create agent with GitHub MCP server and Gemini Realtime LLM
+    # Create agent with GitHub MCP server and OpenAI Realtime LLM
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Create agent with GitHub MCP server and Gemini Realtime LLM
# Create agent with GitHub MCP server and OpenAI Realtime LLM
🤖 Prompt for AI Agents
In examples/other_examples/09_github_mcp_demo/openai_realtime_github_mcp_demo.py
around line 64, the inline comment incorrectly says "Gemini Realtime LLM";
update that comment to reflect the actual LLM used by the code (OpenAI Realtime)
so it matches the agent creation on lines 56-58 — replace the comment text with
something like "Create agent with GitHub MCP server and OpenAI Realtime LLM".

agent = Agent(
edge=edge,
llm=llm,
agent_user=agent_user,
instructions="You are a helpful AI assistant with access to GitHub via MCP server. You can help with GitHub operations like creating issues, managing pull requests, searching repositories, and more. Keep responses conversational and helpful. When you need to perform GitHub operations, use the available MCP tools.",
processors=[],
mcp_servers=[github_server],
)

logger.info("Agent created with OpenAI Realtime and GitHub MCP server")
logger.info(f"GitHub server: {github_server}")

try:
# Create the agent user
await agent.create_user()

# Set up event handler for when participants join
@agent.subscribe
async def on_participant_joined(event: CallSessionParticipantJoinedEvent):
# Check MCP tools after connection
available_functions = agent.llm.get_available_functions()
mcp_functions = [f for f in available_functions if f['name'].startswith('mcp_')]
logger.info(f"✅ Found {len(mcp_functions)} MCP tools available for function calling")
await agent.say(f"Hello {event.participant.user.name}! I'm your GitHub AI assistant powered by OpenAI Realtime. I have access to {len(mcp_functions)} GitHub tools and can help you with repositories, issues, pull requests, and more through voice commands!")

# Create a call
call = agent.edge.client.video.call("default", str(uuid4()))

# Have the agent join the call/room
logger.info("🎤 Agent joining call...")
with await agent.join(call):
# Open the demo UI
logger.info("🌐 Opening browser with demo UI...")
await agent.edge.open_demo(call)
logger.info("✅ Agent is now live with OpenAI Realtime! You can talk to it in the browser.")
logger.info("Try asking:")
logger.info(" - 'What repositories do I have?'")
logger.info(" - 'Create a new issue in my repository'")
logger.info(" - 'Search for issues with the label bug'")
logger.info(" - 'Show me recent pull requests'")
logger.info("")
logger.info("The agent will use OpenAI Realtime's real-time function calling to interact with GitHub!")

# Run until the call ends
await agent.finish()

except Exception as e:
logger.error(f"Error with OpenAI Realtime GitHub MCP demo: {e}")
logger.error("Make sure your GITHUB_PAT and OPENAI_API_KEY are valid")
import traceback
traceback.print_exc()

# Clean up
await agent.close()
logger.info("Demo completed!")


if __name__ == "__main__":
asyncio.run(cli.start_dispatcher(main))
14 changes: 8 additions & 6 deletions examples/other_examples/09_github_mcp_demo/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ dependencies = [
"vision-agents-plugins-silero",
"vision-agents-plugins-getstream",
"vision-agents-plugins-openai",
"vision-agents-plugins-gemini",
]

[project.optional-dependencies]
dev = ["pytest", "mypy", "ruff"]

[tool.uv.sources]
"vision-agents" = {path = "../../agents-core", editable=true}
"vision-agents-plugins-deepgram" = {path = "../../plugins/deepgram", editable=true}
"vision-agents-plugins-elevenlabs" = {path = "../../plugins/elevenlabs", editable=true}
"vision-agents-plugins-silero" = {path = "../../plugins/silero", editable=true}
"vision-agents-plugins-getstream" = {path = "../../plugins/getstream", editable=true}
"vision-agents-plugins-openai" = {path = "../../plugins/openai", editable=true}
"vision-agents" = {path = "../../../agents-core", editable=true}
"vision-agents-plugins-deepgram" = {path = "../../../plugins/deepgram", editable=true}
"vision-agents-plugins-elevenlabs" = {path = "../../../plugins/elevenlabs", editable=true}
"vision-agents-plugins-silero" = {path = "../../../plugins/silero", editable=true}
"vision-agents-plugins-getstream" = {path = "../../../plugins/getstream", editable=true}
"vision-agents-plugins-openai" = {path = "../../../plugins/openai", editable=true}
"vision-agents-plugins-gemini" = {path = "../../../plugins/gemini", editable=true}
Loading