MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / Assistant

Method Assistant

app/src/AI/Assistant.cpp:52–85  ·  view source on GitHub ↗

* @brief Builds the QNAM, dispatcher, providers, and conversation. */

Source from the content-addressed store, hash-verified

50 * @brief Builds the QNAM, dispatcher, providers, and conversation.
51 */
52AI::Assistant::Assistant()
53 : QObject(nullptr)
54 , m_currentProvider(0)
55 , m_cacheReadTokens(0)
56 , m_cacheCreatedTokens(0)
57 , m_autoApproveEdits(false)
58 , m_allowDeviceControl(false)
59{
60 m_nam = std::make_unique<QNetworkAccessManager>(this);
61 m_dispatcher = std::make_unique<ToolDispatcher>(this);
62 m_conversation = std::make_unique<Conversation>(this);
63
64 rebuildProviders();
65 restoreModelSelections();
66
67 const int storedProvider = m_settings.value(QStringLiteral("ai/currentProvider"), 0).toInt();
68 if (storedProvider >= 0 && storedProvider < kProviderCount)
69 m_currentProvider = storedProvider;
70
71 m_autoApproveEdits = m_settings.value(QStringLiteral("ai/autoApproveEdits"), false).toBool();
72
73 m_allowDeviceControl = m_settings.value(QStringLiteral("ai/allowDeviceControl"), false).toBool();
74 CommandRegistry::instance().setDeviceControlAllowed(m_allowDeviceControl);
75
76 m_conversation->setDispatcher(m_dispatcher.get());
77 rewireConversationProvider();
78
79 connect(
80 m_conversation.get(), &Conversation::busyChanged, this, &Assistant::onConversationBusyChanged);
81 connect(
82 m_conversation.get(), &Conversation::errorOccurred, this, &Assistant::onConversationError);
83
84 initChats();
85}
86
87/**
88 * @brief Persists the active chat, then releases owned resources.

Callers

nothing calls this directly

Calls 4

setDispatcherMethod · 0.80
valueMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected