Compare commits

..

No commits in common. "b36990f550a06b210aed02fc0c5ffe66672e501b" and "d2f57931a1df548903d374ca86bae580d2fcb285" have entirely different histories.

5 changed files with 18 additions and 71 deletions

View File

@ -24,8 +24,6 @@ R Vibe Tool is a powerful Command-Line Interface (CLI) utility designed for Linu
### Environment Variables
TIP: create bash files containg these variables and make them easily accessable. For example by symlinking them to `~/.bash_aliases` or `~/.bash_profile`. Or even easier, make them executable and put them in /usr/local/bin.
#### Ollama Configuration
```bash
export R_MODEL="qwen2.5:3b"
@ -41,22 +39,6 @@ export R_KEY="sk-ant-[your-key]"
./r
```
#### OpenAI Configuration
```bash
export R_MODEL="gpt-4o-mini"
export R_BASE_URL="https://api.openai.com"
export R_KEY="sk-[your-key]"
./r
```
#### Grok Configuration
```bash
export R_MODEL="grok-2"
export R_BASE_URL="https://api.x.ai"
export R_USE_STRICT=false
export R_KEY="xai-gfh"
```
## Best Practices
1. Use `~/.rcontext.txt` to define specific behavioral instructions

View File

@ -59,17 +59,12 @@ struct json_object *message_add_tool_call(struct json_object *message) {
}
struct json_object *message_add_tool_result(const char *tool_call_id,
char *tool_result) {
const char *tool_result) {
struct json_object *messages = message_list();
struct json_object *message = json_object_new_object();
json_object_object_add(message, "tool_call_id",
json_object_new_string(tool_call_id));
if(strlen(tool_result) > 104000){
tool_result[104000] = '\0';
}
json_object_object_add(message, "tool_result",
json_object_new_string(tool_result));
@ -89,18 +84,10 @@ struct json_object *message_add(const char *role, const char *content) {
struct json_object *messages = message_list();
struct json_object *message = json_object_new_object();
json_object_object_add(message, "role", json_object_new_string(role));
if(content){
char * formatted_content = strdup(content);
if(strlen(formatted_content) > 1048570){
formatted_content[1048570] = '\0';
}
json_object_object_add(message, "content", json_object_new_string(formatted_content));
free(formatted_content);
}
json_object_object_add(message, "content", json_object_new_string(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_array_add(messages, message);

20
r.h
View File

@ -32,26 +32,6 @@ char *_model = NULL;
#define DB_FILE "~/.r.db"
#define PROMPT_TEMPERATURE 0.1
bool get_use_strict(){
if(getenv("R_USE_STRICT") != NULL) {
const char * value = getenv("R_USE_STRICT");
if(!strcmp(value, "true")) {
return true;
}
if(!strcmp(value, "false")) {
return false;
}
if(!strcmp(value, "1")) {
return true;
}
if(!strcmp(value, "0")) {
return false;
}
}
return true;
}
char * get_completions_api_url() {
if(getenv("R_BASE_URL") != NULL) {
return joinpath(getenv("R_BASE_URL"), "v1/chat/completions");

BIN
rpylib.so

Binary file not shown.

32
tools.h
View File

@ -11,8 +11,6 @@
#ifndef R_TOOLS_H
#define R_TOOLS_H
#include "http_curl.h"
#include "r.h"
#include "utils.h"
@ -119,7 +117,7 @@ struct json_object *tool_description_web_search_news() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -173,7 +171,7 @@ struct json_object *tool_description_web_search() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -224,7 +222,7 @@ struct json_object *tool_description_db_get() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -274,7 +272,7 @@ struct json_object *tool_description_db_query() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -331,7 +329,7 @@ struct json_object *tool_description_db_set() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -470,7 +468,7 @@ struct json_object *tool_description_chdir() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -510,7 +508,7 @@ struct json_object *tool_description_index_source_directory() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -553,7 +551,7 @@ struct json_object *tool_description_linux_terminal_interactive() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -596,7 +594,7 @@ struct json_object *tool_description_directory_rglob() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -635,7 +633,7 @@ struct json_object *tool_description_read_file() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -687,7 +685,7 @@ struct json_object *tool_description_write_file() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -972,7 +970,7 @@ struct json_object *tool_description_http_get() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -1014,7 +1012,7 @@ struct json_object *tool_description_directory_glob() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -1053,7 +1051,7 @@ struct json_object *tool_description_linux_terminal() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);
@ -1099,7 +1097,7 @@ struct json_object *tool_description_mkdir() {
json_object_new_boolean(0));
json_object_object_add(function, "parameters", parameters);
json_object_object_add(function, "strict", json_object_new_boolean(get_use_strict()));
json_object_object_add(function, "strict", json_object_new_boolean(1));
json_object_object_add(root, "function", function);