Problem/Motivation
Currently, the assignment of default values is hardcoded for the following operation types:
- chat
- chat_with_image_vision
- chat_with_complex_json
- text_to_image
- embeddings
- text_to_speech
- speech_to_text
- moderation
The 1.1.x version of the AI module has some additional operation types:
- Chat with Structured Response
- Chat with Tools/Function Calling
These additional ones needs to be handled or would be better if we can have this list of operation type dynamic so that every time there's is modification to these could be handled automatically.
Steps to reproduce
modules/contrib/ai_provider_openai/src/Form/OpenAiConfigForm.php
$this->aiProviderManager->defaultIfNone('chat', 'openai', 'gpt-4o');
$this->aiProviderManager->defaultIfNone('chat_with_image_vision', 'openai', 'gpt-4o');
$this->aiProviderManager->defaultIfNone('chat_with_complex_json', 'openai', 'gpt-4o');
$this->aiProviderManager->defaultIfNone('text_to_image', 'openai', 'dall-e-3');
$this->aiProviderManager->defaultIfNone('embeddings', 'openai', 'text-embedding-3-small');
$this->aiProviderManager->defaultIfNone('text_to_speech', 'openai', 'tts-1-hd');
$this->aiProviderManager->defaultIfNone('speech_to_text', 'openai', 'whisper-1');
$this->aiProviderManager->defaultIfNone('moderation', 'openai', 'omni-moderation-latest');
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | config-ai-settings.png | 359.52 KB | ishani patel |
Issue fork ai_provider_openai-3521901
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
prabha1997 commentedComment #4
prabha1997 commentedI’ve added a dynamic implementation to set the default provider and model ID for each operation type.
Comment #5
ishani patel commentedI've checked with 1.1. x of the AI branch, and it is working as expected. Please refer to the attached screenshot.
Thank you!
Comment #6
prashant.cLeft some review comments, moving to NW. Kindly address those and move back to NR.
Comment #7
prabha1997 commentedComment #8
marcus_johansson commentedI don't think they should be dynamically set in the providers with known choices - these are editorial choices of models that fit as the best possible model for tested use cases like Drupal CMS agents, but still cheap. gpt-4 was always better than gpt-4o on text tasks, but we still choose 4o because it was faster and cheaper.
In many providers we do not even set these, because they are not up to the standards for every operation type.
The question is if its time to bump up all the chat_with_complex_json, chat_with_structured_json, chat_with_tools to 4.1 since its cheaper and better (not tested with Drupal CMS yet).
WDYT?
Techincally the code looks good, just wondering if it makes sense since the order coming back could in theory pick 3.5 turbo on json and tool calling, since its possible.
Comment #9
marcus_johansson commentedA way to cleanup code is to add it here and then link to this in the form?
Comment #10
prabha1997 commentedThank you for the feedback! As of now, I’m getting the default models from the plugin and have set them dynamically like this. Please review this approach. I understand your point about editorial choices, and regarding bumping models to GPT-4.1, we can wait until the tests with Drupal CMS are completed. Once we have more insights, we can make the necessary changes.
Comment #11
marcus_johansson commentedI did some initial tests with 4.1 vs 4o and they work more or less the same on the small data set I've tested against: https://docs.google.com/spreadsheets/d/1IfWlRhlq2E4Lh5R53W3qicink9eDzi6U.... The failures happening are code or prompt failures, rather than provider issues.
Since 4.1 is cheaper I think at least for chat_with_tools we could set it?
Comment #12
prabha1997 commentedHi @marcus_johansson,
I'm currently unable to access the spreadsheet — it looks like I don't have permission. Could you please grant me access?
Thanks!
Comment #13
marcus_johansson commentedCould you make a request for it or write your e-mail (on Slack if you don't want to publish it here)?
Comment #14
prabha1997 commentedHi @marcus_johansson,
Thanks for sharing access — I’ve checked the sheet. While I understand the data, I’m not yet at the level where I feel confident analyzing and comparing the cost-effectiveness between 4.1 and 4o in depth.
Comment #15
marcus_johansson commentedThank you, getting merged!