mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-21 16:37:47 +08:00
feat: preserve full prompt text across current_input_file rewrites
Keep token accounting tied to the original prompt even after the live prompt is replaced with a neutral placeholder and hidden context file.
This commit is contained in:
@@ -35,6 +35,10 @@ func (s Service) ApplyCurrentInputFile(ctx context.Context, a *auth.RequestAuth,
|
|||||||
if strings.TrimSpace(fileText) == "" {
|
if strings.TrimSpace(fileText) == "" {
|
||||||
return stdReq, errors.New("current user input file produced empty transcript")
|
return stdReq, errors.New("current user input file produced empty transcript")
|
||||||
}
|
}
|
||||||
|
originalPromptTokenText := strings.TrimSpace(stdReq.PromptTokenText)
|
||||||
|
if originalPromptTokenText == "" {
|
||||||
|
originalPromptTokenText = strings.TrimSpace(stdReq.FinalPrompt)
|
||||||
|
}
|
||||||
|
|
||||||
result, err := s.DS.UploadFile(ctx, a, dsclient.UploadFileRequest{
|
result, err := s.DS.UploadFile(ctx, a, dsclient.UploadFileRequest{
|
||||||
Filename: currentInputFilename,
|
Filename: currentInputFilename,
|
||||||
@@ -61,6 +65,7 @@ func (s Service) ApplyCurrentInputFile(ctx context.Context, a *auth.RequestAuth,
|
|||||||
stdReq.CurrentInputFileApplied = true
|
stdReq.CurrentInputFileApplied = true
|
||||||
stdReq.RefFileIDs = prependUniqueRefFileID(stdReq.RefFileIDs, fileID)
|
stdReq.RefFileIDs = prependUniqueRefFileID(stdReq.RefFileIDs, fileID)
|
||||||
stdReq.FinalPrompt, stdReq.ToolNames = promptcompat.BuildOpenAIPrompt(messages, stdReq.ToolsRaw, "", stdReq.ToolChoice, stdReq.Thinking)
|
stdReq.FinalPrompt, stdReq.ToolNames = promptcompat.BuildOpenAIPrompt(messages, stdReq.ToolsRaw, "", stdReq.ToolChoice, stdReq.Thinking)
|
||||||
|
stdReq.PromptTokenText = originalPromptTokenText
|
||||||
return stdReq, nil
|
return stdReq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user