feat: Add sharing opened files with code completion requests (#156)

This commit is contained in:
Petr Mironychev
2025-04-04 10:38:06 +02:00
committed by GitHub
parent ffaf6bd61b
commit 9d2d70fc63
9 changed files with 92 additions and 4 deletions

View File

@ -230,6 +230,19 @@ void LLMClientInterface::handleCompletion(const QJsonObject &request)
if (updatedContext.fileContext.has_value())
systemPrompt.append(updatedContext.fileContext.value());
if (m_completeSettings.useOpenFilesContext()) {
if (provider->providerID() == LLMCore::ProviderID::LlamaCpp) {
for (const auto openedFilePath : m_contextManager->openedFiles({filePath})) {
if (!updatedContext.filesMetadata) {
updatedContext.filesMetadata = QList<LLMCore::FileMetadata>();
}
updatedContext.filesMetadata->append({openedFilePath.first, openedFilePath.second});
}
} else {
systemPrompt.append(m_contextManager->openedFilesContext({filePath}));
}
}
updatedContext.systemPrompt = systemPrompt;
if (promptTemplate->type() == LLMCore::TemplateType::Chat) {
@ -330,6 +343,4 @@ void LLMClientInterface::sendCompletionToClient(
emit messageReceived(LanguageServerProtocol::JsonRpcMessage(response));
}
void LLMClientInterface::parseCurrentMessage() {}
} // namespace QodeAssist