mirror of
https://github.com/NousResearch/atropos.git
synced 2026-04-23 16:54:56 +00:00
Reorganize community environments - Move lean_proof_env, router_env, and philosophical_rlaif_env.py to environments/community/ - Add comprehensive README for community environments - This organizes community-contributed environments into a dedicated community folder for better maintainability and discoverability
This commit is contained in:
parent
945ea30c3a
commit
e85a170c34
53 changed files with 85 additions and 0 deletions
|
|
@ -0,0 +1,76 @@
|
|||
import logging
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from pathlib import Path
|
||||
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, cli, mcp, ChatContext, RunContext, function_tool
|
||||
from livekit.plugins import deepgram, openai, silero
|
||||
from livekit.plugins.turn_detector.multilingual import MultilingualModel
|
||||
import random
|
||||
from typing import Optional, List
|
||||
|
||||
load_dotenv(os.path.join(os.path.dirname(__file__), '..', '..', '.env'))
|
||||
|
||||
from livekit import api
|
||||
logger = logging.getLogger("caller-agent")
|
||||
|
||||
class CallerAgent(Agent):
|
||||
def __init__(self,
|
||||
chat_ctx: ChatContext,
|
||||
tools: Optional[List[function_tool]] = None) -> None:
|
||||
|
||||
final_instructions = (
|
||||
"You are a Caller specialist. Your primary function is to initiate phone calls. " +
|
||||
"If the user asks to call someone, use the 'make_phone_call' tool. " +
|
||||
"Currently, you can only call a predefined contact (Sam at +16467085301). Confirm with the user if they want to call this specific contact. " +
|
||||
"If your task is complete or the user asks for something outside your calling capabilities (e.g., math, web search), " +
|
||||
"you MUST use the 'delegate_to_router_agent' tool to return to the main assistant."
|
||||
)
|
||||
|
||||
agent_tools = [self.make_phone_call]
|
||||
all_tools = agent_tools + (tools if tools is not None else [])
|
||||
|
||||
super().__init__(
|
||||
instructions=final_instructions,
|
||||
chat_ctx=chat_ctx,
|
||||
allow_interruptions=True,
|
||||
tools=all_tools
|
||||
)
|
||||
self.lkapi = api.LiveKitAPI()
|
||||
|
||||
async def on_enter(self):
|
||||
self.session.generate_reply()
|
||||
|
||||
|
||||
@function_tool
|
||||
async def make_phone_call(self, context: RunContext, phone_number: str):
|
||||
"""
|
||||
Call this function to make a phone call to a user number.
|
||||
Args:
|
||||
phone_number: The phone number to call.
|
||||
"""
|
||||
await self.lkapi.agent_dispatch.create_dispatch(
|
||||
api.CreateAgentDispatchRequest(
|
||||
agent_name="my-telephony-agent",
|
||||
room=f"outbound-{''.join(str(random.randint(0, 9)) for _ in range(10))}",
|
||||
metadata='{"phone_number": "+16467085301"}' #HARDCODED
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def entrypoint(ctx: JobContext):
|
||||
await ctx.connect()
|
||||
|
||||
session = AgentSession(
|
||||
vad=silero.VAD.load(),
|
||||
stt=deepgram.STT(model="nova-3", language="multi"),
|
||||
llm=openai.LLM(model="gpt-4o-mini"),
|
||||
tts=openai.TTS(voice="ash"),
|
||||
turn_detection=MultilingualModel(),
|
||||
)
|
||||
|
||||
await session.start(agent=CallerAgent(chat_ctx=session._chat_ctx), room=ctx.room)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint,
|
||||
agent_name="mcp-agent"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue