refactor(ai): remove redundant callback layer from AI client
Some checks failed
CI Code / Check spelling (pull_request) Successful in 53s
CI Code / Check coding style (pull_request) Successful in 1m8s
CI Code / Linux (debian) (pull_request) Failing after 2m55s
CI Code / Linux (ubuntu) (pull_request) Failing after 3m4s
CI Code / Linux (arch) (pull_request) Failing after 3m7s
CI Code / Code Coverage (pull_request) Successful in 2m42s
Some checks failed
CI Code / Check spelling (pull_request) Successful in 53s
CI Code / Check coding style (pull_request) Successful in 1m8s
CI Code / Linux (debian) (pull_request) Failing after 2m55s
CI Code / Linux (ubuntu) (pull_request) Failing after 3m4s
CI Code / Linux (arch) (pull_request) Failing after 3m7s
CI Code / Code Coverage (pull_request) Successful in 2m42s
The ai_response_cb and ai_error_cb parameters were always passed the same functions (aiwin_display_response and aiwin_display_error), making the callback indirection redundant and complicating the call chain. Remove ai_callback_data_t, _ai_callback_invoke(), and _ai_invoke_callback(). Simplify _ai_request_thread and ai_send_prompt to directly call aiwin_display_error() and aiwin_display_response() when user_data is a valid ProfAiWin*.
This commit is contained in:
@@ -3,20 +3,6 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/**
|
||||
* @brief Callback function for successful AI responses.
|
||||
* @param response The AI response text.
|
||||
* @param user_data User-provided data passed to the callback.
|
||||
*/
|
||||
typedef void (*ai_response_cb)(const gchar* response, gpointer user_data);
|
||||
|
||||
/**
|
||||
* @brief Callback function for AI errors.
|
||||
* @param error_msg The error message.
|
||||
* @param user_data User-provided data passed to the callback.
|
||||
*/
|
||||
typedef void (*ai_error_cb)(const gchar* error_msg, gpointer user_data);
|
||||
|
||||
/**
|
||||
* @brief AI message structure for conversation history.
|
||||
*/
|
||||
@@ -186,7 +172,7 @@ void ai_session_set_model(AISession* session, const gchar* model);
|
||||
* Send a prompt to the AI provider asynchronously.
|
||||
* @param session The AI session containing provider and model
|
||||
* @param prompt The prompt to send
|
||||
* @param user_data User data to be passed to the callbacks
|
||||
* @param user_data User data (ProfAiWin* for UI display)
|
||||
* @return TRUE if the request was successfully queued, FALSE otherwise
|
||||
*/
|
||||
gboolean ai_send_prompt(AISession* session, const gchar* prompt,
|
||||
|
||||
Reference in New Issue
Block a user