Telegram 內容工作流程如何將模型回覆配對至任務
Matching model responses to tasks in a Telegram content workflow
這套以 Python 建立的 Telegram 內容工作流程,透過 request_id 將模型回覆配對至相應任務,避免把回覆錯配給最近送出的任務。每項請求的 JSON 標頭包含 request_id、stage 和 schema_version,回覆則以附有該識別碼的結束標記作結;結束標記不代表草稿準確、安全或已獲批准。草稿須經人工審核,按下發佈按鈕後才會發佈主要貼文。
When a content workflow sends several tasks to a model, receiving a response is not enough. The program must know which request the response belongs to before it presents a draft for review. Here is how that handoff is structured in my Python-based Telegram content factory, and what the identifier does and does not solve
The workflow
The factory monitors selected Telegram channels through the owner's account. It turns candidate news items into cards in a private group's ideas topic. A person selects a card, chooses the destination channel and platforms, and can add an author comment
The program passes the source, channel-specific writing rules and optional comment to a separate writer bot. The writer researches the topic, prepares a draft and checks facts. The completed draft goes to a separate posts topic for human review. The program does not publish the main post until someone presses the publish button
Match the answer to the request
Each request starts with a JSON header containing request_id, stage and schema_version. The writer's reply ends with [END:<request_id>], using that request's identifier. The receiving program can associate the reply with the task that produced it instead of assuming that the next message belongs to the last task sent
The stage field describes the step, while schema_version gives the sender and receiver a way to identify the request format. The end marker is part of the communication protocol: it is not evidence that the draft is accurate, safe, or approved
The surrounding workflow is described in my walkthrough of the content factory, including where the person selects a topic and reviews the result
Checks worth running
Before relying on a similar handoff, send two distinguishable test tasks and verify that each result is attached to the correct request. Test a missing or mismatched end marker and verify that it is not mistaken for a completed response. Then test the human decision: requesting a rewrite should return a draft for review, and cancellation should not publish it
These are suggested tests, not a claim that every failure mode is automatically handled by the protocol. A matching identifier solves correlation; factual checks, access control, durable state and duplicate-publication prevention are separate engineering problems
This article was created with the help of AI.
來源:DEV Community · dev.to