diff --git a/main.c b/main.c index b0faeba..e932412 100644 --- a/main.c +++ b/main.c @@ -200,6 +200,7 @@ void repl() { // previous_line = line; if(!strncmp(line,"dump",4)){ printf("%s\n",message_json()); + continue; } if (!strncmp(line, "exit", 4)) { exit(0); diff --git a/messages.h b/messages.h index 7d22f43..65920d8 100644 --- a/messages.h +++ b/messages.h @@ -57,6 +57,11 @@ struct json_object *message_add_tool_result(const char *tool_call_id, const char return message; } +void message_add_object(json_object *message) { + struct json_object *messages = message_list(); + json_object_array_add(messages, message); +} + struct json_object *message_add(const char *role, const char *content) { struct json_object *messages = message_list(); struct json_object *message = json_object_new_object(); diff --git a/openai.h b/openai.h index e9469d3..98e712b 100644 --- a/openai.h +++ b/openai.h @@ -95,6 +95,7 @@ char* openai_chat(const char* user_role, const char* message_content) { const char* api_url = "https://api.openai.com/v1/chat/completions"; char* json_data = chat_json(user_role, message_content); struct json_object* message_object = openai_process_chat_message(api_url, json_data); + message_add_object(message_object); if (message_object == NULL) { printf("ERROR + NULL IS SUCCESS\n"); return NULL; @@ -102,7 +103,7 @@ char* openai_chat(const char* user_role, const char* message_content) { struct json_object* tool_calls; json_object_object_get_ex(message_object, "tool_calls", &tool_calls); if (tool_calls) { - message_add_tool_call(message_object); + // message_add_tool_call(message_object); struct json_object* tool_call_results = tools_execute(tool_calls); int results_count = json_object_array_length(tool_call_results); for (int i = 0; i < results_count; i++) {