A single-header SDK for building G-Assist plugins in C++.
- C++17 or later
- nlohmann/json library
- Copy
gassist_sdk.hppto your project - Download
nlohmann/json.hppfrom https://github.com/nlohmann/json/releases
#include <nlohmann/json.hpp>
#include "gassist_sdk.hpp"
using json = nlohmann::json;
int main() {
gassist::Plugin plugin("hello-world", "1.0.0", "A simple example plugin");
// Register a command
plugin.command("say_hello", [&](const json& args) -> json {
std::string name = args.value("name", "World");
return "Hello, " + name + "!";
});
// Register command with streaming
plugin.command("count", [&](const json& args) -> json {
int count_to = args.value("count_to", 5);
for (int i = 1; i <= count_to; i++) {
plugin.stream("Counting: " + std::to_string(i) + "\n");
}
return "Done counting!";
});
// Run the plugin
plugin.run();
return 0;
}plugin.command("function_name", [&](const json& args) -> json {
// Access arguments
std::string param = args.value("param", "default");
// Return result (string, number, object, etc.)
return {{"result", "value"}};
});plugin.command("long_operation", [&](const json& args) -> json {
plugin.stream("Starting...\n");
// do work
plugin.stream("50% complete...\n");
// do more work
plugin.stream("Done!\n");
return "";
});plugin.command("start_chat", [&](const json& args) -> json {
plugin.set_keep_session(true);
return "Chat started! Type 'exit' to leave.";
});
plugin.command("on_input", [&](const json& args) -> json {
std::string content = args.value("content", "");
if (content == "exit") {
plugin.set_keep_session(false);
return "Goodbye!";
}
plugin.set_keep_session(true);
return "You said: " + content;
});- Create a new Console Application project
- Add
gassist_sdk.hppandnlohmann/json.hppto your project - Set C++ Language Standard to C++17 or later
- Build as Release x64
cmake_minimum_required(VERSION 3.15)
project(my_plugin)
set(CMAKE_CXX_STANDARD 17)
add_executable(my_plugin plugin.cpp)
target_include_directories(my_plugin PRIVATE ${CMAKE_SOURCE_DIR}/include)cl /EHsc /std:c++17 /O2 plugin.cpp /Fe:g-assist-plugin-myplugin.exeCreate manifest.json alongside your executable:
{
"manifestVersion": 1,
"name": "my-plugin",
"version": "1.0.0",
"description": "My C++ plugin",
"executable": "g-assist-plugin-myplugin.exe",
"persistent": true,
"protocol_version": "2.0",
"functions": [
{
"name": "say_hello",
"description": "Greet the user",
"tags": ["hello", "greet"],
"properties": {
"name": {
"type": "string",
"description": "Name to greet"
}
}
}
]
}Plugin logs are written to:
%PROGRAMDATA%\NVIDIA Corporation\nvtopps\rise\plugins\<plugin-name>\<plugin-name>.log
This SDK implements Protocol V2 (JSON-RPC 2.0) with length-prefixed framing.
See PROTOCOL_V2.md in the Python SDK for full protocol documentation.