Compare commits
2 Commits
feat/ai-ap
...
e9614abb89
| Author | SHA1 | Date | |
|---|---|---|---|
|
e9614abb89
|
|||
|
cac2aa856a
|
@@ -472,16 +472,12 @@ _names_model(const gchar* s)
|
||||
{
|
||||
if (!s)
|
||||
return FALSE;
|
||||
/* "does not exist"/"not found"/"not supported" alone also appear in
|
||||
* route-missing bodies; require them to talk about a model (covers
|
||||
* Ollama's 'model "x" not found, try pulling it first' and Perplexity's
|
||||
* 'model "x" is not supported'). Gateways vary in casing, so compare
|
||||
* case-insensitively. */
|
||||
auto_gchar gchar* lower = g_ascii_strdown(s, -1);
|
||||
return strstr(lower, "model_not_found") || strstr(lower, "invalid_model")
|
||||
|| strstr(lower, "unknown_model")
|
||||
|| (strstr(lower, "model")
|
||||
&& (strstr(lower, "does not exist") || strstr(lower, "not found") || strstr(lower, "not supported")));
|
||||
/* "does not exist"/"not found" alone also appear in route-missing bodies;
|
||||
* require them to talk about a model (covers Ollama's 'model "x" not
|
||||
* found, try pulling it first') */
|
||||
return strstr(s, "model_not_found") || strstr(s, "invalid_model")
|
||||
|| strstr(s, "unknown_model")
|
||||
|| (strstr(s, "model") && (strstr(s, "does not exist") || strstr(s, "not found")));
|
||||
}
|
||||
|
||||
/* A missing endpoint answers 404/405/501. A wrong model can also 404/405, but
|
||||
@@ -1092,7 +1088,7 @@ _curl_exec_and_handle(CURL* curl, const gchar* url, struct curl_slist* headers,
|
||||
auto_gchar gchar* error_msg = parsed
|
||||
? g_strdup_printf("HTTP %ld: %s", http_code, parsed)
|
||||
: g_strdup_printf("HTTP %ld: %s", http_code,
|
||||
response->data && strlen(response->data) > 0 ? response->data : "empty response body");
|
||||
response->data && strlen(response->data) > 0 ? response->data : "Unknown error");
|
||||
log_error("Request HTTP error for '%s': %s", provider->name, error_msg);
|
||||
_aiwin_display_error(user_data, error_msg);
|
||||
} else {
|
||||
@@ -2190,7 +2186,7 @@ _ai_request_thread(gpointer data)
|
||||
ai_api_type_to_string(attempts[i + 1]));
|
||||
if (!first_unparsable_note)
|
||||
first_unparsable_note = g_strdup_printf("%s endpoint answered HTTP %ld but the body could not be parsed",
|
||||
ai_api_type_to_string(used_type), http_code);
|
||||
ai_api_type_to_string(used_type), http_code);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2240,7 +2236,7 @@ _ai_request_thread(gpointer data)
|
||||
response.size, response_data);
|
||||
/* Try to extract the actual error message from the JSON response */
|
||||
auto_gchar gchar* parsed_error = ai_parse_error_message(err_body);
|
||||
auto_gchar gchar* error_msg = parsed_error ? g_strdup_printf("HTTP %ld: %s", err_code, parsed_error) : g_strdup_printf("HTTP %ld: %s", err_code, err_body && strlen(err_body) > 0 ? err_body : "empty response body");
|
||||
auto_gchar gchar* error_msg = parsed_error ? g_strdup_printf("HTTP %ld: %s", err_code, parsed_error) : g_strdup_printf("HTTP %ld: %s", err_code, err_body && strlen(err_body) > 0 ? err_body : "Unknown error");
|
||||
if (first_unparsable_note) {
|
||||
gchar* with_note = g_strdup_printf("%s (first attempt: %s)", error_msg, first_unparsable_note);
|
||||
g_free(error_msg);
|
||||
|
||||
Reference in New Issue
Block a user