Compare commits
3 Commits
534fb6bfcf
...
2834e28db2
Author | SHA1 | Date | |
---|---|---|---|
2834e28db2 | |||
80d72823f7 | |||
cc1c6570e3 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ rf
|
||||
auth.h
|
||||
.rcontext*
|
||||
tests
|
||||
rpylib.so
|
||||
|
2
chat.h
2
chat.h
@ -54,7 +54,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, "max_tokens", json_object_new_int(prompt_max_tokens));
|
||||
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);
|
||||
|
33
markdown.h
33
markdown.h
@ -35,7 +35,29 @@
|
||||
#define FG_CYAN "\033[36m"
|
||||
|
||||
int is_keyword(const char *word) {
|
||||
const char *keywords[] = {"int", "float", "double", "char", "void", "if", "else", "while", "for", "return", "struct", "printf"};
|
||||
|
||||
const char *keywords[] = {
|
||||
"int", "float", "double", "char", "void",
|
||||
"if", "else", "while", "for", "return",
|
||||
"struct", "printf",
|
||||
// Rust keywords
|
||||
"let", "fn", "impl", "match", "enum", "trait", "use", "mod", "pub", "const", "static",
|
||||
// Python keywords
|
||||
"def", "class", "import", "from", "as", "with", "try", "except", "finally", "lambda", "async", "await",
|
||||
// Java keywords
|
||||
"public", "private", "protected", "class", "interface", "extends", "implements", "new", "static", "final", "synchronized",
|
||||
// JavaScript keywords
|
||||
"var", "let", "const", "function", "async", "await", "if", "else", "switch", "case", "break", "continue", "return",
|
||||
// C++ keywords
|
||||
"namespace", "template", "typename", "class", "public", "private", "protected", "virtual", "override", "friend", "new",
|
||||
// Go keywords
|
||||
"package", "import", "func", "var", "const", "type", "interface", "struct", "go", "defer", "select",
|
||||
// Bash keywords
|
||||
"if", "then", "else", "elif", "fi", "case", "esac", "for", "while", "until", "do", "done", "function",
|
||||
// C# keywords
|
||||
"namespace", "using", "class", "interface", "public", "private", "protected", "static", "void", "new", "override"
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(keywords) / sizeof(keywords[0]); i++) {
|
||||
if (strcmp(word, keywords[i]) == 0) {
|
||||
return 1;
|
||||
@ -81,7 +103,7 @@ void parse_markdown_to_ansi(const char *markdown) {
|
||||
bool inside_code = false;
|
||||
|
||||
while (*ptr) {
|
||||
if (*ptr == '`') {
|
||||
if (*ptr == '`' && *(ptr + 1) != '`') {
|
||||
inside_code = !inside_code;
|
||||
if (inside_code) {
|
||||
printf(FG_YELLOW);
|
||||
@ -90,10 +112,13 @@ void parse_markdown_to_ansi(const char *markdown) {
|
||||
}
|
||||
ptr++;
|
||||
continue;
|
||||
}else if(!strncmp(ptr, "```", 3)) {
|
||||
inside_code = !inside_code;
|
||||
ptr = strstr(ptr, "\n") + 1;
|
||||
}
|
||||
|
||||
if (inside_code) {
|
||||
char code_buffer[4096];
|
||||
char code_buffer[1024*1024] = {0};;
|
||||
size_t index = 0;
|
||||
|
||||
while (*ptr && *ptr != '`') {
|
||||
@ -152,4 +177,4 @@ void parse_markdown_to_ansi(const char *markdown) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
r.h
2
r.h
@ -3,7 +3,7 @@
|
||||
#include "malloc.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "auth.h"
|
||||
bool is_verbose = false;
|
||||
|
||||
|
2
tools.h
2
tools.h
@ -8,7 +8,7 @@
|
||||
|
||||
#ifndef R_TOOLS_H
|
||||
#define R_TOOLS_H
|
||||
|
||||
#include "r.h"
|
||||
#include <stdio.h>
|
||||
#include <json-c/json.h>
|
||||
#include <json-c/json_object.h>
|
||||
|
Loading…
Reference in New Issue
Block a user