LlamaLib  v2.0.2
Cross-platform library for local LLMs
Loading...
Searching...
No Matches
LLM.h File Reference

Core LLM functionality interface and base classes. More...

#include "defs.h"
#include "error_handling.h"
#include <sstream>
Include dependency graph for LLM.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LoraIdScale
 Structure representing a LoRA adapter with ID and scale. More...
 
struct  LoraIdScalePath
 Structure representing a LoRA adapter with ID, scale, and file path. More...
 
class  LLM
 Abstract base class for Large Language Model operations. More...
 
class  LLMLocal
 Abstract class for local LLM operations with slot management. More...
 
class  LLMProvider
 Abstract class for LLM service providers. More...
 
class  LLMProviderRegistry
 Registry for managing LLM provider instances. More...
 

Functions

void ensure_error_handlers_initialized ()
 Ensures error handlers are properly initialized.
 
bool Has_GPU_Layers (const char *command)
 Check if command has GPU layers (C API)
 
void LLM_Debug (int debug_level)
 Set global debug level (C API)
 
void LLM_Logging_Callback (CharArrayFn callback)
 Set global logging callback (C API)
 
void LLM_Logging_Stop ()
 Stop global logging (C API)
 
void LLM_Set_Completion_Parameters (LLM *llm, const char *params_json="{}")
 Set completion parameters (C API)
 
const char * LLM_Get_Completion_Parameters (LLM *llm)
 Get completion parameters (C API)
 
void LLM_Set_Grammar (LLM *llm, const char *grammar="")
 Set grammar (C API)
 
const char * LLM_Get_Grammar (LLM *llm)
 Get grammar (C API)
 
const char * LLM_Apply_Template (LLM *llm, const char *messages_as_json)
 Apply chat template (C API)
 
const char * LLM_Tokenize (LLM *llm, const char *query)
 Tokenize text (C API)
 
const char * LLM_Detokenize (LLM *llm, const char *tokens_as_json)
 Detokenize tokens (C API)
 
const char * LLM_Embeddings (LLM *llm, const char *query)
 Generate embeddings (C API)
 
const char * LLM_Completion (LLM *llm, const char *prompt, CharArrayFn callback=nullptr, int id_slot=-1, bool return_response_json=false)
 Generate completion (C API)
 
const char * LLM_Save_Slot (LLMLocal *llm, int id_slot, const char *filepath)
 Save slot state (C API)
 
const char * LLM_Load_Slot (LLMLocal *llm, int id_slot, const char *filepath)
 Load slot state (C API)
 
void LLM_Cancel (LLMLocal *llm, int id_slot)
 Cancel request (C API)
 
bool LLM_Lora_Weight (LLMProvider *llm, const char *loras_as_json)
 Configure LoRA weights (C API)
 
void LLM_Enable_Reasoning (LLMProvider *llm, bool enable_reasoning)
 Enable reasoning (C API)
 
const char * LLM_Lora_List (LLMProvider *llm)
 List LoRA adapters (C API)
 
void LLM_Delete (LLMProvider *llm)
 Delete LLM provider (C API)
 
void LLM_Start (LLMProvider *llm)
 Start LLM service (C API)
 
const bool LLM_Started (LLMProvider *llm)
 Check if service is started (C API)
 
void LLM_Stop (LLMProvider *llm)
 Stop LLM service (C API)
 
void LLM_Start_Server (LLMProvider *llm, const char *host="0.0.0.0", int port=-1, const char *API_key="")
 Start HTTP server (C API)
 
void LLM_Stop_Server (LLMProvider *llm)
 Stop HTTP server (C API)
 
void LLM_Join_Service (LLMProvider *llm)
 Wait for service to complete (C API)
 
void LLM_Join_Server (LLMProvider *llm)
 Wait for server to complete (C API)
 
void LLM_Set_SSL (LLMProvider *llm, const char *SSL_cert, const char *SSL_key)
 Set SSL configuration (C API)
 
const int LLM_Status_Code ()
 Get last operation status code (C API)
 
const char * LLM_Status_Message ()
 Get last operation status message (C API)
 
const int LLM_Embedding_Size (LLMProvider *llm)
 Get embedding vector size (C API)
 

Detailed Description

Core LLM functionality interface and base classes.

This file provides the foundational interface for Large Language Model operations, including completion, tokenization, embeddings, and LoRA (Low-Rank Adaptation) support.

Definition in file LLM.h.

Function Documentation

◆ ensure_error_handlers_initialized()

void ensure_error_handlers_initialized ( )

Ensures error handlers are properly initialized.

This function must be called before using any LLM functionality to set up proper error handling mechanisms

Definition at line 25 of file LLM.cpp.

Here is the caller graph for this function: