diff --git a/Makefile b/Makefile index 15fdd1e..15a7c3c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: build build_free build_rpylib run_free +all: build build_rd build_free build_rpylib run_rd # Variables for compiler and flags CC = gcc @@ -13,6 +13,12 @@ build_free: $(CC) -DOLLAMA main.c $(CFLAGS) -o rf publish rf +build_rd: + $(CC) -DRD main.c $(CFLAGS) -o rd + publish rd + + + build_rpylib: $(CC) -shared -o rpylib.so -fPIC rpylib.c -lpython3.12 `python3-config --includes` -I/usr/include/CL -ljson-c -lcurl -lsqlite3 publish rpylib.so @@ -21,4 +27,7 @@ run: ./r --verbose run_free: - ./rf --verbose + ./rf --verbose + +run_rd: + ./rd --verbose diff --git a/malloc.c b/malloc.c new file mode 100644 index 0000000..b391183 --- /dev/null +++ b/malloc.c @@ -0,0 +1 @@ +#include "malloc.h" diff --git a/malloc.h b/malloc.h new file mode 100644 index 0000000..20fef36 --- /dev/null +++ b/malloc.h @@ -0,0 +1,33 @@ +#ifndef R_MALLOC +#define R_MALLOC +#include <malloc.h> + +long long int r_malloc_alloc_count = 0; +long long int r_malloc_alloc_total = 0; + +void *r_malloc(size_t size) { + r_malloc_alloc_count++; + r_malloc_alloc_total++; + + return malloc(size); +} + +void r_free(void *ptr) { + r_malloc_alloc_count--; + + free(ptr); +} + +void r_malloc_stats() { + fprintf(stderr, "r_malloc_alloc_count: %lld\n", r_malloc_alloc_count); + fprintf(stderr, "r_malloc_alloc_total: %lld\n", r_malloc_alloc_total); + fprintf(stderr, "r_malloc_freed_total: %lld\n", + r_malloc_alloc_total - r_malloc_alloc_count); +} + +#define malloc(x) r_malloc(x) +#define free(x) r_free(x) + +#include <stdio.h> + +#endif diff --git a/r.h b/r.h index 477bc79..0c2d7cc 100644 --- a/r.h +++ b/r.h @@ -7,13 +7,26 @@ #include <string.h> bool is_verbose = false; +#ifndef RD #ifndef OLLAMA char *models_api_url = "https://api.openai.com/v1/models"; // char *completions_api_url = "https://ollama.molodetz.nl/v1/chat/completions"; char *completions_api_url = "https://api.openai.com/v1/chat/completions"; char *advanced_model = "gpt-4o-mini"; char *fast_model = "gpt-3.5-turbo"; -#else +#endif +#endif + +#ifdef RD + +char *models_api_url = "https://api.openai.com/v1/models"; +char *completions_api_url = "https://api.deepinfra.com/v1/openai/chat/completions"; +//char *advanced_model = "meta-llama/Meta-Llama-3.1-8B-Instruct"; +char *advanced_model = "google/gemini-1.5-flash"; +char *fast_model = "Qwen/Qwen2.5-Coder-32B-Instruct"; + +#endif +#ifdef OLLAMA char *models_api_url = "https://ollama.molodetz.nl/v1/models"; char *completions_api_url = "https://ollama.molodetz.nl/v1/chat/completions"; char *advanced_model = "qwen2.5:3b"; diff --git a/rpylib.so b/rpylib.so index 0bb3a3a..3478a9d 100755 Binary files a/rpylib.so and b/rpylib.so differ