|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +namespace OCP\TaskProcessing\TaskTypes; |
| 11 | + |
| 12 | +use OCP\IL10N; |
| 13 | +use OCP\L10N\IFactory; |
| 14 | +use OCP\TaskProcessing\EShapeType; |
| 15 | +use OCP\TaskProcessing\ITaskType; |
| 16 | +use OCP\TaskProcessing\ShapeDescriptor; |
| 17 | + |
| 18 | +/** |
| 19 | + * This is the task processing task type for Context Agent interaction |
| 20 | + * @since 32.0.0 |
| 21 | + */ |
| 22 | +class ContextAgentAudioInteraction implements ITaskType { |
| 23 | + public const ID = 'core:contextagent:audio-interaction'; |
| 24 | + |
| 25 | + private IL10N $l; |
| 26 | + |
| 27 | + /** |
| 28 | + * @param IFactory $l10nFactory |
| 29 | + * @since 32.0.0 |
| 30 | + */ |
| 31 | + public function __construct( |
| 32 | + IFactory $l10nFactory, |
| 33 | + ) { |
| 34 | + $this->l = $l10nFactory->get('lib'); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @inheritDoc |
| 39 | + * @since 32.0.0 |
| 40 | + */ |
| 41 | + public function getName(): string { |
| 42 | + return 'ContextAgent audio'; // We do not translate this |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @inheritDoc |
| 47 | + * @since 32.0.0 |
| 48 | + */ |
| 49 | + public function getDescription(): string { |
| 50 | + return $this->l->t('Chat by voice with an agent'); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @return string |
| 55 | + * @since 32.0.0 |
| 56 | + */ |
| 57 | + public function getId(): string { |
| 58 | + return self::ID; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @return ShapeDescriptor[] |
| 63 | + * @since 32.0.0 |
| 64 | + */ |
| 65 | + public function getInputShape(): array { |
| 66 | + return [ |
| 67 | + 'input' => new ShapeDescriptor( |
| 68 | + $this->l->t('Chat voice message'), |
| 69 | + $this->l->t('Describe a task that you want the agent to do or ask a question.'), |
| 70 | + EShapeType::Audio |
| 71 | + ), |
| 72 | + 'confirmation' => new ShapeDescriptor( |
| 73 | + $this->l->t('Confirmation'), |
| 74 | + $this->l->t('Whether to confirm previously requested actions: 0 for denial and 1 for confirmation.'), |
| 75 | + EShapeType::Number |
| 76 | + ), |
| 77 | + 'conversation_token' => new ShapeDescriptor( |
| 78 | + $this->l->t('Conversation token'), |
| 79 | + $this->l->t('A token representing the conversation.'), |
| 80 | + EShapeType::Text |
| 81 | + ), |
| 82 | + ]; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * @return ShapeDescriptor[] |
| 87 | + * @since 32.0.0 |
| 88 | + */ |
| 89 | + public function getOutputShape(): array { |
| 90 | + return [ |
| 91 | + 'input_transcript' => new ShapeDescriptor( |
| 92 | + $this->l->t('Input transcript'), |
| 93 | + $this->l->t('Transcription of the audio input'), |
| 94 | + EShapeType::Text, |
| 95 | + ), |
| 96 | + 'output' => new ShapeDescriptor( |
| 97 | + $this->l->t('Response voice message'), |
| 98 | + $this->l->t('The generated voice response as part of the conversation'), |
| 99 | + EShapeType::Audio |
| 100 | + ), |
| 101 | + 'output_transcript' => new ShapeDescriptor( |
| 102 | + $this->l->t('Output transcript'), |
| 103 | + $this->l->t('Transcription of the audio output'), |
| 104 | + EShapeType::Text, |
| 105 | + ), |
| 106 | + 'conversation_token' => new ShapeDescriptor( |
| 107 | + $this->l->t('The new conversation token'), |
| 108 | + $this->l->t('Send this along with the next interaction.'), |
| 109 | + EShapeType::Text |
| 110 | + ), |
| 111 | + 'actions' => new ShapeDescriptor( |
| 112 | + $this->l->t('Requested actions by the agent'), |
| 113 | + $this->l->t('Actions that the agent would like to carry out in JSON format.'), |
| 114 | + EShapeType::Text |
| 115 | + ), |
| 116 | + ]; |
| 117 | + } |
| 118 | +} |
0 commit comments