What is the correct way of setting up RPC callback...
# ask-ai
g
What is the correct way of setting up RPC callbacks in case they fail? I have the following code see if you can add any callbacks here: @room.local_participant.register_rpc_method("sendTrigger") async def handle_sendTrigger( data: rtc.RpcInvocationData, agent: VoicePipelineAgent = agent, ): """ Forwards a frontend trigger to buildship and then invokes RPC on the frontend based on the response from buildship """ try: function_timer.record_start_time("triggerReceivedToBuildshipTime") function_timer.record_start_time("triggerReceivedToLlmTime") report_openai_rate_limit() agent.interrupt() params = {"session_id": room.name} data_dict = json.loads(data.payload) params.update(data_dict) log_and_inform(f"RPC: sendTrigger with data: {data_dict}") function_timer.record_end_time("triggerReceivedToBuildshipTime") function_timer.record_start_time("sendReceivedBuildshipTriggerTime") response = await invoke_pre_llm_trigger(params) function_timer.record_end_time("sendReceivedBuildshipTriggerTime") # Check if prompt should be processed if not response.get("shouldPrompt", False): asyncio.create_task(function_timer.submit_timers(ctx.room)) return json.dumps( {"message": "No prompt to process", "success": True} ) # Interrupt and process the prompt agent.interrupt() user_prompt = response.get("userPrompt", "") # Use the new handle_pre_llm_processing function send_msg_params = await handle_pre_llm_processing( agent=agent, user_prompt=user_prompt, response=response, room=room, participant=participant, ) # Process the message using the assistant asyncio.create_task( answer_from_text( txt=send_msg_params, provider=provider, ) ) msg = f"sendTrigger RPC invoked successfully" log_and_inform(msg) return json.dumps({"message": msg, "success": True}) except Exception as e: error_msg = f"Error in sendTrigger RPC: {e.args}" logger.error(error_msg) return json.dumps({"message": error_msg, "success": False})
t
Thanks for reaching out, Elyas. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry, but I don't have the information you need at the moment. If you would like a member of the LiveKit team to respond, please ask your question in one of the other channels.