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
db.h
Go to the documentation of this file.
1/*
2 * Prompt Workbench Core - Database Layer
3 * Copyright (c) 2025 nnlazaro
4 *
5 * This file is part of Prompt Workbench Core, licensed under the
6 * Educational and Non-Commercial Use License.
7 * See LICENSE file for details.
8 *
9 * FOR EDUCATIONAL USE ONLY - NOT FOR PRODUCTION OR COMMERCIAL USE
10 */
11
12#ifndef DB_H
13#define DB_H
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* ==========================================================================
20 * Database entity structures
21 * ========================================================================== */
22
34typedef struct {
35 int id;
36 char* title;
39 char* model;
40} TestSuite;
41
51typedef struct {
52 int id;
53 char* prompt;
56
57/* ==========================================================================
58 * Database lifecycle functions
59 * ========================================================================== */
60
68int db_init(const char* db_path);
69
73void db_close(void);
74
75/* ==========================================================================
76 * Test Suite CRUD operations
77 * ========================================================================== */
78
88int db_create_test_suite(const char* title, const char* description,
89 const char* system_prompt, const char* model);
90
99
108
119int db_update_test_suite(int id, const char* title, const char* description,
120 const char* system_prompt, const char* model);
121
128int db_delete_test_suite(int id);
129
135void db_free_test_suite(TestSuite* suite);
136
143void db_free_test_suites(TestSuite** suites, int count);
144
145/* ==========================================================================
146 * User Prompt CRUD operations
147 * ========================================================================== */
148
156int db_create_user_prompt(const char* prompt, int test_suite_id);
157
166
175UserPrompt** db_get_user_prompts_by_suite(int test_suite_id, int* count);
176
185
194int db_update_user_prompt(int id, const char* prompt, int test_suite_id);
195
202int db_delete_user_prompt(int id);
203
209void db_free_user_prompt(UserPrompt* prompt);
210
217void db_free_user_prompts(UserPrompt** prompts, int count);
218
219#ifdef __cplusplus
220}
221#endif
222
223#endif /* DB_H */
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
UserPrompt * db_get_user_prompt(int id)
Retrieve a user prompt by ID.
Definition db.c:353
void db_free_user_prompts(UserPrompt **prompts, int count)
Free an array of UserPrompt structures.
Definition db.c:587
UserPrompt ** db_get_all_user_prompts(int *count)
Retrieve all user prompts.
Definition db.c:451
int db_init(const char *db_path)
Initialize the database.
Definition db.c:35
void db_free_user_prompt(UserPrompt *prompt)
Free a UserPrompt structure.
Definition db.c:580
int db_update_user_prompt(int id, const char *prompt, int test_suite_id)
Update an existing user prompt.
Definition db.c:511
TestSuite ** db_get_all_test_suites(int *count)
Retrieve all test suites.
Definition db.c:156
int db_delete_user_prompt(int id)
Delete a user prompt.
Definition db.c:553
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
void db_free_test_suites(TestSuite **suites, int count)
Free an array of TestSuite structures.
Definition db.c:314
Represents a test suite in the database.
Definition db.h:34
char * title
Definition db.h:36
char * description
Definition db.h:37
int id
Definition db.h:35
char * model
Definition db.h:39
char * system_prompt
Definition db.h:38
Represents a user prompt associated with a test suite.
Definition db.h:51
char * prompt
Definition db.h:53
int test_suite_id
Definition db.h:54
int id
Definition db.h:52