← Back to list

LLM Transport Layer

เราเรียนรู้เรื่องการใช้งานของการสร้าง Agent หรือ Tools ที่เกี่ยวข้องไปค่อนข้างเยอะแล้ว ที่นี้มาดูภาพรวมการสื่อสารของ LLM กันบ้าง

Mart - Tanathip Viriya · 2025-10-02 05:28 · 0 claps · 1.8 min read
#server-side-events #llm #streamable-http #mcp-protocol
Open on Medium ↗
Wiki topics: LLM · Large Language Models AGT · AI Agents

LLM Transport Layer

เราเรียนรู้เรื่องการใช้งานของการสร้าง Agent หรือ Tools ที่เกี่ยวข้องไปค่อนข้างเยอะแล้ว ที่นี้มาดูภาพรวมการสื่อสารของ LLM กันบ้าง

LLM มันคุยกับแต่ละส่วนของ Components ยังไง

ที่เราลองๆกันส่วนใหญ่มันคือ Command-Line Interface นะ ที่เราพิมพ์มันใน Terminal, Powershell แล้วดูผลลัพธ์ออกมานะ

Example of CLI

Example of CLI

แต่ถ้ามันเป็นระดับ Application ละ ที่มี Frontend, Backend ใน services ต่างๆ มันจะมาเชื่อมต่อกับ LLM ของเรายังไง เพราะ LLM มันทํางานทีใช้เวลานานใช่มั้ยในการคิด ถ้าเราจะรอ request — response model แปลว่าเราอาจจะต้องนั่งรอมันทํางานจนกว่าจะเสร็จเป็น นาที เลยก็ได้ ดังนั้นเป็นจุดที่เราควรจะมาเรียนรู้ไว้เพื่อเลือกใช้ให้ถูก

STDIO — Standard Input/Output

เป็น basic method มากๆๆที่ใช้ในการ command-line ถ้าอ่านข้อมูลจาก keyboards (standard input) แล้วผลลัพ์ก็ออกทาง terminal/powershell ไป (standard output) คือเหมาะมากๆกับทํางาน locally ไม่ได้เหมาะไปใช้ Prodction level

เหมาะกับ → Local command-line use

SSE — Server-Sent Events

เป็นวิธีที่นิยมกันมากในการจัดการกับ data ขนาดใหญ่ที่เราต้องการส่งให้กับทาง client โดยจะมีกฎข้อบังคับที่ตกลงกันไว้ว่าจะทํางานอย่างไรบ้างระหว่าง client กับ server ซึ่งปกติแล้วเราจะใช้สิ่งเหล่านี้

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

https://developer.mozilla.org/en-US/docs/Web/API/EventSource

  • มีการใช้ specific header ที่ชื่อว่า Accept: text/event-stream เพื่อประกาศให้ทาง server รู้นะว่าเราอยากใช้ SSE broadcast ของ server
  • แล้วถ้าทุกอย่าง Okay ทาง Server ก็ต้องให้ content-type กลับมาเป็น text/event-stream

เป็นการสื่อสารแบบ unidirectional (one directional) ที่ data flow มาจาก server ไป client อย่างเดียว ไม่สามารถส่งกลับไปได้นอกจากเริ่ม HTTP request ใหม่ โดยปกติแล้วทาง server หรือ fastapi จะ provide สิ่งที่เรียกว่า EventSourceResponse (https://github.com/sysid/sse-starlette) กลับไปให้ Client นั้นเอง

คล้ายๆ Websocket แต่ๆเป็น one-way แปลว่า client ไม่สามารถส่งไรกลับไปได้ รับอย่างเดียว แต่ Websocket เป็น Bidirectional

เหมาะกับ → Server pushing real-time updates to a web browser (client)

[embed]What is HTTP Streaming? Explore HTTP streaming: how HLS, DASH, and adaptive bitrate deliver efficient, scalable media content, and their…www.pubnub.com

Streamable HTTP

มองเป็น version upgeade ของ SSE ข้างบนและใช้ใน MCP protocol เพื่อลด limitation ของ SSE

https://medium.com/@higress_ai/comparison-of-data-before-and-after-using-streamable-http-b094db8b414e

https://medium.com/@higress_ai/comparison-of-data-before-and-after-using-streamable-http-b094db8b414e

Must Read

  • code walkthrough FastAPI streaming response

[embed]Streaming Responses In FastAPI FastAPI support streaming response type out of the box with StreamingResponse. There’s also an implementation of server…medium.com

  • in detailed of streamable http

[embed]MCP's New Transport Layer - A Deep Dive into the Streamable HTTP Protocol | Claude MCP Blog MCP is a standard protocol for communication between AI models and tools. As AI applications grow increasingly complex…www.claudemcp.com

[embed]Comparison of data before and after using Streamable HTTP The MCP (Model Context Protocol) protocol is a standard protocol used for communication between AI models and tools. As…medium.com


메타데이터
post_id
b76e488678f9
slug
llm-transport-layer-b76e488678f9
url
https://medium.com/@vtanathip/llm-transport-layer-b76e488678f9
canonical_url
https://medium.com/@vtanathip/llm-transport-layer-b76e488678f9
author_url
https://medium.com/@vtanathip
status
ok
fetched_at
2026-07-09 05:26:43