This commit is contained in:
retoor 2025-03-28 06:55:22 +01:00
parent 6834081960
commit 1e62665d43
7 changed files with 18 additions and 14 deletions

2
chat.h
View File

@ -55,7 +55,7 @@ char *chat_json(const char *role, const char *message) {
json_object_object_add(root_object, "messages", message_list());
// json_object_object_add(root_object, "max_tokens", json_object_new_int(prompt_max_tokens));
json_object_object_add(root_object, "temperature", json_object_new_double(prompt_temperature));
json_object_object_add(root_object, "temperature", json_object_new_double(PROMPT_TEMPERATURE));
return (char *)json_object_to_json_string_ext(root_object, JSON_C_TO_STRING_PRETTY);
}

View File

@ -1,17 +1,18 @@
#ifndef DB_UTILS_H
#define DB_UTILS_H
#include "r.h"
#include <sqlite3.h>
#include <json-c/json.h>
#include "utils.h"
const char * db_file = "~/.r.db";
json_object* db_execute(const char *query);
char * db_file_expanded(){
char * expanded = expand_home_directory(db_file);
char * expanded = expand_home_directory(DB_FILE);
static char result[4096];
result[0] = 0;
strcpy(result, expanded);

View File

@ -112,13 +112,13 @@ char* index_directory(const char *dir_path) {
json_object_object_add(jfile, "file_current_content_data", json_object_new_string("Error reading file"));
} else {
content[length] = '\0'; // Null-terminate the string
json_object_object_add(jfile, "file_current_content_data", json_object_new_string(content));
//json_object_object_add(jfile, "file_current_content_data", json_object_new_string(content));
}
free(content);
}
fclose(fp);
} else {
json_object_object_add(jfile, "content", json_object_new_string("Unable to read file"));
//json_object_object_add(jfile, "content", json_object_new_string("Unable to read file"));
}
json_object_array_add(jarray, jfile);

2
line.h
View File

@ -32,7 +32,7 @@ char * get_history_file(){
char* line_command_generator(const char* text, int state) {
static int list_index, len = 0;
const char* commands[] = {"help", "exit", "list", "review", "refactor", "obfuscate", NULL};
const char* commands[] = {"help", "exit", "list", "review", "refactor", "obfuscate", "!verbose","!dump", "!model","!debug", NULL};
if (!state) {
list_index = 0;

10
main.c
View File

@ -214,8 +214,10 @@ void repl() {
printf("%s\n",message_json());
continue;
}
if(!strncmp(line,"!context",7)){
if(!strncmp(line,"!verbose",7)){
is_verbose = !is_verbose;
fprintf(stderr,"%s\n",is_verbose?"Verbose mode enabled":"Verbose mode disabled");
continue;
}
if (!strncmp(line, "!model", 6)) {
if(!strncmp(line+6," ",1)){
@ -277,7 +279,7 @@ void help() {
" - **google search** and actions with those results.\n"
" - **reminders**.\n"
" - predefined **templates** for **reviewing** / **refactoring** so you can personalize.\n";
sprintf(help_text, template, prompt_temperature, get_prompt_model(), prompt_max_tokens);
sprintf(help_text, template, PROMPT_TEMPERATURE, get_prompt_model(), prompt_max_tokens);
render(help_text);
}
@ -337,8 +339,6 @@ void init() {
void handle_sigint(int sig) {
time_t current_time = time(NULL);
int ret = system("clear");
(void)ret;
printf("\n");
if (sigint_count == 0) {
first_sigint_time = current_time;

9
r.h
View File

@ -9,6 +9,12 @@ bool is_verbose = false;
char * _model = NULL;
#define DB_FILE "~/.r.db"
static int prompt_max_tokens = 10000;
#define PROMPT_TEMPERATURE 0.1
void set_prompt_model(const char *model) {
if(_model != NULL) {
@ -28,8 +34,5 @@ const char * get_prompt_model() {
return _model;
}
static int prompt_max_tokens = 10000;
static double prompt_temperature = 0.1;
#endif

BIN
rpylib.so

Binary file not shown.