Open7

Shopify SidekickのストリーミングでのMarkdownレンダリング

r-kagayar-kagaya

Markdown表現の候補となるシーケンスに遭遇するたびに文字をバッファリングした。

  • The parser encounters an unexpected character
    • バッファをフラッシュし、シーケンス全体を生のテキストとしてレンダリングします。
  • The full Markdown element is complete
    • バッファのコンテンツを1つのMarkdown要素シーケンスとしてレンダリング
r-kagayar-kagaya

Async content resolution and multiplexing

We’ve made a tweak to break the tool invocation and output generation out of the main LLM response, to let the initial LLM roundtrip directly respond to the user, with placeholders that get asynchronously populated:

メインのレスポンスと非同期で表示されるプレースホルダー
Server-Sent Eventsを使う

https://cdn.shopify.com/s/files/1/0779/4361/files/SidekickStreaming-SeqDiagram-03-v002.png?format=webp&v=1690295285
https://cdn.shopify.com/s/files/1/0779/4361/files/SidekickStreaming-Gif-03-v003.gif?v=1690295255

r-kagayar-kagaya

Markdown, as a means of transporting structure, beats JSON and YAML in token counts.

Markdown推し