diff --git a/appinfo/info.xml b/appinfo/info.xml index 9926c48a0..b29a1c2f4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -62,7 +62,7 @@ Known providers: More details on how to set this up in the [admin docs](https://docs.nextcloud.com/server/latest/admin_manual/ai/index.html) ]]> - 3.5.0-dev.2 + 3.5.0-dev.3 agpl Julien Veyssier Assistant diff --git a/lib/Db/ChattyLLM/Message.php b/lib/Db/ChattyLLM/Message.php index c94611e8c..a68c4319a 100644 --- a/lib/Db/ChattyLLM/Message.php +++ b/lib/Db/ChattyLLM/Message.php @@ -26,7 +26,9 @@ * @method \string|null getSources() * @method \void setSources(?string $sources) * @method \string|null getAttachments() - * @method \void setAttachments(?string $attachments) + * @method \void setAttachments(?string $reasoning) + * @method \string|null getReasoning() + * @method \void setReasoning(?string $reasoning) */ class Message extends Entity implements \JsonSerializable { public const ROLE_HUMAN = 'human'; @@ -48,6 +50,8 @@ class Message extends Entity implements \JsonSerializable { protected $sources; /** @var ?string */ protected $attachments; + /** @var string */ + protected $reasoning; public static $columns = [ 'id', @@ -58,6 +62,7 @@ class Message extends Entity implements \JsonSerializable { 'ocp_task_id', 'sources', 'attachments', + 'reasoning', ]; public static $fields = [ 'id', @@ -68,6 +73,7 @@ class Message extends Entity implements \JsonSerializable { 'ocpTaskId', 'sources', 'attachments', + 'reasoning', ]; public function __construct() { @@ -78,6 +84,7 @@ public function __construct() { $this->addType('ocpTaskId', Types::INTEGER); $this->addType('sources', Types::STRING); $this->addType('attachments', Types::STRING); + $this->addType('reasoning', Types::STRING); } #[\ReturnTypeWillChange] @@ -90,6 +97,7 @@ public function jsonSerialize() { 'timestamp' => $this->timestamp, 'ocp_task_id' => $this->ocpTaskId, 'sources' => $this->sources, + 'reasoning' => $this->reasoning, 'attachments' => $this->attachments === null ? [] : (json_decode($this->attachments, true) ?: []), diff --git a/lib/Listener/ChattyLLMTaskListener.php b/lib/Listener/ChattyLLMTaskListener.php index cbb7e4cb6..9f8609487 100644 --- a/lib/Listener/ChattyLLMTaskListener.php +++ b/lib/Listener/ChattyLLMTaskListener.php @@ -123,6 +123,8 @@ public function handle(Event $event): void { } else { $content = trim($taskOutput['output'] ?? ''); $message->setContent($content); + $reasoning = trim($taskOutput['reasoning'] ?? ''); + $message->setReasoning($reasoning); // the task is not an audio one, but we might still need to Tts the answer // if it is a response to a ContextAgentInteraction confirmation that was asked about an audio message $this->runTtsIfNeeded($sessionId, $message, $taskTypeId, $task->getUserId()); diff --git a/lib/Migration/Version030500Date20260630083738.php b/lib/Migration/Version030500Date20260630083738.php new file mode 100644 index 000000000..374382f9c --- /dev/null +++ b/lib/Migration/Version030500Date20260630083738.php @@ -0,0 +1,43 @@ +hasTable('assistant_chat_msgs')) { + $table = $schema->getTable('assistant_chat_msgs'); + if (!$table->hasColumn('reasoning')) { + $table->addColumn('reasoning', Types::TEXT, [ + 'notnull' => false, + ]); + $schemaChanged = true; + } + } + + return $schemaChanged ? $schema : null; + } +} diff --git a/src/components/ChattyLLM/ChattyLLMInputForm.vue b/src/components/ChattyLLM/ChattyLLMInputForm.vue index 074fe8496..da2b310c7 100644 --- a/src/components/ChattyLLM/ChattyLLMInputForm.vue +++ b/src/components/ChattyLLM/ChattyLLMInputForm.vue @@ -1068,16 +1068,18 @@ export default { }) }, - updateStreamingMessage({ output, sources }, sessionId) { + updateStreamingMessage({ output, sources, reasoning }, sessionId) { if (this.streamingMessage) { this.streamingMessage.content = output this.streamingMessage.sources = sources + this.streamingMessage.reasoning = reasoning } else { this.streamingMessage = { role: Roles.ASSISTANT, content: output, attachments: [], sources, + reasoning, session_id: sessionId, id: 0, timestamp: moment().unix(), diff --git a/src/components/ChattyLLM/Message.vue b/src/components/ChattyLLM/Message.vue index 1e95a5888..fa05f8019 100644 --- a/src/components/ChattyLLM/Message.vue +++ b/src/components/ChattyLLM/Message.vue @@ -3,7 +3,7 @@ - SPDX-License-Identifier: AGPL-3.0-or-later -->