@@ -55,8 +55,8 @@ export abstract class VertexAIModel {
5555 *
5656 * @internal
5757 */
58- protected constructor ( vertexAI : VertexAI , modelName : string ) {
59- this . model = VertexAIModel . normalizeModelName ( modelName ) ;
58+ protected constructor ( vertexAI : VertexAI , modelName : string , developerAPIEnabled ?: boolean ) {
59+ this . model = VertexAIModel . normalizeModelName ( modelName , developerAPIEnabled ) ;
6060
6161 if ( ! vertexAI . app ?. options ?. apiKey ) {
6262 throw new VertexAIError (
@@ -72,7 +72,8 @@ export abstract class VertexAIModel {
7272 this . _apiSettings = {
7373 apiKey : vertexAI . app . options . apiKey ,
7474 project : vertexAI . app . options . projectId ,
75- location : vertexAI . location
75+ location : vertexAI . location ,
76+ developerAPIEnabled : developerAPIEnabled ? developerAPIEnabled : false
7677 } ;
7778
7879 if (
@@ -101,19 +102,23 @@ export abstract class VertexAIModel {
101102 * @param modelName - The model name to normalize.
102103 * @returns The fully qualified model resource name.
103104 */
104- static normalizeModelName ( modelName : string ) : string {
105+ static normalizeModelName ( modelName : string , developerAPIEnabled ?: boolean ) : string {
105106 let model : string ;
106- if ( modelName . includes ( '/' ) ) {
107- if ( modelName . startsWith ( 'models/' ) ) {
108- // Add 'publishers/google' if the user is only passing in 'models/model-name'.
109- model = `publishers/google/${ modelName } ` ;
107+ if ( developerAPIEnabled ) {
108+ model = `models/${ modelName } ` ;
109+ } else {
110+ if ( modelName . includes ( '/' ) ) {
111+ if ( modelName . startsWith ( 'models/' ) ) {
112+ // Add 'publishers/google' if the user is only passing in 'models/model-name'.
113+ model = `publishers/google/${ modelName } ` ;
114+ } else {
115+ // Any other custom format (e.g. tuned models) must be passed in correctly.
116+ model = modelName ;
117+ }
110118 } else {
111- // Any other custom format (e.g. tuned models) must be passed in correctly .
112- model = modelName ;
119+ // If path is not included, assume it's a non-tuned model .
120+ model = `publishers/google/models/ ${ modelName } ` ;
113121 }
114- } else {
115- // If path is not included, assume it's a non-tuned model.
116- model = `publishers/google/models/${ modelName } ` ;
117122 }
118123
119124 return model ;
0 commit comments