glamorous-kitchen-68628
08/14/2025, 12:19 PMtall-airline-16756
08/14/2025, 12:19 PMtall-airline-16756
08/14/2025, 12:19 PM@function_tool
that sends just text—no TTS involved—to the client in LiveKit. Let me share an example of how you might set up an Agent class specifically for text-only communication:
Example Agent Class for Text-Only Output:
class MyAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="You are a helpful assistant.",
)
@function_tool
async def get_weather(self, location: str):
"""Called when the user asks about the weather.
Args:
location: The location to get the weather for
"""
return f"The weather in {location} is sunny today."
Configuration for Text-Only Communication:
async def entrypoint(ctx: JobContext):
session = AgentSession(
llm=openai.LLM(model="gpt-4o-mini"),
# Notice we don’t need TTS or STT here
)
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),
)
Key Points:
• Text-Only Configuration: We set room_input_options
and room_output_options
to enable text input and disable audio, keeping things simple.
• No TTS Needed: Since audio output is off, the Agent doesn’t need a TTS instance.
• Function Tool: The @function_tool
decorator helps the agent handle specific tasks and return text responses without any TTS.
This way, your agent sends only text to the client, making it perfect for text-only interactions. If you have any questions or want to explore this more, just let me know!glamorous-kitchen-68628
08/14/2025, 12:20 PMtall-airline-16756
08/14/2025, 12:21 PM@function_tool
responses skip the TTS while others still have audio. The options available let you turn off audio output for the whole session using RoomOutputOptions(audio_enabled=False)
, but this affects all responses, not just specific tools.
If you have a particular scenario in mind or need a hand figuring things out, just let me know! I’m here to help and can also pass your request along for more support if needed.