@@ -99,15 +99,19 @@ def get_client(model_config: dict, oci_config: schema.OracleCloudSettings, giska
99
99
k : full_model_config .get (k ) for k in ["frequency_penalty" , "presence_penalty" , "top_p" , "streaming" ]
100
100
}
101
101
if provider != "oci" :
102
- client = init_chat_model (
103
- model_provider = "openai" if provider == "openai_compatible" else provider ,
104
- model = full_model_config ["id" ],
105
- base_url = full_model_config ["url" ],
106
- api_key = full_model_config ["api_key" ] or "not_required" ,
107
- temperature = full_model_config ["temperature" ],
108
- max_tokens = full_model_config ["max_completion_tokens" ],
102
+ kwargs = {
103
+ "model_provider" : "openai" if provider == "openai_compatible" else provider ,
104
+ "model" : full_model_config ["id" ],
105
+ "base_url" : full_model_config ["url" ],
106
+ "temperature" : full_model_config ["temperature" ],
107
+ "max_tokens" : full_model_config ["max_completion_tokens" ],
109
108
** common_params ,
110
- )
109
+ }
110
+
111
+ if full_model_config .get ("api_key" ): # only add if present
112
+ kwargs ["api_key" ] = full_model_config ["api_key" ]
113
+
114
+ client = init_chat_model (** kwargs )
111
115
else :
112
116
client = ChatOCIGenAI (
113
117
model_id = full_model_config ["id" ],
@@ -122,12 +126,14 @@ def get_client(model_config: dict, oci_config: schema.OracleCloudSettings, giska
122
126
123
127
if full_model_config ["type" ] == "embed" and not giskard :
124
128
if provider != "oci" :
125
- client = init_embeddings (
126
- provider = "openai" if provider == "openai_compatible" else provider ,
127
- model = full_model_config ["id" ],
128
- base_url = full_model_config ["url" ],
129
- api_key = full_model_config ["api_key" ] or "not_required" ,
130
- )
129
+ kwargs = {
130
+ "provider" : "openai" if provider == "openai_compatible" else provider ,
131
+ "model" : full_model_config ["id" ],
132
+ "base_url" : full_model_config ["url" ],
133
+ }
134
+ if full_model_config .get ("api_key" ): # only add if set
135
+ kwargs ["api_key" ] = full_model_config ["api_key" ]
136
+ client = init_embeddings (** kwargs )
131
137
else :
132
138
client = OCIGenAIEmbeddings (
133
139
model_id = full_model_config ["id" ],
0 commit comments