ACMX 2.139.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
mx2-ollama.hpp
Go to the documentation of this file.
1#ifndef __MX2_OLLAMA_HPP__
2#define __MX2_OLLAMA_HPP__
3
4#include <algorithm>
5#include <cctype>
6#include <curl/curl.h>
7#include <fstream>
8#include <iostream>
9#include <regex>
10#include <sstream>
11#include <string>
12
13namespace mx {
14
15 struct ResponseData {
16 std::string response;
17 std::ostringstream shader_stream;
18 };
19
20 class ObjectRequestException : public std::exception {
21 public:
22 explicit ObjectRequestException(const std::string &message) : msg(message) {}
23 virtual const char *what() const noexcept override { return msg.c_str(); }
24
25 private:
26 std::string msg;
27 };
28
30 public:
31 explicit ObjectRequest(const std::string &host = "localhost", const std::string &model = "codellama:7b", const std::string &filename = "shader.glsl") : host(host), model(model), filename(filename) {}
32 void setHost(const std::string &host) { this->host = host; }
33 void setModel(const std::string &model) { this->model = model; }
34 void setFilename(const std::string &filename) { this->filename = filename; }
35 void setShader(const std::string &shader) { this->shader = shader; }
36
37 void setPrompt(const std::string &prompt) { this->prompt = prompt; }
38
39 static std::string unescape(const std::string &input);
40 std::string generateCode();
41 static size_t WriteCallback(void *contents, size_t size, size_t nmemb, ResponseData *data);
42
43 private:
44 std::string host;
45 std::string model;
46 std::string filename;
47 std::string shader;
48 std::string prompt;
49 };
50
51} // namespace mx
52
53#endif
ObjectRequestException(const std::string &message)
virtual const char * what() const noexcept override
void setShader(const std::string &shader)
void setFilename(const std::string &filename)
std::string prompt
std::string filename
std::string shader
std::string generateCode()
std::string model
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, ResponseData *data)
ObjectRequest(const std::string &host="localhost", const std::string &model="codellama:7b", const std::string &filename="shader.glsl")
void setModel(const std::string &model)
void setHost(const std::string &host)
static std::string unescape(const std::string &input)
Definition mx2-ollama.cpp:5
void setPrompt(const std::string &prompt)
std::string host
std::ostringstream shader_stream
std::string response