⚠️ EDUCATIONAL USE ONLY - This software is licensed for educational and learning purposes only. Not for production, commercial, or application deployment. See [LICENSE](LICENSE) for details.
A cross-platform C static library for prompt testing and evaluation with OpenAI-compatible APIs.
Features
- Static library suitable for C#, Swift, and GCC
- OpenAI-compatible API client
- SQLite database for test suite management
- Includes libcurl, cJSON, and SQLite compiled statically
- Comprehensive unit tests
- Optional test executables for development
Building
Prerequisites
- CMake 3.15 or higher
- C compiler (GCC, Clang, or MSVC)
- Git (for submodules)
Setup
Initialize git submodules:
git submodule update --init --recursive
Note: SQLite is downloaded as an amalgamation file, not a git submodule.
Build Library Only
mkdir build
cd build
cmake .. -DBUILD_TESTS=OFF
cmake --build .
Build Library with Test Executables
mkdir build
cd build
cmake .. -DBUILD_TESTS=ON
cmake --build .
Using Pre-built Releases
You can download pre-built releases from the Releases page.
- Download the latest release archive (
.tar.gz
or .zip
)
- Extract the archive
- Copy
libprompt_workbench_core.a
to your lib directory
- Copy header files from
include/
to your include directory
- Link in your project:
-lprompt_workbench_core -lcurl -lsqlite3 -lpthread -ldl -lm
Creating a Release
Releases are created automatically via GitHub Actions:
- Go to Actions tab in your repository
- Select Build and Release workflow
- Click Run workflow
- Select version bump type:
patch
- for bug fixes (1.0.0 → 1.0.1)
minor
- for new features (1.0.0 → 1.1.0)
major
- for breaking changes (1.0.0 → 2.0.0)
- Click Run workflow
The workflow will:
- Build and test the library
- Calculate the new version based on the latest tag
- Create and push a new git tag
- Package the library, headers, and documentation
- Create a GitHub release with downloadable archives
LSP/IDE Support
For LSP support (clangd, etc.) in editors like Neovim, generate the compilation database:
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_TESTS=ON
ln -sf build/compile_commands.json compile_commands.json
This creates a compile_commands.json
file that LSPs use to understand your project's include paths and build configuration.
Testing
Run Unit Tests
./build/bin/prompt-workbench-core_unit_tests
This runs all unit tests for the database and API client modules.
Run Integration Test
./build/bin/prompt-workbench-core_test
Set environment variables to test with a real API:
export OPENAI_API_ENDPOINT="https://api.openai.com/v1/chat/completions"
export OPENAI_API_KEY="your-api-key"
./build/bin/prompt-workbench-core_test
Documentation
Full API documentation is generated using Doxygen and deployed to GitHub Pages.
View Online Documentation
Visit the online documentation (replace with your actual GitHub Pages URL).
Generate Documentation Locally
Install Doxygen and Graphviz:
# Ubuntu/Debian
sudo apt-get install doxygen graphviz
# macOS
brew install doxygen graphviz
Generate the documentation:
Open the generated documentation:
open docs/html/index.html # macOS
xdg-open docs/html/index.html # Linux
Output Files
- Static library:
build/lib/libprompt_workbench_core.a
(Unix) or build/lib/prompt_workbench_core.lib
(Windows)
- Test executable:
build/bin/prompt-workbench-core_test
- Unit tests:
build/bin/prompt-workbench-core_unit_tests
API Reference
API Client
"https://api.openai.com/v1/chat/completions",
"your-api-key",
"gpt-4",
"You are a helpful assistant",
"Hello, how are you?"
);
if (response) {
printf("Response: %s\n", response);
}
char * api_ask(const char *api_endpoint, const char *api_key, const char *model, const char *system_prompt, const char *user_prompt)
void api_ask_free(char *response)
Free a response string returned by API functions.
Database
"My Test Suite",
"Testing GPT-4 responses",
"You are a helpful assistant",
"gpt-4"
);
if (suite) {
printf(
"Suite: %s\n", suite->
title);
}
int count;
if (prompts) {
for (int i = 0; i < count; i++) {
printf("Prompt: %s\n", prompts[i]->prompt);
}
}
int db_delete_test_suite(int id)
Delete a test suite (cascading deletes associated user prompts).
UserPrompt ** db_get_user_prompts_by_suite(int test_suite_id, int *count)
Retrieve all user prompts for a specific test suite.
void db_close(void)
Close the database connection and release any resources.
TestSuite * db_get_test_suite(int id)
Retrieve a test suite by ID.
void db_free_test_suite(TestSuite *suite)
Free a TestSuite structure.
int db_create_user_prompt(const char *prompt, int test_suite_id)
Create a new user prompt associated with a test suite.
int db_update_test_suite(int id, const char *title, const char *description, const char *system_prompt, const char *model)
Update an existing test suite.
void db_free_user_prompts(UserPrompt **prompts, int count)
Free an array of UserPrompt structures.
int db_init(const char *db_path)
Initialize the database.
int db_create_test_suite(const char *title, const char *description, const char *system_prompt, const char *model)
Create a new test suite.
Represents a test suite in the database.
Represents a user prompt associated with a test suite.
Usage in Other Languages
In C
Link the static library and use P/Invoke:
[DllImport("prompt_workbench_core")]
public static extern IntPtr
api_ask(
string endpoint,
string key,
string model,
string system_prompt, string user_prompt);
[DllImport("prompt_workbench_core")]
In Swift
Use the library with a bridging header or module map.
Dependencies
All dependencies are compiled statically into the final library.
License
This project is licensed under a custom Educational and Non-Commercial Use License.
You may:
- Study the code for learning programming
- Run the software locally for educational purposes
- Analyze and learn from the implementation
You may NOT:
- Use this software in production environments
- Deploy applications using this code
- Integrate this code into other applications
- Use this for commercial purposes
- Distribute this software or derivatives
See the [LICENSE](LICENSE) file for complete terms and conditions.
Note: This is strictly for educational and learning purposes. If you need to use this code in production or commercial projects, please contact the copyright holder for alternative licensing arrangements.