Skip to content

Commit

Permalink
Fix OpenAI model selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Oct 9, 2024
1 parent b93dde5 commit f4741cb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions includes/OpenAI/OpenAI_AI_Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static function ( array $model ) {
return array_reduce(
$model_slugs,
static function ( array $model_caps, string $model_slug ) use ( $openai_gpt_capabilities ) {
if ( str_starts_with( $model_slug, 'gpt-' ) ) {
if ( str_starts_with( $model_slug, 'gpt-' ) && ! str_contains( $model_slug, '-instruct' ) ) {
$model_caps[ $model_slug ] = $openai_gpt_capabilities;
} else {
/*
Expand Down Expand Up @@ -193,21 +193,24 @@ public function get_model( array $model_params = array(), array $request_options
private function sort_models_by_preference( array $model_slugs ): array {
$get_preference_group = static function ( $model_slug ) {
if ( str_starts_with( $model_slug, 'gpt-3.5' ) ) {
if ( str_contains( $model_slug, '-turbo' ) ) {
if ( str_ends_with( $model_slug, '-turbo' ) ) {
return 0;
}
return 1;
if ( str_contains( $model_slug, '-turbo' ) ) {
return 1;
}
return 2;
}
if ( str_starts_with( $model_slug, 'gpt-' ) ) {
if ( str_contains( $model_slug, '-turbo' ) ) {
return 2;
return 3;
}
return 3;
return 4;
}
return 4;
return 5;
};

$preference_groups = array_fill( 0, 5, array() );
$preference_groups = array_fill( 0, 6, array() );
foreach ( $model_slugs as $model_slug ) {
$group = $get_preference_group( $model_slug );
$preference_groups[ $group ][] = $model_slug;
Expand Down

0 comments on commit f4741cb

Please sign in to comment.