mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-03 07:13:26 +08:00
fix: 输出为空的代码补全不再记录
This commit is contained in:
@@ -376,11 +376,15 @@ func (p *LLMProxy) handleCompletionStream(ctx context.Context, w http.ResponseWr
|
||||
if len(t.Choices) > 0 {
|
||||
rc.Completion += t.Choices[0].Text
|
||||
}
|
||||
rc.InputTokens += int64(t.Usage.PromptTokens)
|
||||
rc.InputTokens = int64(t.Usage.PromptTokens)
|
||||
rc.OutputTokens += int64(t.Usage.CompletionTokens)
|
||||
}
|
||||
}
|
||||
|
||||
if rc.OutputTokens == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
p.logger.With("record", rc).DebugContext(ctx, "流式记录")
|
||||
if err := p.usecase.Record(context.Background(), rc); err != nil {
|
||||
p.logger.With("modelID", m.ID, "modelName", m.ModelName, "modelType", consts.ModelTypeLLM).
|
||||
@@ -469,6 +473,10 @@ func (p *LLMProxy) handleCompletion(ctx context.Context, w http.ResponseWriter,
|
||||
}
|
||||
|
||||
func (p *LLMProxy) recordCompletion(c *Ctx, modelID string, req domain.CompletionRequest, resp *openai.CompletionResponse) {
|
||||
if resp.Usage.CompletionTokens == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
prompt := req.Prompt.(string)
|
||||
rc := &domain.RecordParam{
|
||||
|
||||
Reference in New Issue
Block a user