information-retrieval

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit e709ee4038cceeb0574cdfc1e8999502ecb5c960
parent 57e642fdae070c5dedd6a3fa4d9e781fe330fbf6
Author: Andrew Laack <andrew.laack@imbue.com>
Date:   Tue, 13 Jan 2026 16:01:19 -0600

Added file summary script

Diffstat:
Mweb-research/CMakeLists.txt | 4++++
Aweb-research/src/summary.cpp | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/web-research/CMakeLists.txt b/web-research/CMakeLists.txt @@ -22,3 +22,7 @@ include_directories(${CURL_INCLUDE_DIRS}) add_executable(main src/main.cpp src/researcher.cpp) target_link_libraries(main PRIVATE ${CURL_LIBRARIES}) target_link_libraries(main PRIVATE cpr::cpr) + +add_executable(summary src/summary.cpp src/researcher.cpp) +target_link_libraries(summary PRIVATE ${CURL_LIBRARIES}) +target_link_libraries(summary PRIVATE cpr::cpr) diff --git a/web-research/src/summary.cpp b/web-research/src/summary.cpp @@ -0,0 +1,59 @@ +#include "../include/openai.hpp" +#include <iostream> +#include "../include/nlohmann/json.hpp" +#include "../include/researcher.hpp" +#include <fstream> + +int main(int argc, char* argv[]) { + + + openai::start(); + openai::OpenAI connection = openai::OpenAI(); + + std::string envVariable = "GROQ_API_KEY"; + std::string model = "moonshotai/kimi-k2-instruct-0905"; + std::string baseURL = "https://api.groq.com/openai/v1/"; + std::string priorRuns = ""; + int linkNum = 1; + + connection.setToken(getenv(envVariable.c_str())); + connection.setBaseUrl(baseURL); + + std::string filepath; + if(argc == 2){ + filepath = argv[1]; + } + else{ + std::cout << "Please specify file to read." << std::endl; + exit(-1); + } + + Researcher summarizer = Researcher(); + summarizer.setSystemPrompt( +R"( +You are a highly capable AI assistant. Your mission is to consider the audio transcript below and summarize it with extreme precision. As much as possible, use direct quotes from the source to ensure your summary is faithful to the original piece. +)"); + + + std::ifstream t = std::ifstream(filepath); + std::string filecontent = ""; + std::string line; + while(t){ + std::getline(t, line); + filecontent += line; + } + + int approxTokens = filecontent.size() / 4; + + if (approxTokens > 128000){ + filecontent = filecontent.substr(0,128000 * 4); + } + + t.close(); + + nlohmann::json summaryJson = summarizer.sendUserMessage(&connection, model, filecontent); + std::string summary = summarizer.getMessageFromChat(summaryJson); + std::cout << summary << std::endl; + return 0; + +}