-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Feat: Add MultimodalChatWithTools and MultimodalContextAgentInteraction #61963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lukasdotcom
wants to merge
1
commit into
master
Choose a base branch
from
feat/multimodal-provider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+265
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
lib/public/TaskProcessing/TaskTypes/MultimodalChatWithTools.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\TaskProcessing\TaskTypes; | ||
|
|
||
| use OCP\IL10N; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\TaskProcessing\EShapeType; | ||
| use OCP\TaskProcessing\ITaskType; | ||
| use OCP\TaskProcessing\ShapeDescriptor; | ||
|
|
||
| /** | ||
| * This is the task processing task type for invoking multimodal Chat-enabled LLMs with tool call support | ||
| * @since 35.0.0 | ||
| */ | ||
| class MultimodalChatWithTools implements ITaskType { | ||
| /** | ||
| * @since 35.0.0 | ||
| */ | ||
| public const ID = 'core:text2text:multimodal-chatwithtools'; | ||
|
|
||
| private IL10N $l; | ||
|
|
||
| /** | ||
| * @param IFactory $l10nFactory | ||
| * @since 35.0.0 | ||
| */ | ||
| public function __construct( | ||
| IFactory $l10nFactory, | ||
| ) { | ||
| $this->l = $l10nFactory->get('lib'); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getName(): string { | ||
| // TRANSLATORS Tool calling, also known as function calling, is a structured way to give LLMs the ability to make requests back to the application that called it. You define the tools you want to make available to the model, and the model will make tool requests to your app as necessary to fulfill the prompts you give it. | ||
| return $this->l->t('Chat with tools using attachments'); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getDescription(): string { | ||
| // TRANSLATORS Tool calling, also known as function calling, is a structured way to give LLMs the ability to make requests back to the application that called it. You define the tools you want to make available to the model, and the model will make tool requests to your app as necessary to fulfill the prompts you give it. | ||
| return $this->l->t('Chat with the language model with tool calling support and attachments.'); | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getId(): string { | ||
| return self::ID; | ||
| } | ||
|
|
||
| /** | ||
| * @return ShapeDescriptor[] | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getInputShape(): array { | ||
| return [ | ||
| 'system_prompt' => new ShapeDescriptor( | ||
| $this->l->t('System prompt'), | ||
| $this->l->t('Define rules and assumptions that the assistant should follow during the conversation.'), | ||
| EShapeType::Text | ||
| ), | ||
| 'input' => new ShapeDescriptor( | ||
| $this->l->t('Chat message'), | ||
| $this->l->t('Describe a task that you want the assistant to do or ask a question'), | ||
| EShapeType::Text | ||
| ), | ||
| 'input_attachments' => new ShapeDescriptor( | ||
| $this->l->t('Input attachments'), | ||
| $this->l->t('Files to send along with the chat message.'), | ||
| EShapeType::ListOfFiles | ||
| ), | ||
| 'tool_message' => new ShapeDescriptor( | ||
| $this->l->t('Tool message'), | ||
| $this->l->t('The result of tool calls in the last interaction'), | ||
| EShapeType::Text | ||
| ), | ||
| 'history' => new ShapeDescriptor( | ||
| $this->l->t('Chat history'), | ||
| $this->l->t('The history of chat messages before the current message, starting with a message by the user'), | ||
| EShapeType::ListOfTexts | ||
| ), | ||
| // See https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools for the format | ||
| 'tools' => new ShapeDescriptor( | ||
| // TRANSLATORS Tool calling, also known as function calling, is a structured way to give LLMs the ability to make requests back to the application that called it. You define the tools you want to make available to the model, and the model will make tool requests to your app as necessary to fulfill the prompts you give it. | ||
| $this->l->t('Available tools'), | ||
| $this->l->t('The available tools in JSON format'), | ||
| EShapeType::Text | ||
| ), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @return ShapeDescriptor[] | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getOutputShape(): array { | ||
| return [ | ||
| 'output' => new ShapeDescriptor( | ||
| $this->l->t('Generated response'), | ||
| $this->l->t('The response from the chat model'), | ||
| EShapeType::Text | ||
| ), | ||
| 'output_attachments' => new ShapeDescriptor( | ||
| $this->l->t('Output attachments'), | ||
| $this->l->t('Files generated by the model.'), | ||
| EShapeType::ListOfFiles | ||
| ), | ||
| 'tool_calls' => new ShapeDescriptor( | ||
| $this->l->t('Tool calls'), | ||
| $this->l->t('Tools call instructions from the model in JSON format'), | ||
| EShapeType::Text | ||
| ), | ||
|
marcelklehr marked this conversation as resolved.
|
||
| ]; | ||
| } | ||
| } | ||
126 changes: 126 additions & 0 deletions
126
lib/public/TaskProcessing/TaskTypes/MultimodalContextAgentInteraction.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCP\TaskProcessing\TaskTypes; | ||
|
|
||
| use OCP\IL10N; | ||
| use OCP\L10N\IFactory; | ||
| use OCP\TaskProcessing\EShapeType; | ||
| use OCP\TaskProcessing\IInternalTaskType; | ||
| use OCP\TaskProcessing\ShapeDescriptor; | ||
|
|
||
| /** | ||
| * This is the task processing task type for multimodal Context Agent interaction | ||
| * @since 35.0.0 | ||
| */ | ||
| class MultimodalContextAgentInteraction implements IInternalTaskType { | ||
| /** | ||
| * @since 35.0.0 | ||
| */ | ||
| public const ID = 'core:contextagent:multimodal-interaction'; | ||
|
|
||
| private IL10N $l; | ||
|
|
||
| /** | ||
| * @param IFactory $l10nFactory | ||
| * @since 35.0.0 | ||
| */ | ||
| public function __construct( | ||
| IFactory $l10nFactory, | ||
| ) { | ||
| $this->l = $l10nFactory->get('lib'); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getName(): string { | ||
| return 'ContextAgent multimodal'; // We do not translate this | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getDescription(): string { | ||
| return $this->l->t('Chat with an agent using attachments'); | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getId(): string { | ||
| return self::ID; | ||
| } | ||
|
|
||
| /** | ||
| * @return ShapeDescriptor[] | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getInputShape(): array { | ||
| return [ | ||
| 'input' => new ShapeDescriptor( | ||
| $this->l->t('Chat message'), | ||
| $this->l->t('A chat message to send to the agent.'), | ||
| EShapeType::Text | ||
| ), | ||
| 'input_attachments' => new ShapeDescriptor( | ||
| $this->l->t('Input attachments'), | ||
| $this->l->t('Files to send along with the chat message.'), | ||
| EShapeType::ListOfFiles | ||
| ), | ||
| 'confirmation' => new ShapeDescriptor( | ||
| $this->l->t('Confirmation'), | ||
| $this->l->t('Whether to confirm previously requested actions: 0 for denial and 1 for confirmation.'), | ||
| EShapeType::Number | ||
| ), | ||
| 'conversation_token' => new ShapeDescriptor( | ||
| $this->l->t('Conversation token'), | ||
| $this->l->t('A token representing the conversation.'), | ||
| EShapeType::Text | ||
| ), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about adding memories here directly? |
||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @return ShapeDescriptor[] | ||
| * @since 35.0.0 | ||
| */ | ||
| #[\Override] | ||
| public function getOutputShape(): array { | ||
| return [ | ||
| 'output' => new ShapeDescriptor( | ||
| $this->l->t('Generated response'), | ||
| $this->l->t('The response from the chat model.'), | ||
| EShapeType::Text | ||
| ), | ||
| 'output_attachments' => new ShapeDescriptor( | ||
| $this->l->t('Output attachments'), | ||
| $this->l->t('Files generated by the agent.'), | ||
| EShapeType::ListOfFiles | ||
| ), | ||
| 'conversation_token' => new ShapeDescriptor( | ||
| $this->l->t('The new conversation token'), | ||
| $this->l->t('Send this along with the next interaction.'), | ||
| EShapeType::Text | ||
| ), | ||
| 'actions' => new ShapeDescriptor( | ||
| $this->l->t('Requested actions by the agent'), | ||
| $this->l->t('Actions that the agent would like to carry out in JSON format.'), | ||
| EShapeType::Text | ||
| ), | ||
| ]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about adding sources here directly? |
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.