Created
December 2, 2025 16:00
-
-
Save amosgyamfi/f84b588874eef50e5ed07af022678758 to your computer and use it in GitHub Desktop.
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
| """ | |
| DeepSeek V3.2 Maths and Physics Tutor | |
| This example demonstrates how to use the DeepSeek V3.2 model with the OpenRouter plugin with a Vision Agent. | |
| OpenRouter provides access to multiple LLM providers through a unified API. The DeepSeek V3.2 model is a powerful LLM that is able to solve Maths and Physics problems based on what the user shows you through their camera feed. | |
| Set OPENROUTER_API_KEY environment variables before running. | |
| """ | |
| import asyncio | |
| import logging | |
| from dotenv import load_dotenv | |
| from vision_agents.core import User, Agent, cli | |
| from vision_agents.core.agents import AgentLauncher | |
| from vision_agents.plugins import ( | |
| openrouter, | |
| getstream, | |
| elevenlabs, | |
| smart_turn, | |
| ) | |
| logger = logging.getLogger(__name__) | |
| load_dotenv() | |
| async def create_agent(**kwargs) -> Agent: | |
| """Create the agent with OpenRouter LLM.""" | |
| #model = "deepseek/deepseek-v3.2" # Can also use other models like anthropic/claude-3-opus/gemini | |
| model = "deepseek/deepseek-v3.2-speciale" | |
| # Determine personality based on model | |
| if "deepseek" in model.lower(): | |
| personality = "Talk like a Maths and Physics tutor." | |
| elif "anthropic" in model.lower(): | |
| personality = "Talk like a robot." | |
| elif "openai" in model.lower() or "gpt" in model.lower(): | |
| personality = "Talk like a pirate." | |
| elif "gemini" in model.lower(): | |
| personality = "Talk like a cowboy." | |
| elif "x-ai" in model.lower(): | |
| personality = "Talk like a 1920s Chicago mobster." | |
| else: | |
| personality = "Talk casually." | |
| agent = Agent( | |
| edge=getstream.Edge(), | |
| agent_user=User(name="OpenRouter AI", id="agent"), | |
| instructions=f""" | |
| You are an expert in Maths and Physics. You help users solve Maths and Physics problems based on what they show you through their camera feed. Always provide concise and clear instructions, and explain the step-by-step process to the user so they can understand how you arrive at the final answer. | |
| {personality} | |
| """, | |
| llm=openrouter.LLM(model=model), | |
| tts=elevenlabs.TTS(), | |
| stt=elevenlabs.STT(), | |
| turn_detection=smart_turn.TurnDetection( | |
| pre_speech_buffer_ms=2000, speech_probability_threshold=0.9 | |
| ), | |
| ) | |
| return agent | |
| async def join_call(agent: Agent, call_type: str, call_id: str, **kwargs) -> None: | |
| """Join the call and start the agent.""" | |
| # Ensure the agent user is created | |
| await agent.create_user() | |
| # Create a call | |
| call = await agent.create_call(call_type, call_id) | |
| logger.info("🤖 Starting OpenRouter Agent...") | |
| # Have the agent join the call/room | |
| with await agent.join(call): | |
| logger.info("Joining call") | |
| logger.info("LLM ready") | |
| # Open demo page for the user to join the call | |
| await agent.edge.open_demo(call) | |
| # Wait until the call ends (don't terminate early) | |
| await agent.finish() | |
| if __name__ == "__main__": | |
| cli(AgentLauncher(create_agent=create_agent, join_call=join_call)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment