Llama.cpp C++-to-Csharp wrapper from testedlines.com: C++ docs 1.0.1
Llama.cpp C++-to-Csharp wrapper is a minor extension to Llama.cpp tag b3490 codebase modified a bit by testedlines allowing it to be compiled for and called from Styled Lines Csharp unity asset store package.
Loading...
Searching...
No Matches
lib.h
Go to the documentation of this file.
1#pragma once
2#include "common.h"
3#include <string>
4
5#define NDEBUG
16{
21 std::string GetGenerated();
22 void Echo(std::string in);
26 void Stop();
27
33 LlamaInfrence(const LoggingContext* logging, const gpt_params& cfg_params);
34
41 static gpt_params* GetParameters(const std::string& llamacpp_cmd_args);
42
43
49 bool Generate(const std::string& prompt);
50
55
59 struct LlamaImpl;
60
64 LlamaImpl* pImpl;
65
66};
67
68
83public:
88
93
94 struct LoggingContextPimpl;
95 LoggingContextPimpl* pImpl;
96};
97
98// Definition of AsyncLlamaInfrence
116
125
131 int SetupAsync(const LoggingContext * logging, const gpt_params& cfg_params);
132
138 bool GetSetupResults(int task_id);
139
145 int GenerateAsync(const std::string& prompt);
146 bool IsGenerationReady(int task_id);
147
153 std::string GetGenerationResults(int task_id);
155
159 struct LlamaAsyncImpl;
160
164 LlamaAsyncImpl* pImpl;
165};
166
184 static bool Save(const std::string& data, const std::string& path);
185
196 static bool Save(unsigned char* data, long data_length, const std::string& path);
197
209 static bool Save(const char* data, std::size_t data_length, const std::string& path);
210};
Manages callback functions for logging, token processing, and completion events.
Definition lib.h:82
LoggingContext()
Constructs a new LoggingContext object.
~LoggingContext()
Destructs the LoggingContext object, cleaning up any allocated resources.
LoggingContextPimpl * pImpl
The PImpl structure containing private implementation details.
Definition lib.h:95
Provides an interface for asynchronous inference operations on a model, such as GPT.
Definition lib.h:107
std::string GetGenerationResults(int task_id)
Retrieves the generated text associated with a task ID.
bool GetSetupResults(int task_id)
Retrieves the result of the setup operation associated with a task ID.
AsyncLlamaInfrence()
Default constructor for the AsyncLlamaInfrence class.
int SetupAsync(const LoggingContext *logging, const gpt_params &cfg_params)
Asynchronously sets up the model with specified configuration LLama.cpp parameters.
int GenerateAsync(const std::string &prompt)
Asynchronously generates output based on the provided prompt.
bool IsGenerationReady(int task_id)
LlamaAsyncImpl * pImpl
Pointer to the implementation class, used by the PImpl idiom.
Definition lib.h:164
~AsyncLlamaInfrence()
Destructor for the AsyncLlamaInfrence class.
Provides static utility functions for saving data to files.
Definition lib.h:174
static bool Save(const std::string &data, const std::string &path)
Saves string data to a file.
static bool Save(unsigned char *data, long data_length, const std::string &path)
Saves binary data to a file.
static bool Save(const char *data, std::size_t data_length, const std::string &path)
Saves data to a file.
Provides an interface for inference operations on a model, such as GPT (yet any LLama....
Definition lib.h:16
bool Generate(const std::string &prompt)
Generates output based on the provided prompt.
~LlamaInfrence()
destructor to allow for proper cleanup in derived classes. Does cleanup.
LlamaInfrence(const LoggingContext *logging, const gpt_params &cfg_params)
Sets up the model with specified configuration LLama.cpp parameters that can include file (to load fr...
void Echo(std::string in)
void Stop()
Stops the current generation operation. To be called from callbacks for text length generation contro...
std::string GetGenerated()
Retrieves the complete generated text after a generation call. On generation call string is emptied.
static gpt_params * GetParameters(const std::string &llamacpp_cmd_args)
Generates model config using a string that contains command-line-like arguments same as in original L...
LlamaImpl * pImpl
Pointer to the implementation class, used by the PImpl idiom.
Definition lib.h:64
Definition common-base.h:38