|
| 1 | +# Chain-of-Thoughts |
| 2 | + |
| 3 | +Web Chat supports Chain-of-Thoughts (CoT) UI for reasoning. |
| 4 | + |
| 5 | +Chain-of-Thought reasoning enables users to follow the logical progression of ideas or decisions. By presenting reasoning as a sequence of steps, it becomes easier to debug, refine, and explain the thought process behind a decision or solution. This is particularly useful in scenarios involving complex problem-solving, collaborative discussions, or educational purposes, where transparency and clarity are essential. |
| 6 | + |
| 7 | +## Terminology |
| 8 | + |
| 9 | +| Term | Description | |
| 10 | +| ----- | -------------------------------------- | |
| 11 | +| Chain | The complete Chain-of-Thought sequence | |
| 12 | +| Step | A reasoning step in the chain. | |
| 13 | + |
| 14 | +## Must-knows |
| 15 | + |
| 16 | +- A chain must have one or more steps |
| 17 | +- Each step is implemented as a message activity (either complete or [livestreaming](./LIVESTREAMING.md) message) |
| 18 | +- Chains are identified by an ID rather than being materialized objects |
| 19 | +- Chain ID is treated as an opaque string and local to the conversation |
| 20 | +- Steps are linked to chains through the chain ID |
| 21 | + |
| 22 | +## Design decisions |
| 23 | + |
| 24 | +### Why use Schema.org `HowTo` and `HowToStep`? |
| 25 | + |
| 26 | +We are leveraging [`HowTo`](https://schema.org/HowTo) and [`HowToStep`](https://schema.org/HowToStep) type to represent the chain and the step respectively. |
| 27 | + |
| 28 | +Their definitions: |
| 29 | + |
| 30 | +- [`HowTo`](https://schema.org/HowTo): "Instructions that explain how to achieve a result by performing a sequence of steps." |
| 31 | +- [`HowToStep`](https://schema.org/HowToStep): "A step in the instructions for how to achieve a result." |
| 32 | + |
| 33 | +The definitions of `HowTo` and `HowToStep` capture the metaphor of Chain-of-Thought precisely. Thus, the payload is based on them. |
| 34 | + |
| 35 | +## Sample payload |
| 36 | + |
| 37 | +> Copied from [../__tests__/html2/part-grouping/index.html](this test case). |
| 38 | +
|
| 39 | +```json |
| 40 | +{ |
| 41 | + "entities": [ |
| 42 | + { |
| 43 | + "@context": "https://schema.org", |
| 44 | + "@id": "", |
| 45 | + "@type": "Message", |
| 46 | + "type": "https://schema.org/Message", |
| 47 | + |
| 48 | + "abstract": "Considering equation solutions", |
| 49 | + "isPartOf": { |
| 50 | + "@id": "h-00001", |
| 51 | + "@type": "HowTo" |
| 52 | + }, |
| 53 | + "keywords": ["AIGeneratedContent", "AnalysisMessage"], |
| 54 | + "position": 1 |
| 55 | + } |
| 56 | + ], |
| 57 | + "id": "a-00001", |
| 58 | + "text": "The equation \\(x^2 + y^2 = 0\\) has only one solution: \\((0, 0)\\). This means the graph would only plot a single point at the origin." |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +The table below explains each individual property in the sample payload. |
| 63 | + |
| 64 | +| Type | Property | Required | Description | |
| 65 | +| --------- | ---------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 66 | +| `Message` | | | This root entity represents the message itself. In the sample, it is `entities[@id=""]`. | |
| 67 | +| | `@context` | Yes | Must be `"https://schema.org"`. | |
| 68 | +| | `@id` | Yes | Must be empty string `""`, it represents the message itself. | |
| 69 | +| | `@type` | Yes | Must be `"Message"`. | |
| 70 | +| | `abstract` | No | Short description of the message. For CoT, this is the title of the step. | |
| 71 | +| | `isPartOf` | Yes | Indicates this message is part of a group. For CoT, `isPartOf.@type` must be `"HowTo"` to indicate "this message is a step of the chain." | |
| 72 | +| | `keywords` | No | Attributes of the message. For CoT, if it contains `"Collapsible"`, the step will be shown as collapsed by-default. | |
| 73 | +| | `position` | No | A non-negative integer representing the position of the step in the chain. Steps are sorted in ascending order. | |
| 74 | +| | `type` | Yes | Must be `"https://schema.org/Message"`, required by Bot Framework spec. | |
| 75 | +| `HowTo` | | | This entity represent the chain. In the sample, it is `entities[@id=""].isPartOf[@type="HowTo"]`. | |
| 76 | +| | `@id` | Yes | ID of the chain. For all messages that participate in the same chain, they share the same ID. Treated as opaque string and local to the conversation. | |
| 77 | +| | `@type` | Yes | Must be `"HowTo"` to represent the chain. | |
| 78 | + |
| 79 | +## Readings |
| 80 | + |
| 81 | +- Related pull requests |
| 82 | + - [Initial commit](https://github.com/microsoft/BotFramework-WebChat/pull/5553) |
| 83 | +- [Test cases](/__tests__/html2/part-grouping) |
0 commit comments