- Issue created by @nicxvan
- 🇺🇸United States nicxvan
I tracked down the issue, in OpenAiStringLong.php
storeValues just passes the array to the entity set.Ideally we could ether configure the expected response or we could implode the values, adding $values = implode(' ', $values); in there merges everything into one field.
- First commit to issue fork.
- Status changed to Needs review
7 months ago 5:55am 9 May 2024 - 🇮🇳India mukhtarm
@nicxvan Created an MR to address the changes. Please review.
- 🇩🇪Germany marcus_johansson
Hi @nicxvan - this works like that on purpose, for instance think off the use case that you have one website link that you use as context to scrape into one text area and from that you want to generate 10 search words to use the SERP module to verify the exactness of the claims of the first website. In other cases it is the only way to do it, since you can't concatinate images
How I have done it when I actually want 10 responses in one text field is to prompt it - "give me back as one comma separated value".
However it is not very clearly communicated, and for textual fields your idea makes total sense as a configuration. I would add a configuration for it where its disabled by default, but then you can choose possible joiners (",", "\n", "\t", " " etc.) and even choose "other" if you want to add your own. Sounds usable?
- 🇩🇪Germany marcus_johansson
@MukhtarM - if @nicxvan agrees with the configuration idea and you want credit for the fix, I would write a comment on the merge request with the fixes needed and hand it back to you. If not, let me know and I'll take it over.
- Status changed to Active
7 months ago 10:58am 9 May 2024 - 🇺🇸United States nicxvan
Yeah I think making it configurable would be great!
For the record I did try prompting it to send it to me as a comma separated value before posting and is still put them in separate objects.
- 🇩🇪Germany marcus_johansson
@nicxvan - perfect, regarding the prompting, AI is not very determenistic even at low temperatures, so this sounds like a great solution for this problem :)
@MukhtarM - so below are the tasks that would be needed to be fixed in the ticket. If you want to do it, please feel free. I know its a lot of tasks for one single credit and it also touches two modules, but if you want to get to know the project its an interesting ticket. Also if you want, I could setup a meeting and show you around where stuff gets changed if you have interest in contributing to the project in the future. I could also setup another ticket for the AI Interpolator core changes, that would give you another credit.
I would probably take over the ticket by next week if I don't get an answer from you, since I want to prioritize tickets where someone is actually using it in production.
TODO
Reason
On all the textual responses for complex LLMs we currently are asking the AI to generate an array of values. For complex fields like link, email or a graph, the reasoning is simple - you can't put it in one big blob. But for textual responses, this is an actual option that the user expects - more so if the cardinality of the field is 1.
Changes needed
- On the AI Interpolator module, in the general helper service, add an helper function that takes a plugin prefix as a required variable and that generates two form fields with the prefix..
- One that is pre chosen join values (',', ' ', "\n", "\t") and a final option that is other.
- The other is a text field that is only visible when other is chosen (use AJAX form states)
- Create another function in the general helper service that takes the values from these two fields and the generated values and implodes them an returns.
- In the AI Interpolator OpenAI, on the following rules, add this to the form and to the generation: String, StringLong, Text, TextLong, TextLongWithSummary, VideoToString, VideoToText, AudioToString, AudioToText
- (to maintiner/@marcus_johansson) Make sure that the composer version dependency of the AI Interpolator Core is raised in the AI Interpolator OpenAI
- 🇮🇳India mukhtarm
Hi, @Marcus_Johansson thanks for the detailed response. I like to work on the tasks you mentioned, But probably I need to get more on the module workflow and related modules (Also I might need a test API key to test things out). Thanks.
- 🇩🇪Germany marcus_johansson
Perfect @MukhtarM - do you want to have a meeting where I can show you where som stuff is or do you think you can figure it out yourself? I would provide you with an API key while you are fixing the issue.
@Marcus - please let me know if Mukhtar should take this complex ticket (2 modules) fixing text responses for LLMs or wait for a simpler one next week. I would be very happy if you could let me know, thanks
- 🇩🇪Germany marcus_johansson
Sorry, my fault - I was busy with other stuff and forgot this ticket. @MukhtarM - the DM might be in my spambox. Could you mail drupal@marcusmailbox.com and I'll setup something.
- 🇮🇳India mukhtarm
Hi, @Marcus sent you that mail, and as suggested by @sandy we could start with a simpler one :)
- 🇩🇪Germany marcus_johansson
So, we had a discussion now and since this tickets touches core, I will take over this for now and then for future ticket @MuktharM will help out when he wants/is available.
- Assigned to marcus_johansson
-
Marcus_Johansson →
committed a4460322 on 1.0.x
Issue #3446162 by Marcus_Johansson, nicxvan: The response from open ai...
-
Marcus_Johansson →
committed a4460322 on 1.0.x
- Status changed to Needs review
7 months ago 1:51pm 19 May 2024 - 🇩🇪Germany marcus_johansson
@nicxvan - This should be testable if you get the OpenAI plugin and the core module in DEV versions. This fix also makes it possible to add temperature, max tokens and some other parameters on most OpenAI rules.
Its a refactor to reusable code for all LLMs, so it will need some more work for the more complex rules to be exposed to the extra form fields, before release, but the normal text fields everything should work.
- 🇩🇪Germany marcus_johansson
This is also dependent on changes on https://www.drupal.org/project/ai_interpolator/issues/3448110 ✨ Add helper functions and form helper functions for joining text fields. Fixed and https://www.drupal.org/project/ai_interpolator/issues/3448111 ✨ Add helper function to fill out HTML text fields Fixed
- Status changed to Needs work
7 months ago 3:12pm 20 May 2024 - 🇺🇸United States nicxvan
Ok I had a chance to check this, and I ran into the following issues:
First I updated ai_interpolator and ai_interpolator_openai and dependencies.
Current versions:
drupal/openai (1.0.0-beta5)
drupal/ai_interpolator (dev-1.0.x a9b4c7c)
drupal/ai_interpolator_openai (dev-1.0.x a446032)
Ran db updates (none)
Cleared cacheTest 1.
I checked the json field rule and saw no new options. Based on your comment I'm not sure if you added this to the json rule yet.Test 2.
I created a new long plain text field and had the following issues.
1. I cannot select the field I want as the base field, only the file is available.
2. There are no new options, and several of the existing options are gone (e.g. to add the prompt)
3. Several console errors:TypeError: Drupal\ai_interpolator\Rulehelpers\GeneralHelper::__construct(): Argument #4 ($token) must be of type Drupal\Core\Utility\Token, Drupal\token\TreeBuilder given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\ai_interpolator\Rulehelpers\GeneralHelper->__construct() (line 81 of /var/www/html/web/modules/contrib/ai_interpolator/src/Rulehelpers/GeneralHelper.php).
AssertionError: The file specified by the given app root, relative path and file name (/var/www/html/web/modules/contrib/openai/openai.info.yml) do not exist. in assert() (line 73 of /var/www/html/web/core/lib/Drupal/Core/Extension/Extension.php) #0 /var/www/html/web/core/lib/Drupal/Core/Extension/Extension.php(73): assert(false, 'The file specif...') #1 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(114): Drupal\Core\Extension\Extension->__construct('/var/www/html/w...', 'module', 'modules/contrib...', NULL) #2 /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\Core\Extension\ModuleHandler->__construct('/var/www/html/w...', Array, Object(Drupal\Core\Cache\ChainedFastBackend))
- Status changed to Needs review
7 months ago 3:16pm 20 May 2024 - 🇺🇸United States nicxvan
I think something went wrong with my composer command I just deleted all three modules and reinstalled and now I see the options.
I am going to test again now.
- 🇺🇸United States nicxvan
Ok I still do not see the options on the JSON field, but I do see them on a plain text long field.
I see temperature, max tokens, AI Top P, Frequency penalty, Presence penalty, Joiner as new options.
I no longer see the ability to dump the full response.
I am not able to get the response I was getting in the JSON field, I only get:
`requested value`I am using the defaults for the settings except I bumped temperature to 1.
-
Marcus_Johansson →
committed 00ee0b0d on 1.0.x
Issue #3446162 by Marcus_Johansson, nicxvan: The response from open ai...
-
Marcus_Johansson →
committed 00ee0b0d on 1.0.x
- 🇩🇪Germany marcus_johansson
@nicxvan - no all field types that the OpenAI field does, should have been updated. Some of them like Transcribe Audio and Video to Video will not have the options, because the models does not take them.
This should also fix the JSON field and also make all the none Transcribe and Video feeds possible to add to any model with little to no works (meaning you could soon try JSON field with some cheaper models).
The latest changes are on the latest DEV versions.
I will try to fix this ticket as well, then there would be a new release if all of the tests works: https://www.drupal.org/project/ai_interpolator_openai/issues/3432536 ✨ Image style option for GPT Vision Active
Next step is to add autotest all the rules using actual functional testing.
- 🇺🇸United States nicxvan
The options all seem to be there!
Joining results for long text doesn't seem to work, and I don't see the option to output the result for long text, but the JSON field is working perfectly!
- 🇩🇪Germany marcus_johansson
The simple output for any text field I added a separate ticket for and its fixed in latest DEV now (needs AI Interpolator latest DEV as well): https://www.drupal.org/project/ai_interpolator_openai/issues/3449252 ✨ Add simple text fields Fixed
For the joining I get it to work on text long at least - could you give back the setup you are using, thanks?
Joiner Settings:
Output: