Add ChatProcessor
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3492940. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
Related to !1009
>>>
<p>--- AI TRACKER METADATA ---<br>
Update Summary: Add Chat Consumer<br>
Check-in Date: MM/DD/YYYY (US format) [When we should see progress/get an update]<br>
Due Date: MM/DD/YYYY (US format) [When the issue should be fully completed]<br>
Blocked by: [#XXXXXX] (New issues on new lines)<br>
Additional Collaborators: @username1, @username2<br>
AI Tracker found here: <a href="https://www.drupalstarforge.ai/">https://www.drupalstarforge.ai/</a><br>
--- END METADATA ---</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Currently the AI Assistant API is coupled with the AI Chatbot, but we should be able to decouple this by adding a plugin interface for the Chatbot that anyone can extend. One of the questions we get a lot is to setup a naive RAG funcitonality with the chatbot, so that should be possible.</p>
<p>AI Assistants API will be refactored and put into AI Agents in 2.0, but we should still try to make sure that all the possible use cases can be handled by the agent.</p>
<p>We will separate the styling configurations from the plugin configurations, meaning that the plugin system should have a subform and its own configuration that can be stored on the Chatbot system setup.</p>
<p>We discussed this during DrupalCon Vienna and the general conclussion is that we open it up completely for anyone wanting to create some kind of integration, but we do not split it out of AI module, so we can ty it to ChatInput and ChatOutput.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Create an attribute called ChatConsumer that has label, description.</li>
<li>Create a pluginmanager that looks for ChatConsumers under src/Plugin/ChatConsumer</li>
<li>Create an interface that has setInput, getInput, setOutput, getOutput, doExecute, setThreadId, getThreadId, setFinished, getFinished.</li>
<li>Interface should use ConfigurableInterface and PluginFormInterface.</li>
<li>Create an base class that has execute that is running doExecute and that sets all the get and set methods.</li>
<li>This means that the chatbot has to be able to to stream its output as well.</li>
<li>On the interface add allowedFileExtensions that takes an array of allowed file extentions that the consumer can use.</li>
</ul>
<h3>New settings for the general form</h3>
<ul>
<li>Show tools usage.</li>
<li>Turn off CSRF - should come with warning text (or we can look into implementing our own CSRF that doesn't require sessions).</li>
</ul>
<h3>Interface descriptions</h3>
<p>setInput(ChatInput)<br>
Set the input to use for exeuction.</p>
<p>getInput(): ChatInput<br>
Gets the input to use for execution.</p>
<p>setOutput(ChatOutput)<br>
Sets the output to use for execution</p>
<p>getOutput(): ChatOutput<br>
Gets the output to use for execution.</p>
<p>doExecute()<br>
Executes the plugin.</p>
<p>setThreadId(string)<br>
Optional, to be able to set a thread id to the current process.</p>
<p>getThreadId(): string<br>
Optional, to be able to get a thread id to the current process.</p>
<p>setFinished(bool)<br>
Sets the output to finished, so the Chatbot doesn't need to poll again. Defaults to true. Only set to false on looping agents, where each step should be called via the chatbot to see progress.</p>
<p>setInputFiles(array<genericfile>)<br>
Options, sets the files that are not images to the input. Images should be set in ChatInput.</genericfile></p>
<p>allowedFileExtensions(): array<string><br>
Sets the allowed file extensions if any that a chat consumer can take.</string></p>
<p>allowsImages(): boolean<br>
Sets if images are allowed to be used in the chatinput.</p>
<p>getFinished() bool<br>
See above.</p>
issue