Prompt Workbench Core 1.0.0
A C library for prompt testing and evaluation with OpenAI-compatible APIs (Educational Use Only)
|
Go to the source code of this file.
Functions | |
int | db_init (const char *db_path) |
Initialize the database. | |
void | db_close (void) |
Close the database connection and release any resources. | |
int | db_create_test_suite (const char *title, const char *description, const char *system_prompt, const char *model) |
Create a new test suite. | |
TestSuite * | db_get_test_suite (int id) |
Retrieve a test suite by ID. | |
TestSuite ** | db_get_all_test_suites (int *count) |
Retrieve all test suites. | |
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. | |
int | db_delete_test_suite (int id) |
Delete a test suite (cascading deletes associated user prompts). | |
void | db_free_test_suite (TestSuite *suite) |
Free a TestSuite structure. | |
void | db_free_test_suites (TestSuite **suites, int count) |
Free an array of TestSuite structures. | |
int | db_create_user_prompt (const char *prompt, int test_suite_id) |
Create a new user prompt associated with a test suite. | |
UserPrompt * | db_get_user_prompt (int id) |
Retrieve a user prompt by ID. | |
UserPrompt ** | db_get_user_prompts_by_suite (int test_suite_id, int *count) |
Retrieve all user prompts for a specific test suite. | |
UserPrompt ** | db_get_all_user_prompts (int *count) |
Retrieve all user prompts. | |
int | db_update_user_prompt (int id, const char *prompt, int test_suite_id) |
Update an existing user prompt. | |
int | db_delete_user_prompt (int id) |
Delete a user prompt. | |
void | db_free_user_prompt (UserPrompt *prompt) |
Free a UserPrompt structure. | |
void | db_free_user_prompts (UserPrompt **prompts, int count) |
Free an array of UserPrompt structures. | |
Variables | |
static sqlite3 * | db = NULL |
static const char * | CREATE_TABLES_SQL |
void db_close | ( | void | ) |
int db_create_test_suite | ( | const char * | title, |
const char * | description, | ||
const char * | system_prompt, | ||
const char * | model | ||
) |
int db_create_user_prompt | ( | const char * | prompt, |
int | test_suite_id | ||
) |
int db_delete_test_suite | ( | int | id | ) |
int db_delete_user_prompt | ( | int | id | ) |
void db_free_test_suite | ( | TestSuite * | suite | ) |
Free a TestSuite structure.
suite | Pointer to the test suite to free |
Definition at line 304 of file db.c.
References TestSuite::description, TestSuite::model, TestSuite::system_prompt, and TestSuite::title.
Referenced by db_free_test_suites().
void db_free_test_suites | ( | TestSuite ** | suites, |
int | count | ||
) |
Free an array of TestSuite structures.
suites | Array of TestSuite pointers |
count | Number of elements in the array |
Definition at line 314 of file db.c.
References db_free_test_suite().
Referenced by db_get_all_test_suites().
void db_free_user_prompt | ( | UserPrompt * | prompt | ) |
Free a UserPrompt structure.
prompt | Pointer to the user prompt to free |
Definition at line 580 of file db.c.
References UserPrompt::prompt.
Referenced by db_free_user_prompts().
void db_free_user_prompts | ( | UserPrompt ** | prompts, |
int | count | ||
) |
Free an array of UserPrompt structures.
prompts | Array of UserPrompt pointers |
count | Number of elements in the array |
Definition at line 587 of file db.c.
References db_free_user_prompt().
Referenced by db_get_all_user_prompts(), and db_get_user_prompts_by_suite().
TestSuite ** db_get_all_test_suites | ( | int * | count | ) |
Retrieve all test suites.
count | Output parameter receiving the number of test suites returned |
Definition at line 156 of file db.c.
References db, db_free_test_suites(), TestSuite::description, TestSuite::id, TestSuite::model, TestSuite::system_prompt, and TestSuite::title.
UserPrompt ** db_get_all_user_prompts | ( | int * | count | ) |
Retrieve all user prompts.
count | Output parameter receiving the number of user prompts returned |
Definition at line 451 of file db.c.
References db, db_free_user_prompts(), UserPrompt::id, UserPrompt::prompt, and UserPrompt::test_suite_id.
TestSuite * db_get_test_suite | ( | int | id | ) |
Retrieve a test suite by ID.
id | The test suite ID |
Definition at line 117 of file db.c.
References db, TestSuite::description, TestSuite::id, TestSuite::model, TestSuite::system_prompt, and TestSuite::title.
UserPrompt * db_get_user_prompt | ( | int | id | ) |
Retrieve a user prompt by ID.
id | The user prompt ID |
Definition at line 353 of file db.c.
References db, UserPrompt::id, UserPrompt::prompt, and UserPrompt::test_suite_id.
UserPrompt ** db_get_user_prompts_by_suite | ( | int | test_suite_id, |
int * | count | ||
) |
Retrieve all user prompts for a specific test suite.
test_suite_id | The test suite ID |
count | Output parameter receiving the number of user prompts returned |
Definition at line 389 of file db.c.
References db, db_free_user_prompts(), UserPrompt::id, UserPrompt::prompt, and UserPrompt::test_suite_id.
int db_init | ( | const char * | db_path | ) |
Initialize the database.
Creates the database file if it does not exist and sets up required tables.
db_path | Path to the database file |
Definition at line 35 of file db.c.
References CREATE_TABLES_SQL, and db.
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.
id | The test suite ID |
title | New title (NULL to leave unchanged) |
description | New description (NULL to leave unchanged) |
system_prompt | New system prompt (NULL to leave unchanged) |
model | New model (NULL to leave unchanged) |
Definition at line 218 of file db.c.
References db.
int db_update_user_prompt | ( | int | id, |
const char * | prompt, | ||
int | test_suite_id | ||
) |
|
static |
Definition at line 20 of file db.c.
Referenced by db_init().
|
static |
Definition at line 18 of file db.c.
Referenced by db_close(), db_create_test_suite(), db_create_user_prompt(), db_delete_test_suite(), db_delete_user_prompt(), db_get_all_test_suites(), db_get_all_user_prompts(), db_get_test_suite(), db_get_user_prompt(), db_get_user_prompts_by_suite(), db_init(), db_update_test_suite(), and db_update_user_prompt().