faint-finland-12341
02/24/2025, 8:49 PMgray-monkey-83525
02/24/2025, 8:49 PMauto_subscribe=AutoSubscribe.AUDIO_ONLY
setting. This configuration means the agent is not listening for text inputs. To enable text interaction, you might need to adjust the subscription settings or explicitly handle text messages in your code.
Would you like more details on how to modify your setup to handle text inputs as well?
Sources:
- https://docs.livekit.io/python/livekit/agents/pipeline/pipeline_agent.html#args
- https://docs.livekit.io/python/livekit/agents/pipeline/index.html#args 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.faint-finland-12341
02/24/2025, 8:51 PMgray-monkey-83525
02/24/2025, 8:51 PMChatManager
to listen for incoming chat messages.
Here's an example of how you can modify your code to handle text inputs:
import asyncio
from livekit import rtc
from livekit.agents import JobContext, WorkerOptions, cli
from livekit.agents.llm import ChatContext
from livekit.agents.voice_assistant import VoiceAssistant
from livekit.plugins import silero, openai
async def entrypoint(ctx: JobContext):
initial_ctx = ChatContext().append(
role="system",
text="Use this test version app"
)
await ctx.connect() # Remove the AUDIO_ONLY restriction
fnc_ctx = AssistantFnc()
assistant = VoiceAssistant(
vad=silero.VAD.load(),
stt=openai.STT(),
llm=openai.LLM(),
tts=openai.TTS(),
chat_ctx=initial_ctx,
fnc_ctx=fnc_ctx
)
assistant.start(ctx.room)
# Set up a ChatManager to handle text messages
chat = rtc.ChatManager(ctx.room)
@chat.on("message_received")
def on_chat_received(msg: rtc.ChatMessage):
if msg.message:
asyncio.create_task(answer_from_text(msg.message))
async def answer_from_text(txt: str):
chat_ctx = assistant.chat_ctx.copy()
chat_ctx.append(role="user", text=txt)
stream = assistant.llm.chat(chat_ctx=chat_ctx)
await assistant.say(stream)
if __name__ == "__main__":
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
Explanation:
- ChatManager: This is used to listen for incoming text messages. The on_chat_received
function is triggered whenever a new text message is received.
- answer_from_text: This function processes the text message by appending it to the chat context and generating a response using the LLM.
By implementing these changes, your agent should be able to handle both audio and text inputs effectively.
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1732415232.661559
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1727139659.431669 👍 1 button 👎 0 button 💡 Hint: Mention @millions-hair-24956 in the thread for followups.gray-monkey-83525
02/24/2025, 9:09 PMresponses
dictionary is being correctly initialized and updated, and ensure that the GDSQuestion
and `DEPRESSIVE_YES_ANSWERS`/`DEPRESSIVE_NO_ANSWERS` are correctly defined and used. If this doesn't help, please reach out to the Livekit support team for further assistance. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.faint-finland-12341
02/25/2025, 9:22 PMgray-monkey-83525
02/25/2025, 9:22 PMGDSQuestion
and response handling logic are implemented. If this doesn't help, please reach out to the Livekit support team for further assistance. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.