Created
November 15, 2025 22:26
-
-
Save jsbeaudry/06b42e4a7488a67d857a37631bbdda43 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
| import os | |
| from dotenv import load_dotenv | |
| from livekit import agents | |
| from livekit.agents import AgentSession, Agent, RoomInputOptions | |
| from livekit.plugins import noise_cancellation, silero, deepgram, openai, google | |
| from livekit.plugins.turn_detector.multilingual import MultilingualModel | |
| load_dotenv(".env.local") | |
| class Assistant(Agent): | |
| def __init__(self) -> None: | |
| super().__init__( | |
| instructions = """ | |
| Ou se yon asistan vwa medikal entelijan Ayiti.""" | |
| ) | |
| async def entrypoint(ctx: agents.JobContext): | |
| session = AgentSession( | |
| stt=openai.STT( | |
| # base_url=os.getenv("KANI_BASE_URL", "http://localhost:8000/v1"), | |
| model="gpt-4o-transcribe", | |
| ), | |
| llm=openai.LLM( | |
| model="gpt-4.1-nano-2025-04-14" | |
| ), | |
| tts = openai.TTS( | |
| base_url=os.getenv("KANI_BASE_URL", "http://localhost:8000/v1"), | |
| model="tts-1", | |
| voice="bob-ht", | |
| response_format="pcm", | |
| speed= 1.0 | |
| ), | |
| vad=silero.VAD.load(), | |
| turn_detection=MultilingualModel(), | |
| ) | |
| await session.start( | |
| room=ctx.room, | |
| agent=Assistant(), | |
| room_input_options=RoomInputOptions( | |
| # For telephony applications, use `BVCTelephony` instead for best results | |
| noise_cancellation=noise_cancellation.BVC(), | |
| ), | |
| ) | |
| await session.generate_reply( | |
| instructions = """ | |
| Ou se asistan vwa medikal Ayiti. | |
| Salye pasyan an an kreyòl avèk respè ak dousè. | |
| Kenbe repons yo kout (mwens pase 100 karaktè si posib). | |
| Egzanp: “Bonjou! Kijan ou santi w jodi a?” oswa “Kisa ou ta renmen mwen ede w ak sante w?” | |
| """ | |
| ) | |
| if __name__ == "__main__": | |
| agents.cli.run_app(agents.WorkerOptions(entrypoint_fnc=entrypoint)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment