62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
|
|
#include "KIClient.h"
|
|
|
|
namespace KompanionAI {
|
|
|
|
KIClient::KIClient(QObject *parent) : QObject(parent)
|
|
{
|
|
}
|
|
|
|
KIProvider* KIClient::provider() const
|
|
{
|
|
return m_provider;
|
|
}
|
|
|
|
void KIClient::setProvider(KIProvider* provider)
|
|
{
|
|
if (m_provider != provider) {
|
|
m_provider = provider;
|
|
emit providerChanged();
|
|
}
|
|
}
|
|
|
|
QString KIClient::defaultModel() const
|
|
{
|
|
return m_defaultModel;
|
|
}
|
|
|
|
void KIClient::setDefaultModel(const QString& model)
|
|
{
|
|
if (m_defaultModel != model) {
|
|
m_defaultModel = model;
|
|
emit defaultModelChanged();
|
|
}
|
|
}
|
|
|
|
QFuture<KIReply*> KIClient::chat(const KIThread& thread, const KIChatOptions& opts)
|
|
{
|
|
if (!m_provider) {
|
|
// TODO: Handle error: no provider set
|
|
return QFuture<KIReply*>();
|
|
}
|
|
return m_provider->chat(thread, opts);
|
|
}
|
|
|
|
QFuture<KIEmbeddingResult> KIClient::embed(const QStringList& texts, const KIEmbedOptions& opts)
|
|
{
|
|
if (!m_provider) {
|
|
// TODO: Handle error: no provider set
|
|
return QFuture<KIEmbeddingResult>();
|
|
}
|
|
return m_provider->embed(texts, opts);
|
|
}
|
|
|
|
void KIClient::cancel(quint64 requestId)
|
|
{
|
|
if (m_provider) {
|
|
m_provider->cancel(requestId);
|
|
}
|
|
}
|
|
|
|
} // namespace KompanionAI
|