Prompt Workbench Core 1.0.0
A C library for prompt testing and evaluation with OpenAI-compatible APIs (Educational Use Only)
Loading...
Searching...
No Matches
Prompt Workbench Core

⚠️ 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.

  1. Download the latest release archive (.tar.gz or .zip)
  2. Extract the archive
  3. Copy libprompt_workbench_core.a to your lib directory
  4. Copy header files from include/ to your include directory
  5. Link in your project: -lprompt_workbench_core -lcurl -lsqlite3 -lpthread -ldl -lm

Creating a Release

Releases are created automatically via GitHub Actions:

  1. Go to Actions tab in your repository
  2. Select Build and Release workflow
  3. Click Run workflow
  4. 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)
  5. 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:

doxygen Doxyfile

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

#include "api-client.h"
// Ask a question via OpenAI-compatible API
char* response = api_ask(
"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);
api_ask_free(response);
}
char * api_ask(const char *api_endpoint, const char *api_key, const char *model, const char *system_prompt, const char *user_prompt)
Definition api-client.c:41
void api_ask_free(char *response)
Free a response string returned by API functions.
Definition api-client.c:167

Database

#include "db.h"
// Initialize database
db_init("test.db");
// Create a test suite
int suite_id = db_create_test_suite(
"My Test Suite",
"Testing GPT-4 responses",
"You are a helpful assistant",
"gpt-4"
);
// Add user prompts
db_create_user_prompt("What is AI?", suite_id);
db_create_user_prompt("Explain machine learning", suite_id);
// Read test suite
TestSuite* suite = db_get_test_suite(suite_id);
if (suite) {
printf("Suite: %s\n", suite->title);
}
// Get all prompts for a suite
int count;
UserPrompt** prompts = db_get_user_prompts_by_suite(suite_id, &count);
if (prompts) {
for (int i = 0; i < count; i++) {
printf("Prompt: %s\n", prompts[i]->prompt);
}
db_free_user_prompts(prompts, count);
}
// Update and delete
db_update_test_suite(suite_id, "Updated Title", NULL, NULL, "gpt-4-turbo");
int db_delete_test_suite(int id)
Delete a test suite (cascading deletes associated user prompts).
Definition db.c:277
UserPrompt ** db_get_user_prompts_by_suite(int test_suite_id, int *count)
Retrieve all user prompts for a specific test suite.
Definition db.c:389
void db_close(void)
Close the database connection and release any resources.
Definition db.c:76
TestSuite * db_get_test_suite(int id)
Retrieve a test suite by ID.
Definition db.c:117
void db_free_test_suite(TestSuite *suite)
Free a TestSuite structure.
Definition db.c:304
int db_create_user_prompt(const char *prompt, int test_suite_id)
Create a new user prompt associated with a test suite.
Definition db.c:325
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.
Definition db.c:218
void db_free_user_prompts(UserPrompt **prompts, int count)
Free an array of UserPrompt structures.
Definition db.c:587
int db_init(const char *db_path)
Initialize the database.
Definition db.c:35
int db_create_test_suite(const char *title, const char *description, const char *system_prompt, const char *model)
Create a new test suite.
Definition db.c:85
Represents a test suite in the database.
Definition db.h:34
char * title
Definition db.h:36
Represents a user prompt associated with a test suite.
Definition db.h:51

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")]
public static extern void api_ask_free(IntPtr response);

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.