Progress.

This commit is contained in:
retoor 2025-03-28 21:38:50 +01:00
parent 89be6b8542
commit ecadf1e9a2
5 changed files with 59 additions and 3 deletions

View File

@ -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

1
malloc.c Normal file
View File

@ -0,0 +1 @@
#include "malloc.h"

33
malloc.h Normal file
View File

@ -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

15
r.h
View File

@ -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";

BIN
rpylib.so

Binary file not shown.