Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ jobs:
GENERATE_XML = YES
WARN_IF_UNDOCUMENTED = NO
QUIET = YES
HAVE_DOT = YES
DOT_IMAGE_FORMAT = svg
INTERACTIVE_SVG = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
UML_LOOK = YES

EOF

doxygen build/Doxyfile
sphinx-build -b html docs build/site
# Copy Doxygen HTML with diagrams into the Sphinx site
cp -r build/doxygen/html/* build/site/api/ || true

deactivate

- name: Upload downloadable site artifact
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)

project(cpp-workspace VERSION 0.1.1 LANGUAGES CXX)
project(cpp-workspace VERSION 0.2.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -15,14 +15,18 @@ add_executable(cpp-workspace-app
src/main.cpp
src/ollama_client.cpp
src/progress_spinner.cpp
src/user-interface.cpp
src/text-utils.cpp
)

find_package(fmt REQUIRED)
find_package(CURL REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(Curses REQUIRED)
target_link_libraries(cpp-workspace-app
PRIVATE
fmt::fmt
CURL::libcurl
nlohmann_json::nlohmann_json
Curses::Curses
)
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def requirements(self):
self.requires("fmt/11.2.0")
self.requires("libcurl/8.5.0")
self.requires("nlohmann_json/3.11.2")
self.requires("ncurses/6.5")

def layout(self):
cmake_layout(self)
56 changes: 26 additions & 30 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
#include "ollama_client.hpp"
#include "user-interface.hpp"
#include <iostream>

bool next_prompt(std::string* prompt) {
bool done = false;
printf("⏳ Type your prompt (q/Q to quit): ");
if (!std::getline(std::cin, *prompt, '\n')) {
fprintf(stderr, "Error reading user input.\n");
exit(1);
}

if (*prompt == "q" || *prompt == "Q") {
done = true;
}

return done;
}
#include <unistd.h>

int main(int argc, const char* argv[]) {
std::string model = "gemma3n:latest";
Expand All @@ -38,25 +25,32 @@ int main(int argc, const char* argv[]) {
}
}

printf("\n");
printf("🛈 model = %s\n", model.c_str());
printf("🛈 prompt = %s\n", prompt.c_str());
printf("🛈 stream = %s\n", stream ? "true" : "false");
printf("🛈 interactive = %s\n", interactive ? "true" : "false");
printf("\n");

UserInterface ui = UserInterface();
if (interactive == true) {
printf("\nInteractive mode debug info.\n");
printf("---\n");
printf("isatty(0)=%d, isatty(1)=%d, isatty(2)=%d\n", isatty(0), isatty(1), isatty(2));
printf("TERM=%s\n", getenv("TERM"));
printf("TERMINFO=%s\n", getenv("TERMINFO") ? getenv("TERMINFO") : "(not set)");
printf("LC_ALL=%s\n", getenv("LC_ALL") ? getenv("LC_ALL") : "(not set)");
printf("LANG=%s\n", getenv("LANG") ? getenv("LANG") : "(not set)");
printf("---\n");

ui.run();
ui.print_args(model, prompt, stream, interactive);

while (prompt.length() == 0) {
done = next_prompt(&prompt);
done = ui.next_prompt(&prompt);

if (done == true) {
printf("\n🏁 The session has ended.\n");
exit(0);
ui.end_session(EXIT_SUCCESS);
}
}
} else {
UserInterface::print_args_noninteractive(model, prompt, stream, interactive);

if (prompt.length() == 0) {
done = next_prompt(&prompt);
done = UserInterface::next_prompt_noninteractive(&prompt);

if (prompt.length() == 0) {
printf("\n🏁 Empty prompt. The session has ended.\n");
Expand All @@ -70,7 +64,7 @@ int main(int argc, const char* argv[]) {
}
}

OllamaClient client = OllamaClient();
OllamaClient client = OllamaClient(&ui);

client.query_model_list();

Expand All @@ -83,17 +77,19 @@ int main(int argc, const char* argv[]) {

if (interactive == true) {
while (done == false) {
done = next_prompt(&prompt);
done = ui.next_prompt(&prompt);
if (done == true) {
continue;
}

config.prompt = prompt;
client.query_model(config);
ui.request_redraw();
}
ui.end_session(EXIT_SUCCESS);
} else {
printf("\n🏁 The session has ended.\n");
}

printf("\n🏁 The session has ended.\n");

return 0;
}
Loading
Loading