feat: Add ollama thinking feature (#275)

This commit is contained in:
Petr Mironychev
2025-11-26 10:32:04 +01:00
committed by GitHub
parent dc6ec4fb4f
commit b4f31dee23
7 changed files with 212 additions and 8 deletions

View File

@ -31,6 +31,8 @@ public:
void handleContentDelta(const QString &content);
void handleToolCall(const QJsonObject &toolCall);
void handleThinkingDelta(const QString &thinking);
void handleThinkingComplete(const QString &signature);
void handleDone(bool done);
QJsonObject toProviderFormat() const;
@ -38,6 +40,7 @@ public:
LLMCore::MessageState state() const { return m_state; }
QList<LLMCore::ToolUseContent *> getCurrentToolUseContent() const;
QList<LLMCore::ThinkingContent *> getCurrentThinkingContent() const;
QList<LLMCore::ContentBlock *> currentBlocks() const { return m_currentBlocks; }
void startNewContinuation();
@ -48,11 +51,13 @@ private:
QList<LLMCore::ContentBlock *> m_currentBlocks;
QString m_accumulatedContent;
bool m_contentAddedToTextBlock = false;
LLMCore::ThinkingContent *m_currentThinkingContent = nullptr;
void updateStateFromDone();
bool tryParseToolCall();
bool isLikelyToolCallJson(const QString &content) const;
LLMCore::TextContent *getOrCreateTextContent();
LLMCore::ThinkingContent *getOrCreateThinkingContent();
template<typename T, typename... Args>
T *addCurrentContent(Args &&...args)