Added messages_remove.

This commit is contained in:
retoor 2025-03-19 18:04:32 +01:00
parent a2eccb4e5a
commit eab4e4d7f1
2 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,10 @@
all: build run
build_rpylib:
gcc -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl
build:
# -lpython3.14 -I/usr/include/python3.14
gcc main.c -Ofast -o r -Werror -Wall -lreadline -lncurses -lcurl -lssl -lcrypto -ljson-c -lm

View File

@ -24,15 +24,22 @@ struct json_object *message_list() {
}
return message_array;
}
void messages_remove_last() {
bool messages_remove_last() {
struct json_object *messages = message_list();
int size = json_object_array_length(messages);
if (size) {
json_object_array_del_idx(messages, size - 1, 1);
return true;
}
return false;
}
void messages_remove(){
while(messages_remove_last())
continue;
}
struct json_object *message_add_tool_call(struct json_object *message) {
struct json_object *messages = message_list();
json_object_array_add(messages, message);
@ -75,4 +82,4 @@ void message_free() {
}
}
#endif
#endif