MCPcopy Create free account
hub / github.com/astercloud/aster / executeReasoningStep

Method executeReasoningStep

pkg/reasoning/engine.go:88–114  ·  view source on GitHub ↗

executeReasoningStep 执行单个推理步骤

(ctx context.Context, chain *Chain, basePrompt string)

Source from the content-addressed store, hash-verified

86
87// executeReasoningStep 执行单个推理步骤
88func (e *Engine) executeReasoningStep(ctx context.Context, chain *Chain, basePrompt string) (*Step, error) {
89 // 构建当前步骤的提示词
90 prompt := e.buildStepPrompt(chain, basePrompt)
91
92 // 调用 Provider
93 messages := []types.Message{
94 {
95 Role: types.MessageRoleUser,
96 ContentBlocks: []types.ContentBlock{
97 &types.TextBlock{Text: prompt},
98 },
99 },
100 }
101
102 response, err := e.provider.Complete(ctx, messages, nil)
103 if err != nil {
104 return nil, fmt.Errorf("provider complete: %w", err)
105 }
106
107 // 解析响应
108 step, err := e.parseStepResponse(response)
109 if err != nil {
110 return nil, fmt.Errorf("parse step response: %w", err)
111 }
112
113 return step, nil
114}
115
116// buildReasoningPrompt 构建推理提示词
117func (e *Engine) buildReasoningPrompt(query string, systemPrompt string) string {

Callers 1

ReasonMethod · 0.95

Calls 3

buildStepPromptMethod · 0.95
parseStepResponseMethod · 0.95
CompleteMethod · 0.65

Tested by

no test coverage detected