great-zebra-60665
06/06/2025, 11:45 AMtall-airline-16756
06/06/2025, 11:46 AMtall-airline-16756
06/06/2025, 11:46 AMimport logging
from dotenv import load_dotenv
from livekit.agents import (
Agent,
AgentSession,
JobContext,
RoomInputOptions,
RoomOutputOptions,
WorkerOptions,
cli,
)
from livekit.plugins import openai
logger = logging.getLogger("text-only")
logger.setLevel(<http://logging.INFO|logging.INFO>)
load_dotenv()
class MyAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="You are a helpful assistant.",
llm=openai.LLM(model="gpt-4o-mini"),
)
async def entrypoint(ctx: JobContext):
await ctx.connect()
session = AgentSession()
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False),
room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False),
)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
This example demonstrates a text-only agent that:
• Accepts text input through TextStream on the lk.chat topic
• Sends text output through TextStream to the lk.transcription topic
• Disables audio input and output by setting audio_enabled=False in both input and output options Sources: Tree View: | dse-workbench