Commit Graph

64 Commits

Author SHA1 Message Date
47aa1693ea chore: add rd build target and deepinfra api config with custom malloc tracking 2025-03-28 20:38:50 +00:00
7befee245d feat: add Ollama support with conditional compilation and new build targets
Introduce conditional compilation via OLLAMA preprocessor flag to switch between OpenAI and Ollama API endpoints, model names, and URLs. Add `build_free` and `run_free` Makefile targets for the Ollama variant. Enhance REPL with `!models` command to list available models, improve error handling in `openai_process_chat_message`, and fix history line addition logic.
2025-03-28 19:50:10 +00:00
fec259097a chore: normalize indentation to 2 spaces and reorder includes in auth.h, browse.c, chat.h, db_utils.c, db_utils.h, http_curl.h 2025-03-28 05:56:36 +00:00
599a268e65 refactor: replace hardcoded prompt_temperature and db_file with PROMPT_TEMPERATURE and DB_FILE macros defined in r.h 2025-03-28 05:55:22 +00:00
7dfd1c0b44 fix: prevent infinite recursion in web_search and add upsert logic to db_set with new db_execute function 2025-03-28 04:37:22 +00:00
0b54f87e3a docs: add multi-language keyword support and expand code buffer in markdown parser 2025-03-28 02:10:54 +00:00
e903226953 fix: handle triple backtick code blocks in markdown-to-ansi parser and add rpylib.so to gitignore 2025-03-28 02:02:24 +00:00
3d4b57d8ae fix: comment out max_tokens field and add missing includes across multiple headers 2025-03-28 01:41:15 +00:00
8dc66bbfaa feat: add web_search function and dynamic model switching with !dump/!model/!debug commands 2025-03-28 00:55:04 +00:00
9348e4ebea chore: add sqlite3 link, increase prompt tokens, expand history path, and refine tool descriptions 2025-03-27 22:08:00 +00:00
7cd02d81f5 fix: guard against null avatar URL in user profile loader before dereference 2025-03-22 02:16:14 +00:00
eccb17d766 chore: add sqlite3 link flag, verbose mode, and new browse/db_utils modules to build system 2025-03-22 02:15:49 +00:00
0689101e72 feat: add real-time stdout printing during terminal command execution in tools.h
The change inserts a `printf("%s", output)` call inside the `tool_function_linux_terminal` function, immediately after reallocating the output buffer and before appending new data. This enables real-time display of captured process output to the console as chunks are received, rather than only returning the final aggregated string. The modification affects the core execution loop in `tools.h` where command output is accumulated from the process stream.
2025-03-21 08:19:41 +00:00
aa0467475d chore: clear terminal on first SIGINT before printing exit prompt in main.c
Add explicit system("clear") call and newline in handle_sigint to visually reset the terminal display before showing the double-Ctrl+C exit message, ensuring clean output regardless of prior screen state.
2025-03-21 02:27:11 +00:00
4e05fe540d feat: add glob-based file path autocompletion to readline input handler
Add file path completion support alongside existing command completion in the readline-based input system. Include <glob.h> header and implement line_file_generator function that uses glob pattern matching to suggest file paths based on partial input. Modify line_command_completion to detect file path context (non-command input after start position) and delegate to the new file generator, enabling tab-completion of filenames and directories in the shell-like interface.
2025-03-21 02:22:19 +00:00
50419881dd feat: add double-sigint exit, --free flag, model command, and index_source_directory tool
- Add SIGINT handler that exits on two Ctrl+C presses within 1 second
- Introduce --free flag to switch auth type to AUTH_TYPE_FREE via auth_free()
- Implement "model" REPL command to print current prompt model name
- Register index_source_directory tool description and function in tools.h
2025-03-21 00:15:40 +00:00
075e4efc4f fix: replace message_add_tool_call with message_add_object in openai_chat function 2025-03-20 16:00:13 +00:00
eb99686ce9 feat: add message_add_object helper and integrate into openai_chat flow
Add a new `message_add_object` function in messages.h that appends a json_object to the global message list. Modify openai_chat in openai.h to call this function after processing a chat completion, ensuring the assistant's response object is stored. Also comment out the previous `message_add_tool_call` call to avoid duplicate message storage when tool calls are present, and add a missing `continue` in main.c's repl loop after the dump command to prevent fallthrough.
2025-03-20 15:38:10 +00:00
1bc92e5834 feat: add prompt and system methods to rpylib.c and remove free build from Makefile
- Added rpylib_prompt and rpylib_system functions to rpylib.c for user and system role OpenAI chat
- Removed build_free target from Makefile and added publish step for rpylib.so build
2025-03-20 03:13:26 +00:00
4fed366425 chore: refactor Makefile with CC/CFLAGS variables and reorder build targets 2025-03-20 01:57:47 +00:00
1a77a5b692 fix: add dump command to repl and remove deprecated hello function from rpylib 2025-03-20 01:36:56 +00:00
0a18669f40 feat: add auth_init function and remove version-specific startup messages
Implement auth_init() in auth.h to detect API keys from environment variables (R_KEY or OPENAI_API_KEY) and set auth_type accordingly. In main.c, call auth_init() during init() and replace the conditional commercial/free version startup messages with a simple carriage return clear.
2025-03-19 21:02:39 +00:00
91553e1979 feat: replace compile-time free tier flag with runtime auth_type enum for model selection
Add AUTH_TYPE enum and global auth_type variable to auth.h, replacing the FREE_VERSION preprocessor conditional in chat.h with a dynamic get_prompt_model() function that returns "gpt-3.5-turbo" for free users and "gpt-4o-mini" for API key holders. Update all references to prompt_model to use the new function, enabling runtime model switching without recompilation.
2025-03-19 20:45:07 +00:00
6b08d3334c fix: return empty string instead of null on glob failure in directory glob
The tool_function_directory_glob function previously returned NULL when the glob
pattern failed to match, causing a null pointer dereference in the user profile
avatar loader when it attempted to process the result. Changed the return value
to an empty string to ensure callers always receive a valid pointer.
2025-03-19 20:25:34 +00:00
6d84cbef32 fix: correct integer overflow in rpylib.c buffer size calculation for large inputs 2025-03-19 17:05:42 +00:00
af7969a183 feat: add messages_remove function to delete all chat messages by repeatedly removing last entry 2025-03-19 17:04:32 +00:00
a0feb4b985 fix: remove stderr warning and hardcode fallback api key in resolve_api_key
The diff removes a diagnostic fprintf to stderr that warned about a missing
environment variable, and replaces the null return path with a hardcoded
fallback API key string in auth.h's resolve_api_key function.
2025-03-16 22:35:35 +00:00
6e3e899832 chore: remove FREE_VERSION conditional and add --py flag for python file inclusion 2025-03-16 21:46:09 +00:00
8b25cb93d4 chore: add static qualifiers to global variables and const-correctness to tool result parameters 2025-03-16 06:36:13 +00:00
3aa4f0d02e chore: remove trailing whitespace from line.h and delete unused http.h module 2025-03-05 23:10:15 +00:00
8d1968ce97 fix: add null checks for openai responses and implement interactive terminal tool with home directory expansion 2025-03-05 22:53:35 +00:00
8a13f1a59c chore: replace placeholder branding with final logo and color scheme 2025-03-03 16:06:05 +00:00
d819021fdb chore: add directory_rglob tool declaration and registration to tools.h 2025-03-03 13:51:13 +00:00
be5e2e4c05 fix: clarify directory_glob tool description to specify glob format output 2025-03-03 13:09:28 +00:00
c247e3b1bb fix: remove debug print statements from chat_json and tools_descriptions functions 2025-03-03 12:57:16 +00:00
d626f1e8e5 chore: strip license boilerplate and commented dead code from openai.h header 2025-03-03 12:53:24 +00:00
b54efff1f3 feat: add file system tools and debug logging for prompt and tool descriptions 2025-03-03 12:51:57 +00:00
0bc2698d83 fix: return strdup instead of string literal in popen error paths in tools.h
The error return paths in tool_function_bash were returning string literals instead of heap-allocated copies via strdup, causing potential null pointer dereference when callers attempt to free the returned pointer. This fix ensures both "Popen failed!" and "Failed to allocate memory!" error messages are properly duplicated on the heap before being returned.
2025-03-03 08:52:28 +00:00
00c45e0978 fix: return error strings instead of NULL on popen and realloc failures in tool_function_bash 2025-03-03 08:48:50 +00:00
f8667d1a4b feat: add bash command execution tool with popen-based output capture
Implement a new `tool_function_bash` that executes shell commands via `popen` and captures their output into a dynamically allocated buffer. Register the corresponding `tool_description_bash` JSON schema and include it in the `tools_descriptions` array alongside the existing HTTP GET tool. Also change the history file path from `~/.calpaca_history` to `.r_history` and remove the redundant `read_history` call before adding new history entries.
2025-03-03 08:39:19 +00:00
38b233bfcf chore: remove trailing blank lines and debug printfs from openai.h and tools.h 2025-03-03 07:32:41 +00:00
e4f71ccea8 feat: add tool calling support with http_fetch function and message handling
Implement tool calling infrastructure including tools.h with http_fetch function description and execution, message_add_tool_call and message_add_tool_result helpers in messages.h, tool descriptions injection into user messages and chat_json, http header parsing utilities in http.h, curl_get function in http_curl.h, and tool call execution loop in openai_chat that recursively processes tool results.
2025-03-03 07:07:17 +00:00
c054c5a019 chore: remove python3.14 linking and plugin include from build and main 2025-02-13 18:09:29 +00:00
5b660fe905 refactor: extract user authentication logic into dedicated service class with dependency injection 2025-01-27 18:06:59 +00:00
7a8f949646 feat: replace custom SSL HTTP implementation with libcurl and add include guards
Add `http_curl.h` providing `curl_post` function using libcurl, update `openai.h` to call `curl_post` instead of `https_post` in both `openai_system` and `openai_chat`, add missing `#ifndef`/`#endif` include guard to `auth.h`, increase HTTP buffer size from 4096 to 1MB, add explicit `(char *)` casts to `malloc`/`realloc` calls in `http.h`, and link `-lcurl` in both `build` and `build_free` Makefile targets.
2025-01-27 17:57:21 +00:00
b95d7d8e56 fix: add missing newlines at EOF, fix memory leaks, increase buffer sizes, and improve plugin imports 2025-01-26 01:54:45 +00:00
45246a1bd0 feat: add --stdin flag to read prompt from piped input and increase code highlight buffer to 4096 2025-01-25 13:19:01 +00:00
484b7c5c5b feat: add inplace_url.h and url.h for URL extraction and markdown-style inline replacement 2025-01-05 23:26:34 +00:00
7160567726 feat: add free version build target with hardcoded api key and gpt-3.5-turbo model 2025-01-05 21:59:51 +00:00
3892e7ec87 docs: swap free and commercial download sections and add python3.14-dev note to README 2025-01-05 22:11:19 +00:00