Compare commits
2 Commits
89be6b8542
...
cf49a42093
Author | SHA1 | Date | |
---|---|---|---|
cf49a42093 | |||
ecadf1e9a2 |
13
Makefile
13
Makefile
@ -1,4 +1,4 @@
|
||||
all: build build_free build_rpylib run_free
|
||||
all: build build_rd build_free build_rpylib run_free
|
||||
|
||||
# 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
|
||||
|
33
malloc.h
Normal file
33
malloc.h
Normal 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
|
17
r.h
17
r.h
@ -7,16 +7,31 @@
|
||||
#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/Llama-3.3-70B-Instruct-Turbo";
|
||||
//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";
|
||||
//char *advanced_model = "qwen2.5-coder:0.5b";
|
||||
char *fast_model = "qwen2.5:0.5b";
|
||||
#endif
|
||||
|
||||
|
24
tools.h
24
tools.h
@ -216,7 +216,7 @@ struct json_object *tool_description_db_get() {
|
||||
json_object_array_add(required, json_object_new_string("key"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
@ -266,7 +266,7 @@ struct json_object *tool_description_db_query() {
|
||||
json_object_array_add(required, json_object_new_string("query"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
@ -323,7 +323,7 @@ struct json_object *tool_description_db_set() {
|
||||
json_object_array_add(required, json_object_new_string("value"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
@ -494,8 +494,7 @@ struct json_object *tool_description_index_source_directory() {
|
||||
struct json_object *required = json_object_new_array();
|
||||
json_object_array_add(required, json_object_new_string("path"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
@ -621,7 +620,7 @@ struct json_object *tool_description_read_file() {
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(1));
|
||||
@ -951,8 +950,8 @@ struct json_object *tool_description_http_get() {
|
||||
json_object_array_add(required, json_object_new_string("url"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
//json_object_object_add(parameters, "additionalProperties",
|
||||
// json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(1));
|
||||
@ -993,8 +992,8 @@ struct json_object *tool_description_directory_glob() {
|
||||
json_object_array_add(required, json_object_new_string("path"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
// json_object_object_add(parameters, "additionalProperties",
|
||||
// json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(1));
|
||||
@ -1032,8 +1031,8 @@ struct json_object *tool_description_linux_terminal() {
|
||||
json_object_array_add(required, json_object_new_string("command"));
|
||||
json_object_object_add(parameters, "required", required);
|
||||
|
||||
json_object_object_add(parameters, "additionalProperties",
|
||||
json_object_new_boolean(0));
|
||||
//json_object_object_add(parameters, "additionalProperties",
|
||||
// json_object_new_boolean(0));
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(1));
|
||||
@ -1326,3 +1325,4 @@ struct json_object *tools_execute(struct json_object *tools_array) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user