logGptRequest function
void
logGptRequest({})
Logs the GPT request and response to a file.
Implementation
void logGptRequest({
required I18nLocale fromLocale,
required I18nLocale toLocale,
required String fromFile,
required String toFile,
required String outDir,
required int promptCount,
required GptPrompt prompt,
required GptResponse response,
}) {
final path = PathUtils.withFileName(
directoryPath: outDir,
fileName: '_gpt_${promptCount.toString().padLeft(2, '0')}.txt',
pathSeparator: Platform.pathSeparator,
);
FileUtils.writeFile(
path: path,
content: '''
### Meta ###
From: <${fromLocale.languageTag}> $fromFile
To: <${toLocale.languageTag}> $toFile
### Tokens ###
Input: ${response.promptTokens}
Output: ${response.completionTokens}
Total: ${response.totalTokens}
### Conversation ###
>> System:
${prompt.system}
>> User:
${prompt.user}
>> Assistant:
${response.rawMessage}
### JSON ###
Input:
${_encoder.convert(prompt.userJSON)}
Output:
${_encoder.convert(response.jsonMessage)}
''',
);
print(' -> Logs: $path');
}