@@ -173,6 +173,10 @@ static void SetModelName(DataChunk &args, ExpressionState &state, Vector &result
173
173
SetConfigValue (args, state, result, " openprompt_model_name" , " Model name" );
174
174
}
175
175
176
+ static void SetApiTimeout (DataChunk &args, ExpressionState &state, Vector &result) {
177
+ SetConfigValue (args, state, result, " openprompt_api_timeout" , " API timeout" );
178
+ }
179
+
176
180
// Main Function
177
181
static void OpenPromptRequestFunction (DataChunk &args, ExpressionState &state, Vector &result) {
178
182
D_ASSERT (args.data .size () >= 1 ); // At least prompt required
@@ -187,6 +191,7 @@ static void OpenPromptRequestFunction(DataChunk &args, ExpressionState &state, V
187
191
" http://localhost:11434/v1/chat/completions" );
188
192
std::string api_token = GetConfigValue (context, " openprompt_api_token" , " " );
189
193
std::string model_name = GetConfigValue (context, " openprompt_model_name" , " qwen2.5:0.5b" );
194
+ std::string api_timeout = GetConfigValue (context, " openprompt_api_timeout" , " " );
190
195
std::string json_schema;
191
196
std::string system_prompt;
192
197
@@ -259,6 +264,10 @@ static void OpenPromptRequestFunction(DataChunk &args, ExpressionState &state, V
259
264
headers.emplace (" Authorization" , " Bearer " + api_token);
260
265
}
261
266
267
+ if (!api_timeout.empty ()){
268
+ client.set_read_timeout (stoi (api_timeout), 0 );
269
+ }
270
+
262
271
auto res = client.Post (path.c_str (), headers, str_request_body, " application/json" );
263
272
264
273
if (!res) {
@@ -349,6 +358,8 @@ static void LoadInternal(DatabaseInstance &instance) {
349
358
" set_api_url" , {LogicalType::VARCHAR}, LogicalType::VARCHAR, SetApiUrl));
350
359
ExtensionUtil::RegisterFunction (instance, ScalarFunction (
351
360
" set_model_name" , {LogicalType::VARCHAR}, LogicalType::VARCHAR, SetModelName));
361
+ ExtensionUtil::RegisterFunction (instance, ScalarFunction (
362
+ " set_api_timeout" , {LogicalType::VARCHAR}, LogicalType::VARCHAR, SetApiTimeout));
352
363
}
353
364
354
365
void OpenPromptExtension::Load (DuckDB &db) {
0 commit comments