Skip to content

Commit

Permalink
docs(lifecycle): update onStreamingDone and lifecycle documentation
Browse files Browse the repository at this point in the history
Rearrange and expand the explanation of `onStreamingDone` process. Add a detailed description of Shire's lifecycle in the lifecycle documentation.
  • Loading branch information
phodal committed Jun 28, 2024
1 parent 99a2ec2 commit bba53d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions docs/lifecycle/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ nav_order: 4
has_children: true
permalink: /lifecycle
---

# Lifecycle

Shire 的生命周期是围绕 IDE 与 LLM 生成过程所设计的。Shire 的生命周期包括:

- When: 决定是否在 UI 中展示 Shire 指令。
- onStreaming:在 Streaming 过程中对生成的内容进行处理。(TBD)
- onStreamingDone:在 Streaming 完成后通过一系列的后处理器对生成的内容进行处理。
- afterStreaming:在 Streaming 完成后,根据条件执行后续操作,诸如执行新的 Shire 指令、调用其它工具等等。
20 changes: 13 additions & 7 deletions docs/lifecycle/on-streaming-done.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ parent: Lifecycle
nav_order: 3
---

`onStreamingDone` 即在 Streaming 完成后通过一系列的后处理器对生成的内容进行处理,诸如:
`onStreamingDone` 即在 Streaming 完成后通过一系列的后处理器对生成的内容进行处理

- ParseCode,从生成的结果中解析生成的代码块。
- SaveFile,将保存生成的代码到文件。
- CodeVerify,检查代码错误或 PSI 问题
- RunCode,运行生成的代码(取决于是否存在对应的 RunService)。

### 示例:
示例:

```shire
---
Expand All @@ -22,6 +17,17 @@ onStreamingEnd: { parseCode | saveFile | openFile | verifyCode | runCode }
生成一个 python hello world,使用 markdown block 返回
```

该代码会调用 LLM 生成一个 python hello world,然后将生成的代码块解析,保存到文件,打开文件,检查代码错误或 PSI 问题,最后运行生成的代码。

对应的后处理器有:

- ParseCode,从生成的结果中解析生成的代码块。
- SaveFile,将保存生成的代码到文件。
- OpenFile,打开生成的文件。
- VerifyCode,检查代码错误或 PSI 问题
- RunCode,运行生成的代码(取决于是否存在对应的 RunService)。


### 内置 PostHandler

最新版本见源码:com.phodal.shirecore.middleware.BuiltinPostHandler
Expand Down

0 comments on commit bba53d0

Please sign in to comment.