Skip to content

Commit

Permalink
Fix embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
Palm1r committed Oct 28, 2024
1 parent 435d1d6 commit ef3f248
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
6 changes: 1 addition & 5 deletions chatview/ChatRootView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ void ChatRootView::sendEmbeddings(const QString &query)
{
auto &manager = LLMCore::EmbeddingManager::instance();

// Отключаем предыдущие соединения
disconnect(&manager, nullptr, this, nullptr);

// Подключаем обработчики результатов
connect(&manager,
&LLMCore::EmbeddingManager::searchCompleted,
this,
Expand All @@ -105,13 +103,11 @@ void ChatRootView::sendEmbeddings(const QString &query)
});

connect(&manager, &LLMCore::EmbeddingManager::searchError, this, [this](const QString &error) {
// Обработка ошибки поиска
qDebug() << "Search error:" << error;
});

// Запускаем поиск
auto project = ProjectExplorer::ProjectManager::startupProject();
manager.findSimilarCode(query, project);
manager.findSimilarCode(query, project, 0.55f, 5);
}

void ChatRootView::generateColors()
Expand Down
6 changes: 3 additions & 3 deletions llmcore/EmbeddingsGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class EmbeddingsGenerator : public QObject
QJsonObject prepareRequest(const QString &content) const;
QJsonObject prepareMessageRequest(const QString &message) const;

static constexpr const char *MODEL_NAME
= "starcoder2:15b-instruct"; //"starcoder2:15b"; //"all-minilm"; //"starcoder2:7b";
static constexpr const char *BASE_URL = "http://192.168.50.189:11434"; //"http://localhost:11434";
static constexpr const char *MODEL_NAME = "starcoder2:7b";
//"starcoder2:15b-instruct"; //"starcoder2:15b"; //"all-minilm"; //"starcoder2:7b";
static constexpr const char *BASE_URL = "http://localhost:11434";
static constexpr const char *ENDPOINT = "/api/embeddings";
static constexpr const char *QUERY_TEMPLATE = "Convert this question into code context: %1";

Expand Down
8 changes: 1 addition & 7 deletions llmcore/EmbeddingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,7 @@ void EmbeddingManager::findSimilarCode(const QString &query,

for (const auto &result : results) {
searchResults.append(result);
formattedResponse
+= QString("filepath:%1 startLine:%2 endLine:%3 similarity:%4 content:%5")
.arg(result.filePath)
.arg(result.startLine)
.arg(result.endLine)
.arg(result.similarity, 0, 'f', 4)
.arg(result.content);
formattedResponse += result.content;
}

LOG_MESSAGE(QString("Found %1 similar code fragments").arg(results.size()));
Expand Down
4 changes: 2 additions & 2 deletions llmcore/EmbeddingsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class EmbeddingManager : public QObject
QString getEmbeddingsPath(ProjectExplorer::Project *project) const;
void findSimilarCode(const QString &query,
ProjectExplorer::Project *project,
float minSimilarity = 0.65f,
int maxResults = 5);
float minSimilarity,
int maxResults);

signals:
void searchCompleted(const QString &query,
Expand Down

0 comments on commit ef3f248

Please sign in to comment.