Added auth.

This commit is contained in:
2025-01-04 16:54:48 +01:00
parent c05edc45d9
commit 413c3b9599
5 changed files with 52 additions and 17 deletions
+11 -13
View File
@@ -86,7 +86,6 @@ void render(char *content) {
void repl() {
line_init();
setbuf(stdout, NULL);
char *line;
char *previous_line = NULL;
while ((line = line_read("> "))) {
@@ -164,10 +163,10 @@ void help() {
render(help_text);
}
void openai_include(char *path) {
bool openai_include(char *path) {
FILE *file = fopen(path, "r");
if (file == NULL) {
return;
return false;
}
fseek(file, 0, SEEK_END);
long size = ftell(file);
@@ -176,7 +175,7 @@ void openai_include(char *path) {
char *buffer = (char *)malloc(size);
size_t read = fread(buffer, 1, size, file);
if (read == 0) {
return;
return false;
}
fclose(file);
@@ -184,22 +183,21 @@ void openai_include(char *path) {
openai_system(buffer);
free(buffer);
return true;
}
void init() {
setbuf(stdout, NULL);
line_init();
const char *locale = setlocale(LC_ALL, NULL);
char payload[4096] = {0};
sprintf(payload, "User locale is %s. User lang is %s.\n"
"You are Retoor. Use a lot of markdown in response.\n"
"Be confident and short in answers.\n"
"You divide things by zero if you have to.",
locale, locale);
printf("%s", "Loading...");
sprintf(payload, "Your locale is %s. User lang is %s.", locale, locale);
printf("%s", "Loading... ⏳");
openai_system(payload);
openai_include("context.txt");
printf("%s", "\rLoaded! Type help for features.\n");
if(!openai_include(".rcontext.txt")){
openai_include("~/.rcontext.txt");
}
printf("%s", "\r✅ Type help for features.\n");
}
int main(int argc, char *argv[]) {