Fix systemPrompt and context working

This commit is contained in:
Petr Mironychev
2024-11-16 10:20:57 +01:00
committed by GitHub
parent 7af8fc2ddc
commit 5e813ba402
12 changed files with 31 additions and 44 deletions

View File

@ -207,9 +207,15 @@ LLMCore::ContextData DocumentContextReader::prepareContext(int lineNumber, int c
{
QString contextBefore = getContextBefore(lineNumber, cursorPosition);
QString contextAfter = getContextAfter(lineNumber, cursorPosition);
QString instructions = getInstructions();
return {contextBefore, contextAfter, instructions};
QString fileContext;
if (Settings::codeCompletionSettings().useFilePathInContext())
fileContext += getLanguageAndFileInfo();
if (Settings::codeCompletionSettings().useProjectChangesCache())
fileContext += ChangesManager::instance().getRecentChangesContext(m_textDocument);
return {contextBefore, contextAfter, fileContext};
}
QString DocumentContextReader::getContextBefore(int lineNumber, int cursorPosition) const
@ -239,17 +245,4 @@ QString DocumentContextReader::getContextAfter(int lineNumber, int cursorPositio
}
}
QString DocumentContextReader::getInstructions() const
{
QString instructions;
if (Settings::codeCompletionSettings().useFilePathInContext())
instructions += getLanguageAndFileInfo();
if (Settings::codeCompletionSettings().useProjectChangesCache())
instructions += ChangesManager::instance().getRecentChangesContext(m_textDocument);
return instructions;
}
} // namespace QodeAssist