Formatting.
This commit is contained in:
parent
44c7063033
commit
255e5458be
117
browse.h
117
browse.h
@ -12,15 +12,63 @@ char *web_search_news(char *q) {
|
||||
const int MAX_RETRIES = 3;
|
||||
for (int retry = 0; retry < MAX_RETRIES; retry++) {
|
||||
char *news = malloc(4096);
|
||||
if (!news) return NULL;
|
||||
if (!news)
|
||||
return NULL;
|
||||
news[0] = 0;
|
||||
char *q_encoded = url_encode(q);
|
||||
snprintf(news, 4096, "https://search.molodetz.nl/search?q=%s&format=json&categories=news&preferences=eJx1WMuy4zYO_Zp4o4ormaRqahZepZL5gexVFAlLiEhCzYdt3a8PoIdFWt2Ldl8fkCCIxwForRL0FBDirQcPQdmLVb7PqoebyokulrSycPP2Il81uclCgtvlrh6oybcBItkHhNsFHW9qp0Cv-faXshEuDtJA5vb_P_--RHWHCCro4fbLJQ3g4BZRdF1YQbYptqzLw7NNqtt2G8JDOyn-eqXQX9ZtbUyz3UzU4BOEVlnsveO_t_3KPJTXYNrt3BX9liHMLfo2YWIFK4j-jh4Ta9WBrN3QdZ8YplcvzazKgk63v0OGy0BphDneDNwV3-CSg23vFJxKCX1_mwKkNF8MRtVZtgJ8j57d_L9e9W0bSaOyjQOD6qf__MG366CJ7OCxbRdHxhptHmiA2nb571OmskGWuRxRi8hOfFJj0edXMyk9ijpWm0TmvYqN3Asf0LZ3tOtJ09g4DIFCibGfG_6UU0K52CuOvFGbSo8vis0TR9yADi3Kv8LaDlOX9QhpX5IM9v2hcvHDVWt9NVBs0xN78Q4BOI7bTg5QjAyyCzUKztgMU7M6rXCegJxQDMknAwbgi9Pk7SYDMamEvIA4IQMjEOiJ5vhu2GT519NZfSFbzS3MLmS1BQf-BCWHHGet3nZq4uX8KdY4-gcnccyx6tdXYcLdBBJzdydyDps0qOS4usplAThR6J6eKkBjMHAGSy6v_rwH9CMqXW6Y58IJPeDXwPVQIFw5qtvjQQY6CP32lWXAgSS3fycyAZQptxP1fNXJqlmyKx4XKCWOHgilU7muIEjNCO2UkRhUF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D9gPqTGqIoX1Zm6OWGde5G6rdl8czYkyc3qdNPxU0CMxyd4tPfdWEcfcZZ_y3pUyz345vhMnChNO8igujySLhufvsFbV96aNY3H2kYfhOJTPGjVQdbcFqB05U_6YEd7I-_Gj0DItSsIWyx7oqkfmE7v5k4Y7ojF-gtXxAnzLVLt6mZaWtn1C9xmqgsWyaoCVpdLkllGv1vCg-cPLggp1cTleTwlVCk9pVQo_3tWlaInbEb4n2XtQjl_eQ92jUKcv8pVtjkcpxw-w5k2GphT_-ttv_30dmiN8eeWq_cvkWCJePSTpypyoG_OTgvE4FgMcn62reuRul-QBKYo-yPSprB34CP_hQ8c9vTolpXDFYvbldvCorr4A54Cs8HnKWeDP9lnpS7_vPyIcP7RMNvPYF2-k2vUnpGfgsl86aUzsy7XeKLQ8IunxPSzu28QzPJW08nNO4EA91uFJWZ05VhSWsuQ3Dbc4FqVtHrb3Fv2d5BSp11XZhZ8WzP-3fwFOiVFV", q_encoded);
|
||||
snprintf(
|
||||
news, 4096,
|
||||
"https://search.molodetz.nl/"
|
||||
"search?q=%s&format=json&categories=news&preferences=eJx1WMuy4zYO_"
|
||||
"Zp4o4ormaRqahZepZL5gexVFAlLiEhCzYdt3a8PoIdFWt2Ldl8fkCCIxwForRL0FBDirQc"
|
||||
"PQdmLVb7PqoebyokulrSycPP2Il81uclCgtvlrh6oybcBItkHhNsFHW9qp0Cv-"
|
||||
"faXshEuDtJA5vb_P_--RHWHCCro4fbLJQ3g4BZRdF1YQbYptqzLw7NNqtt2G8JDOyn-"
|
||||
"eqXQX9ZtbUyz3UzU4BOEVlnsveO_t_3KPJTXYNrt3BX9liHMLfo2YWIFK4j-"
|
||||
"jh4Ta9WBrN3QdZ8YplcvzazKgk63v0OGy0BphDneDNwV3-CSg23vFJxKCX1_"
|
||||
"mwKkNF8MRtVZtgJ8j57d_L9e9W0bSaOyjQOD6qf__"
|
||||
"MG366CJ7OCxbRdHxhptHmiA2nb571OmskGWuRxRi8hOfFJj0edXMyk9ijp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7XeKLQ8IunxPSzu28QzPJW08nNO4EA91uFJWZ05VhSWsuQ3Dbc4F"
|
||||
"qVtHrb3Fv2d5BSp11XZhZ8WzP-3fwFOiVFV",
|
||||
q_encoded);
|
||||
free(q_encoded);
|
||||
|
||||
char *ret = curl_get(news);
|
||||
free(news);
|
||||
if (!ret) continue;
|
||||
if (!ret)
|
||||
continue;
|
||||
|
||||
json_object *json_ret = json_tokener_parse(ret);
|
||||
if (!json_ret) {
|
||||
@ -44,15 +92,63 @@ char *web_search(char *q) {
|
||||
const int MAX_RETRIES = 3;
|
||||
for (int retry = 0; retry < MAX_RETRIES; retry++) {
|
||||
char *news = malloc(4096);
|
||||
if (!news) return NULL;
|
||||
if (!news)
|
||||
return NULL;
|
||||
news[0] = 0;
|
||||
char *q_encoded = url_encode(q);
|
||||
snprintf(news, 4096, "https://search.molodetz.nl/search?q=%s&format=json&preferences=eJx1WMuy4zYO_Zp4o4ormaRqahZepZL5gexVFAlLiEhCzYdt3a8PoIdFWt2Ldl8fkCCIxwForRL0FBDirQcPQdmLVb7PqoebyokulrSycPP2Il81uclCgtvlrh6oybcBItkHhNsFHW9qp0Cv-faXshEuDtJA5vb_P_--RHWHCCro4fbLJQ3g4BZRdF1YQbYptqzLw7NNqtt2G8JDOyn-eqXQX9ZtbUyz3UzU4BOEVlnsveO_t_3KPJTXYNrt3BX9liHMLfo2YWIFK4j-jh4Ta9WBrN3QdZ8YplcvzazKgk63v0OGy0BphDneDNwV3-CSg23vFJxKCX1_mwKkNF8MRtVZtgJ8j57d_L9e9W0bSaOyjQOD6qf__MG366CJ7OCxbRdHxhptHmiA2nb571OmskGWuRxRi8hOfFJj0edXMyk9ijpWm0TmvYqN3Asf0LZ3tOtJ09g4DIFCibGfG_6UU0K52CuOvFGbSo8vis0TR9yADi3Kv8LaDlOX9QhpX5IM9v2hcvHDVWt9NVBs0xN78Q4BOI7bTg5QjAyyCzUKztgMU7M6rXCegJxQDMknAwbgi9Pk7SYDMamEvIA4IQMjEO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PZkP6-N5JIJ9npDqUjw1Sf5FSBXZ7zLuepxRasvwWh4TD2CJZ7p9sJuM8PexaOKXhHS7TYrymoFY1tAkhFJky_L9ulzouNeEMt10qojIRMxNkUvCyAi0J_-7c5d3Ptr5npuFbLldY7hfo1_z_HhCHEbmzomVxcXmaafVb08mhlLnAtS1sUKnMlrhU8UExZNX0zF5xXKqD9gPqTGqIoX1Zm6OWGde5G6rdl8czYkyc3qdNPxU0CMxyd4tPfdWEcfcZZ_y3pUyz345vhMnChNO8igujySLhufvsFbV96aNY3H2kYfhOJTPGjVQdbcFqB05U_6YEd7I-_Gj0DItSsIWyx7oqkfmE7v5k4Y7ojF-gtXxAnzLVLt6mZaWtn1C9xmqgsWyaoCVpdLkllGv1vCg-cPLggp1cTleTwlVCk9pVQo_3tWlaInbEb4n2XtQjl_eQ92jUKcv8pVtjkcpxw-w5k2GphT_-ttv_30dmiN8eeWq_cvkWCJePSTpypyoG_OTgvE4FgMcn62reuRul-QBKYo-yPSprB34CP_hQ8c9vTolpXDFYvbldvCorr4A54Cs8HnKWeDP9lnpS7_vPyIcP7RMNvPYF2-k2vUnpGfgsl86aUzsy7XeKLQ8IunxPSzu28QzPJW08nNO4EA91uFJWZ05VhSWsuQ3Dbc4FqVtHrb3Fv2d5BSp11XZhZ8WzP-3fwFOiVFV", q_encoded);
|
||||
snprintf(
|
||||
news, 4096,
|
||||
"https://search.molodetz.nl/"
|
||||
"search?q=%s&format=json&preferences=eJx1WMuy4zYO_"
|
||||
"Zp4o4ormaRqahZepZL5gexVFAlLiEhCzYdt3a8PoIdFWt2Ldl8fkCCIxwForRL0FBDirQc"
|
||||
"PQdmLVb7PqoebyokulrSycPP2Il81uclCgtvlrh6oybcBItkHhNsFHW9qp0Cv-"
|
||||
"faXshEuDtJA5vb_P_--RHWHCCro4fbLJQ3g4BZRdF1YQbYptqzLw7NNqtt2G8JDOyn-"
|
||||
"eqXQX9ZtbUyz3UzU4BOEVlnsveO_t_3KPJTXYNrt3BX9liH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UKcv8pVtjkcpxw-w5k2GphT_-ttv_30dmiN8eeWq_"
|
||||
"cvkWCJePSTpypyoG_OTgvE4FgMcn62reuRul-QBKYo-yPSprB34CP_"
|
||||
"hQ8c9vTolpXDFYvbldvCorr4A54Cs8HnKWeDP9lnpS7_vPyIcP7RMNvPYF2-"
|
||||
"k2vUnpGfgsl86aUzsy7XeKLQ8IunxPSzu28QzPJW08nNO4EA91uFJWZ05VhSWsuQ3Dbc4F"
|
||||
"qVtHrb3Fv2d5BSp11XZhZ8WzP-3fwFOiVFV",
|
||||
q_encoded);
|
||||
free(q_encoded);
|
||||
|
||||
char *ret = curl_get(news);
|
||||
free(news);
|
||||
if (!ret) continue;
|
||||
if (!ret)
|
||||
continue;
|
||||
|
||||
json_object *json_ret = json_tokener_parse(ret);
|
||||
if (!json_ret) {
|
||||
@ -76,12 +172,15 @@ char *web_search_engine(char *q) {
|
||||
const int MAX_RETRIES = 3;
|
||||
for (int retry = 0; retry < MAX_RETRIES; retry++) {
|
||||
char *searx = malloc(4096);
|
||||
if (!searx) return NULL;
|
||||
if (!searx)
|
||||
return NULL;
|
||||
searx[0] = 0;
|
||||
snprintf(searx, 4096, "https://searx.molodetz.nl/search?q=%s&format=json", q);
|
||||
snprintf(searx, 4096, "https://searx.molodetz.nl/search?q=%s&format=json",
|
||||
q);
|
||||
char *ret = curl_get(searx);
|
||||
free(searx);
|
||||
if (!ret) continue;
|
||||
if (!ret)
|
||||
continue;
|
||||
|
||||
json_object *json_ret = json_tokener_parse(ret);
|
||||
if (!json_ret) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "db_utils.h"
|
||||
#include <sqlite3.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sqlite3.h>
|
||||
|
||||
void db_initialize() {
|
||||
sqlite3 *db;
|
||||
|
||||
12
db_utils.h
12
db_utils.h
@ -22,8 +22,6 @@ json_object *db_set(const char *key, const char *value);
|
||||
json_object *db_get(const char *key);
|
||||
json_object *db_query(const char *query);
|
||||
|
||||
|
||||
|
||||
void db_initialize() {
|
||||
sqlite3 *db;
|
||||
int rc = sqlite3_open(db_file_expanded(), &db);
|
||||
@ -32,8 +30,10 @@ void db_initialize() {
|
||||
return;
|
||||
}
|
||||
|
||||
db_execute("CREATE TABLE IF NOT EXISTS kv_store (key TEXT PRIMARY KEY, value TEXT);");
|
||||
db_execute("CREATE TABLE IF NOT EXISTS file_version_history ( id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
||||
db_execute("CREATE TABLE IF NOT EXISTS kv_store (key TEXT PRIMARY KEY, value "
|
||||
"TEXT);");
|
||||
db_execute("CREATE TABLE IF NOT EXISTS file_version_history ( id INTEGER "
|
||||
"PRIMARY KEY AUTOINCREMENT,"
|
||||
"path TEXT NOT NULL,"
|
||||
"content TEXT,"
|
||||
"date DATETIME DEFAULT CURRENT_TIMESTAMP"
|
||||
@ -188,7 +188,9 @@ void db_store_file_version(const char * path) {
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "Creating backup:: %s\n", expanded);
|
||||
char * formatted = sqlite3_mprintf("INSERT INTO file_version_history (path, content) VALUES (%Q, %Q)", expanded, content);
|
||||
char *formatted = sqlite3_mprintf(
|
||||
"INSERT INTO file_version_history (path, content) VALUES (%Q, %Q)",
|
||||
expanded, content);
|
||||
db_execute(formatted);
|
||||
sqlite3_free(formatted);
|
||||
free(content);
|
||||
|
||||
72
indexer.h
72
indexer.h
@ -12,17 +12,20 @@
|
||||
#define MAX_PATH 4096
|
||||
|
||||
static const char *extensions[] = {
|
||||
".c", ".cpp", ".h", ".py", ".java", ".js", ".mk", ".html",
|
||||
"Makefile", ".css", ".json", ".cs", ".csproj", ".sln", ".toml", ".rs",
|
||||
".go", ".rb", ".swift", ".php", ".pl", ".sh", ".bash", ".sql",
|
||||
".xml", ".yaml", ".yml", ".kt", ".dart", ".scala", ".clj", ".asm",
|
||||
".m", ".r", ".lua", ".groovy", ".v", ".pas", ".d", ".f90", ".f95",
|
||||
".for", ".s", ".tcl", ".vhdl", ".verilog", ".coffee", ".less", ".scss",
|
||||
".ps1", ".psm1", ".cmd", ".bat", ".json5", ".cxx", ".cc", ".hpp",
|
||||
".hxx", ".inc", ".nsi", ".ninja", ".cmake", ".cmake.in", ".mk.in",
|
||||
".make", ".makefile", ".gyp", ".gypi", ".pro", ".qml", ".ui", ".wxs",
|
||||
".wxl", ".wxi", ".wxl", ".wxs", ".wxi", ".wxl", ".wxs", ".wxi"
|
||||
};
|
||||
".c", ".cpp", ".h", ".py", ".java", ".js",
|
||||
".mk", ".html", "Makefile", ".css", ".json", ".cs",
|
||||
".csproj", ".sln", ".toml", ".rs", ".go", ".rb",
|
||||
".swift", ".php", ".pl", ".sh", ".bash", ".sql",
|
||||
".xml", ".yaml", ".yml", ".kt", ".dart", ".scala",
|
||||
".clj", ".asm", ".m", ".r", ".lua", ".groovy",
|
||||
".v", ".pas", ".d", ".f90", ".f95", ".for",
|
||||
".s", ".tcl", ".vhdl", ".verilog", ".coffee", ".less",
|
||||
".scss", ".ps1", ".psm1", ".cmd", ".bat", ".json5",
|
||||
".cxx", ".cc", ".hpp", ".hxx", ".inc", ".nsi",
|
||||
".ninja", ".cmake", ".cmake.in", ".mk.in", ".make", ".makefile",
|
||||
".gyp", ".gypi", ".pro", ".qml", ".ui", ".wxs",
|
||||
".wxl", ".wxi", ".wxl", ".wxs", ".wxi", ".wxl",
|
||||
".wxs", ".wxi"};
|
||||
static const size_t ext_count = sizeof(extensions) / sizeof(extensions[0]);
|
||||
|
||||
typedef struct {
|
||||
@ -38,17 +41,21 @@ static size_t file_count = 0;
|
||||
|
||||
static int is_valid_extension(const char *filename) {
|
||||
const char *dot = strrchr(filename, '.');
|
||||
if (!dot) dot = filename;
|
||||
if (!dot)
|
||||
dot = filename;
|
||||
for (size_t i = 0; i < ext_count; i++) {
|
||||
if (strcmp(dot, extensions[i]) == 0) return 1;
|
||||
if (strcmp(dot, extensions[i]) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_ignored_directory(const char *dir_name) {
|
||||
const char *ignored_dirs[] = {"env", ".venv", "node_modules", "venv", "virtualenv"};
|
||||
const char *ignored_dirs[] = {"env", ".venv", "node_modules", "venv",
|
||||
"virtualenv"};
|
||||
for (size_t i = 0; i < sizeof(ignored_dirs) / sizeof(ignored_dirs[0]); i++) {
|
||||
if (strcmp(dir_name, ignored_dirs[i]) == 0) return 1;
|
||||
if (strcmp(dir_name, ignored_dirs[i]) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -59,9 +66,12 @@ static void get_file_info(const char *path) {
|
||||
FileInfo info;
|
||||
strncpy(info.name, path, MAX_PATH - 1);
|
||||
info.name[MAX_PATH - 1] = '\0';
|
||||
strftime(info.modification_date, sizeof(info.modification_date), "%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_mtime));
|
||||
strftime(info.creation_date, sizeof(info.creation_date), "%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_ctime));
|
||||
strncpy(info.type, S_ISDIR(file_stat.st_mode) ? "directory" : "file", sizeof(info.type) - 1);
|
||||
strftime(info.modification_date, sizeof(info.modification_date),
|
||||
"%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_mtime));
|
||||
strftime(info.creation_date, sizeof(info.creation_date),
|
||||
"%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_ctime));
|
||||
strncpy(info.type, S_ISDIR(file_stat.st_mode) ? "directory" : "file",
|
||||
sizeof(info.type) - 1);
|
||||
info.type[sizeof(info.type) - 1] = '\0';
|
||||
info.size_bytes = file_stat.st_size;
|
||||
file_list[file_count++] = info;
|
||||
@ -79,8 +89,10 @@ char *index_directory(const char *dir_path) {
|
||||
json_object *jarray = json_object_new_array();
|
||||
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
|
||||
if (entry->d_name[0] == '.' || is_ignored_directory(entry->d_name)) continue;
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
|
||||
continue;
|
||||
if (entry->d_name[0] == '.' || is_ignored_directory(entry->d_name))
|
||||
continue;
|
||||
|
||||
char full_path[MAX_PATH];
|
||||
snprintf(full_path, sizeof(full_path), "%s/%s", dir_path, entry->d_name);
|
||||
@ -95,11 +107,21 @@ char *index_directory(const char *dir_path) {
|
||||
} else if (is_valid_extension(entry->d_name)) {
|
||||
get_file_info(full_path);
|
||||
json_object *jfile = json_object_new_object();
|
||||
json_object_object_add(jfile, "file_name", json_object_new_string(file_list[file_count - 1].name));
|
||||
json_object_object_add(jfile, "modification_date", json_object_new_string(file_list[file_count - 1].modification_date));
|
||||
json_object_object_add(jfile, "creation_date", json_object_new_string(file_list[file_count - 1].creation_date));
|
||||
json_object_object_add(jfile, "type", json_object_new_string(file_list[file_count - 1].type));
|
||||
json_object_object_add(jfile, "size_bytes", json_object_new_int64(file_list[file_count - 1].size_bytes));
|
||||
json_object_object_add(
|
||||
jfile, "file_name",
|
||||
json_object_new_string(file_list[file_count - 1].name));
|
||||
json_object_object_add(
|
||||
jfile, "modification_date",
|
||||
json_object_new_string(file_list[file_count - 1].modification_date));
|
||||
json_object_object_add(
|
||||
jfile, "creation_date",
|
||||
json_object_new_string(file_list[file_count - 1].creation_date));
|
||||
json_object_object_add(
|
||||
jfile, "type",
|
||||
json_object_new_string(file_list[file_count - 1].type));
|
||||
json_object_object_add(
|
||||
jfile, "size_bytes",
|
||||
json_object_new_int64(file_list[file_count - 1].size_bytes));
|
||||
|
||||
json_object_array_add(jarray, jfile);
|
||||
}
|
||||
|
||||
40
main.c
40
main.c
@ -1,18 +1,18 @@
|
||||
#include "r.h"
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "db_utils.h"
|
||||
#include "line.h"
|
||||
#include "markdown.h"
|
||||
#include "openai.h"
|
||||
#include "utils.h"
|
||||
#include "db_utils.h"
|
||||
#include "tools.h"
|
||||
#include "utils.h"
|
||||
|
||||
volatile sig_atomic_t sigint_count = 0;
|
||||
time_t first_sigint_time = 0;
|
||||
@ -75,7 +75,8 @@ char *get_prompt_from_args(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (get_from_std_in) {
|
||||
if (*system) openai_system(system);
|
||||
if (*system)
|
||||
openai_system(system);
|
||||
prompt = get_prompt_from_stdin(prompt);
|
||||
} else {
|
||||
free(prompt);
|
||||
@ -143,7 +144,8 @@ void repl() {
|
||||
|
||||
while (true) {
|
||||
line = line_read("> ");
|
||||
if (!line || !*line) continue;
|
||||
if (!line || !*line)
|
||||
continue;
|
||||
|
||||
if (!strncmp(line, "!dump", 5)) {
|
||||
printf("%s\n", message_json());
|
||||
@ -151,12 +153,15 @@ void repl() {
|
||||
}
|
||||
if (!strncmp(line, "!verbose", 8)) {
|
||||
is_verbose = !is_verbose;
|
||||
fprintf(stderr, "%s\n", is_verbose ? "Verbose mode enabled" : "Verbose mode disabled");
|
||||
fprintf(stderr, "%s\n",
|
||||
is_verbose ? "Verbose mode enabled" : "Verbose mode disabled");
|
||||
continue;
|
||||
}
|
||||
if (line && *line != '\n') line_add_history(line);
|
||||
if (line && *line != '\n')
|
||||
line_add_history(line);
|
||||
if (!strncmp(line, "!tools", 6)) {
|
||||
printf("Available tools: %s\n", json_object_to_json_string(tools_descriptions()));
|
||||
printf("Available tools: %s\n",
|
||||
json_object_to_json_string(tools_descriptions()));
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(line, "!models", 7)) {
|
||||
@ -170,7 +175,8 @@ void repl() {
|
||||
printf("Current model: %s\n", get_prompt_model());
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(line, "exit", 4)) exit(0);
|
||||
if (!strncmp(line, "exit", 4))
|
||||
exit(0);
|
||||
|
||||
while (line && *line != '\n') {
|
||||
char *response = openai_chat("user", line);
|
||||
@ -192,17 +198,20 @@ void repl() {
|
||||
|
||||
char *strreplace(const char *content, const char *what, const char *with) {
|
||||
char *pos = strstr(content, what);
|
||||
if (!pos) return strdup(content);
|
||||
if (!pos)
|
||||
return strdup(content);
|
||||
|
||||
size_t result_size = strlen(content) + strlen(with) - strlen(what) + 1;
|
||||
char *result = malloc(result_size);
|
||||
snprintf(result, result_size, "%.*s%s%s", (int)(pos - content), content, with, pos + strlen(what));
|
||||
snprintf(result, result_size, "%.*s%s%s", (int)(pos - content), content, with,
|
||||
pos + strlen(what));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool openai_include(const char *path) {
|
||||
char *file_content = read_file(path);
|
||||
if (!file_content) return false;
|
||||
if (!file_content)
|
||||
return false;
|
||||
|
||||
openai_system(file_content);
|
||||
free(file_content);
|
||||
@ -217,7 +226,9 @@ void init() {
|
||||
char *schema = db_get_schema();
|
||||
char payload[1024 * 1024] = {0};
|
||||
snprintf(payload, sizeof(payload),
|
||||
"Your have a database that you can mutate using the query tool and the get and set tool. This is the schema in json format: %s. Dialect is sqlite.",
|
||||
"Your have a database that you can mutate using the query tool and "
|
||||
"the get and set tool. This is the schema in json format: %s. "
|
||||
"Dialect is sqlite.",
|
||||
schema);
|
||||
free(schema);
|
||||
|
||||
@ -249,7 +260,8 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGINT, handle_sigint);
|
||||
|
||||
init();
|
||||
if (try_prompt(argc, argv)) return 0;
|
||||
if (try_prompt(argc, argv))
|
||||
return 0;
|
||||
|
||||
repl();
|
||||
return 0;
|
||||
|
||||
@ -25,10 +25,10 @@
|
||||
#ifndef R_MESSAGES_H
|
||||
#define R_MESSAGES_H
|
||||
|
||||
#include "db_utils.h"
|
||||
#include "json-c/json.h"
|
||||
#include "tools.h"
|
||||
#include <string.h>
|
||||
#include "db_utils.h"
|
||||
struct json_object *message_array = NULL;
|
||||
|
||||
struct json_object *message_list() {
|
||||
@ -82,7 +82,6 @@ void message_add_object(json_object *message) {
|
||||
json_object_array_add(messages, message);
|
||||
}
|
||||
|
||||
|
||||
struct json_object *message_add(const char *role, const char *content);
|
||||
|
||||
struct json_object *message_add(const char *role, const char *content) {
|
||||
@ -95,12 +94,14 @@ struct json_object *message_add(const char *role, const char *content) {
|
||||
if (strlen(formatted_content) > 1048570) {
|
||||
formatted_content[1048570] = '\0';
|
||||
}
|
||||
json_object_object_add(message, "content", json_object_new_string(formatted_content));
|
||||
json_object_object_add(message, "content",
|
||||
json_object_new_string(formatted_content));
|
||||
free(formatted_content);
|
||||
}
|
||||
if (!strcmp(role, "user")) {
|
||||
json_object_object_add(message, "tools", tools_descriptions());
|
||||
json_object_object_add(message, "parallel_tool_calls", json_object_new_boolean(true));
|
||||
json_object_object_add(message, "parallel_tool_calls",
|
||||
json_object_new_boolean(true));
|
||||
}
|
||||
|
||||
json_object_array_add(messages, message);
|
||||
|
||||
4
openai.h
4
openai.h
@ -128,8 +128,8 @@ char *openai_chat(const char *user_role, const char *message_content) {
|
||||
message_add_tool_call(tool_call_result);
|
||||
}
|
||||
char *tool_calls_result_str = chat_json(NULL, NULL);
|
||||
message_object =
|
||||
openai_process_chat_message(get_completions_api_url(), tool_calls_result_str);
|
||||
message_object = openai_process_chat_message(get_completions_api_url(),
|
||||
tool_calls_result_str);
|
||||
if (message_object == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
1
r.h
1
r.h
@ -49,7 +49,6 @@ bool get_use_strict(){
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
char *get_completions_api_url() {
|
||||
|
||||
59
tools.h
59
tools.h
@ -12,23 +12,21 @@
|
||||
#ifndef R_TOOLS_H
|
||||
#define R_TOOLS_H
|
||||
|
||||
|
||||
#include "http_curl.h"
|
||||
#include "r.h"
|
||||
#include "utils.h"
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <glob.h>
|
||||
#include <json-c/json.h>
|
||||
#include <json-c/json_object.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "browse.h"
|
||||
#include "db_utils.h"
|
||||
@ -121,7 +119,8 @@ struct json_object *tool_description_web_search_news() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -177,7 +176,8 @@ struct json_object *tool_description_web_search() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -230,7 +230,8 @@ struct json_object *tool_description_db_get() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -282,7 +283,8 @@ struct json_object *tool_description_db_query() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -341,7 +343,8 @@ struct json_object *tool_description_db_set() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -372,14 +375,12 @@ char *tool_function_linux_terminal(char *command) {
|
||||
command = stderr_command;
|
||||
}
|
||||
|
||||
|
||||
fp = popen(command, "r");
|
||||
if (fp == NULL) {
|
||||
perror("popen failed");
|
||||
return strdup("Popen failed!");
|
||||
}
|
||||
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
|
||||
size_t chunk_size = strlen(buffer);
|
||||
char *new_output = realloc(output, total_size + chunk_size + 1);
|
||||
@ -483,7 +484,8 @@ struct json_object *tool_description_chdir() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -525,7 +527,8 @@ struct json_object *tool_description_index_source_directory() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -570,7 +573,8 @@ struct json_object *tool_description_linux_terminal_interactive() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -615,7 +619,8 @@ struct json_object *tool_description_directory_rglob() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -656,7 +661,8 @@ struct json_object *tool_description_read_file() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -710,7 +716,8 @@ struct json_object *tool_description_write_file() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -724,7 +731,8 @@ char *tool_function_index_source_directory(char *path) {
|
||||
char *tool_function_mkdir(char *path);
|
||||
|
||||
void ensure_parent_directory_exists(char *path_including_file_name) {
|
||||
if(!path_including_file_name) return;
|
||||
if (!path_including_file_name)
|
||||
return;
|
||||
|
||||
char *path = strdup(path_including_file_name);
|
||||
char *last_slash = strrchr(path, '/');
|
||||
@ -1009,7 +1017,8 @@ struct json_object *tool_description_http_get() {
|
||||
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -1053,7 +1062,8 @@ struct json_object *tool_description_directory_glob() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -1094,7 +1104,8 @@ struct json_object *tool_description_linux_terminal() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
@ -1133,7 +1144,8 @@ struct json_object *tool_description_mkdir() {
|
||||
json_object_object_add(function, "name", json_object_new_string("mkdir"));
|
||||
json_object_object_add(
|
||||
function, "description",
|
||||
json_object_new_string("Creates a new directory with the specified path."));
|
||||
json_object_new_string(
|
||||
"Creates a new directory with the specified path."));
|
||||
|
||||
struct json_object *parameters = json_object_new_object();
|
||||
json_object_object_add(parameters, "type", json_object_new_string("object"));
|
||||
@ -1158,7 +1170,8 @@ struct json_object *tool_description_mkdir() {
|
||||
json_object_object_add(function, "parameters", parameters);
|
||||
|
||||
if (get_use_strict())
|
||||
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
|
||||
json_object_object_add(function, "strict",
|
||||
json_object_new_boolean(get_use_strict()));
|
||||
|
||||
json_object_object_add(root, "function", function);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user