Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,4 @@ help:
@echo " xcframework - Build the Apple XCFramework"
@echo " aar - Build the Android AAR package"

.PHONY: all clean test extension help version xcframework aar
.PHONY: all clean test extension help version xcframework aar
7 changes: 7 additions & 0 deletions src/sqlite-ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,11 @@ static void llm_text_generate (sqlite3_context *context, int argc, sqlite3_value
// MARK: - Chat -

static bool llm_chat_check_context (ai_context *ai) {
if (!ai || !ai->ctx) {
sqlite_common_set_error(ai ? ai->context : NULL, ai ? ai->vtab : NULL, SQLITE_MISUSE, "No context found. Please call llm_context_create() before llm_chat_create().");
return false;
}

// check sampler
if (!ai->sampler) {
llm_sampler_check(ai);
Expand Down Expand Up @@ -1862,6 +1867,8 @@ static void llm_chat_free (sqlite3_context *context, int argc, sqlite3_value **a
}

static void llm_chat_create (sqlite3_context *context, int argc, sqlite3_value **argv) {
if (llm_check_context(context) == false) return;

ai_context *ai = (ai_context *)sqlite3_user_data(context);

// clean-up old chat (if any)
Expand Down
Loading