if I send a file through: ```info = await room.lo...
# ask-ai
m
if I send a file through:
Copy code
info = await room.local_participant.send_file(
  file_path="path/to/file.jpg",
  topic="my-topic",
)
print(f"Sent file with stream ID: {info.stream_id}")
what should I implement from the agent side to understand the file and respond accordingly?
t
Thanks for reaching out, Paolo. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To handle a file sent via
send_file
on the agent (remote) side, you should implement a byte stream handler using the
registerByteStreamHandler
API. This registers a callback that is triggered when an incoming byte stream is received on a specified topic. The handler receives a
ByteStreamReader
object that allows reading the incoming file data incrementally or in full. You can then process the received data and respond accordingly. In summary, the agent side should: • Use
registerByteStreamHandler
to register a handler for the topic related to the file transfer. • In the handler, use the
ByteStreamReader
to read and process the incoming file stream. • Implement any response logic based on the file content as needed. This mechanism enables robust file transfer handling integrated with LiveKit's streaming architecture. Sources: Sending files & bytes | LiveKit Docs | examples/demo/demo.ts | livekit-rtc/livekit/rtc/_proto/data_stream_pb2.pyi
m
I want to send the location of the file, not stream the bytes, the agent should read the file from location and do something with it
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!