Minor modifications.

This commit is contained in:
Martín Lucas Golini
2025-03-15 22:42:26 -03:00
parent 6d4dd5f611
commit 770afa4a23
3 changed files with 21 additions and 7 deletions

View File

@@ -124,6 +124,15 @@ AIAssistantPlugin::~AIAssistantPlugin() {
getPluginContext()->getConfig().removeTabWidgetType( "llm_chatui" );
}
std::string AIAssistantPlugin::getPluginStatePath() const {
return getManager()->getPluginsPath() + "state" + FileSystem::getOSSlash() + "aiassistant" +
FileSystem::getOSSlash();
}
std::string AIAssistantPlugin::getConversationsPath() const {
return getPluginStatePath() + "chats" + FileSystem::getOSSlash();
}
void AIAssistantPlugin::load( PluginManager* pluginManager ) {
Clock clock;
AtomicBoolScopedOp loading( mLoading, true );

View File

@@ -30,6 +30,10 @@ class AIAssistantPlugin : public PluginBase {
const LLMProviders& getProviders() { return mProviders; }
std::string getPluginStatePath() const;
std::string getConversationsPath() const;
protected:
LLMProviders mProviders;
bool mUIInit{ false };

View File

@@ -13,6 +13,7 @@
#include <eepp/window/clipboard.hpp>
#include <eepp/window/window.hpp>
#include <chrono>
#include <nlohmann/json.hpp>
using namespace EE::System;
@@ -412,6 +413,9 @@ nlohmann::json LLMChatUI::serialize() {
nlohmann::json j;
j["uuid"] = mUUID.toString();
j["chat"] = serializeChat( mCurModel );
j["provider"] = mCurModel.provider;
j["timestamp"] = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() );
j["summary"] = mSummary;
return j;
}
@@ -421,13 +425,10 @@ void LLMChatUI::saveChat() {
auto plugin = getPlugin();
if ( plugin == nullptr )
return;
std::string pluginsStatePath( plugin->getManager()->getPluginsPath() + "plugins_state" +
FileSystem::getOSSlash() + "aiassistant" +
FileSystem::getOSSlash() );
if ( !FileSystem::fileExists( pluginsStatePath ) )
FileSystem::makeDir( pluginsStatePath, true );
std::string path( pluginsStatePath + mSummary + ".json" );
std::string conversationsPath = plugin->getConversationsPath();
if ( !FileSystem::fileExists( conversationsPath ) )
FileSystem::makeDir( conversationsPath, true );
std::string path( conversationsPath + mUUID.toString() + " - " + mSummary + ".json" );
FileSystem::fileWrite( path, serialize().dump( 2 ) );
}