buildStepPrompt 构建步骤提示词
(chain *Chain, basePrompt string)
| 154 | |
| 155 | // buildStepPrompt 构建步骤提示词 |
| 156 | func (e *Engine) buildStepPrompt(chain *Chain, basePrompt string) string { |
| 157 | var prompt strings.Builder |
| 158 | |
| 159 | prompt.WriteString(basePrompt) |
| 160 | prompt.WriteString("\n\n") |
| 161 | |
| 162 | if len(chain.Steps) > 0 { |
| 163 | prompt.WriteString("## Previous Steps\n\n") |
| 164 | for i, step := range chain.Steps { |
| 165 | prompt.WriteString(fmt.Sprintf("### Step %d: %s\n", i+1, step.Title)) |
| 166 | prompt.WriteString(fmt.Sprintf("- Action: %s\n", step.Action)) |
| 167 | prompt.WriteString(fmt.Sprintf("- Result: %s\n", step.Result)) |
| 168 | prompt.WriteString(fmt.Sprintf("- Confidence: %.2f\n\n", step.Confidence)) |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | prompt.WriteString(fmt.Sprintf("## Current Step: %d/%d\n\n", len(chain.Steps)+1, chain.MaxSteps)) |
| 173 | prompt.WriteString("Please provide the next reasoning step.\n") |
| 174 | |
| 175 | return prompt.String() |
| 176 | } |
| 177 | |
| 178 | // parseStepResponse 解析步骤响应 |
| 179 | func (e *Engine) parseStepResponse(response *provider.CompleteResponse) (*Step, error) { |
no test coverage detected