Skip to content

SymfonyAiPlatformAdapter uses incorrect max tokens key for Gemini bridge #13

@dextar47

Description

@dextar47

When using the SymfonyAiPlatformAdapter with the Symfony AI Gemini bridge, requests fail because the adapter sends the max_tokens key instead of max_output_tokens.

I think the problem is here:

/**
   * Resolve the max-tokens option key expected by a Symfony AI bridge based on the used bridge
   */
  public static function resolveMaxTokensKey(string $factoryClass): string
  {
      if (str_contains($factoryClass, '\\Bridge\\OpenAi\\')
          || str_contains($factoryClass, '\\Bridge\\OpenResponses\\')
      ) {
          return 'max_output_tokens';
      }
      return 'max_tokens';
  }

It should be maybe like this:

if (str_contains($factoryClass, '\\Bridge\\OpenAi\\')
            || str_contains($factoryClass, '\\Bridge\\OpenResponses\\')
            || str_contains($factoryClass, '\\Bridge\\Gemini\\')
        ) {
            return 'max_output_tokens';
        }
        return 'max_tokens';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions