This commit is contained in:
KoDer 2026-10-02 19:30:49 +07:00
parent ecef2f41af
commit 87b45a1484
31 changed files with 65 additions and 87 deletions

View File

@ -28,12 +28,13 @@ set(SOURCES
xenith/converter.cpp
help.h
xenith/ollama_api/handler.cpp
xenith/ollama_api/handler.h
xenith/ollama_api/server.h
xenith/ollama_api/handler.hpp
xenith/ollama_api/server.hpp
xenith/ollama_api/server.cpp
xenith/ui/tui/tui.cpp
xenith/ui/tui.h
xenith/ui/tui.hpp
xenith/ui/tui/mouse.cpp
xenith/ui/tui/message.cpp
)
# Заголовочные файлы (для удобства в IDE)

View File

@ -15,7 +15,7 @@
| файл | что делает |
|---|---|
| `xenith/core/tensor.h` | матрицы, три формы GEMM, RMSNorm, RNG, пул потоков |
| `xenith/core/tensor.hpp` | матрицы, три формы GEMM, RMSNorm, RNG, пул потоков |
| `xenith/core/model.cpp` | конфигурация, инициализация, прямой проход, RoPE, Adam |
| `xenith/core/backward.cpp` | обратный проход (ручной, без автомиффов) |
| `xenith/core/trainer.cpp` | цикл обучения, расписание lr, чекпоинты, валидация |

View File

@ -1,8 +1,8 @@
#include "xenith/core/checkpoint.h"
#include "xenith/core/generate.h"
#include "xenith/core/train.h"
#include "xenith/core/checkpoint.hpp"
#include "xenith/core/generate.hpp"
#include "xenith/core/train.hpp"
#include "xenith/core/gradcheck.h"
#include "xenith/ui/tui.h"
#include "xenith/ui/tui.hpp"
#include <cstdio>
#include "help.h"
#include <cstdlib>
@ -358,10 +358,9 @@ static int cmd_update(const Args& a) {
static int cmd_tui(const Args& a)
{
ui::Tui tui = ui::Tui();
while (tui.is_running())
while (ui::app.is_running())
{
tui.update();
ui::app.update();
}
std::cout << "\033[2J\033[H" << std::flush;
return 0;

View File

@ -1,15 +0,0 @@
#ifndef XENITH_SETTINGS_H
#define XENITH_SETTINGS_H
#pragma once
#include "xenith/preprocessing/tokenizer.h"
struct llm_prm
{
bool use_mmap = true;
bool use_mlock = false;
int num_thread = 1;
unsigned int num_gpu = 256;
};
#endif

View File

@ -1,4 +1,4 @@
#include "converter.h"
#include "converter.hpp"
#include <cstring>
#include <iostream>

View File

@ -1,4 +1,4 @@
#include "train.h"
#include "train.hpp"
#include <cmath>
#include <algorithm>

View File

@ -1,4 +1,4 @@
#include "checkpoint.h"
#include "checkpoint.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>

View File

@ -1,5 +1,5 @@
#pragma once
#include "model.h"
#include "model.hpp"
#include <string>
#include <unordered_map>
#include <vector>

View File

@ -1,4 +1,4 @@
#include "generate.h"
#include "generate.hpp"
#include <cstdio>
#include <cmath>
#include <algorithm>

View File

@ -1,6 +1,6 @@
// generate.h — генерация текста с KV-кэшем
#pragma once
#include "checkpoint.h"
#include "checkpoint.hpp"
#include <string>
#include <vector>

View File

@ -1,8 +1,8 @@
// gradcheck.cpp — проверяем, что обратный проход совпадает с численным
// и заодно меряем скорость.
#include "gradcheck.h"
#include "generate.h"
#include "train.h"
#include "generate.hpp"
#include "train.hpp"
#include <cstdio>
#include <cmath>
#include <chrono>

View File

@ -1,6 +1,6 @@
// gradcheck.h — численная проверка градиентов и бенчмарк
#pragma once
#include "checkpoint.h"
#include "checkpoint.hpp"
namespace xt {
int run_gradcheck(bool verbose);

View File

@ -1,4 +1,4 @@
#include "model.h"
#include "model.hpp"
#include <cstdio>
#include <cmath>
#include <algorithm>

View File

@ -1,5 +1,5 @@
#pragma once
#include "tensor.h"
#include "tensor.hpp"
#include <string>
#include <vector>

View File

@ -1,6 +1,6 @@
#pragma once
#include "model.h"
#include "checkpoint.h"
#include "model.hpp"
#include "checkpoint.hpp"
#include <vector>
namespace xt {

View File

@ -1,5 +1,5 @@
#include "train.h"
#include "checkpoint.h"
#include "train.hpp"
#include "checkpoint.hpp"
#include <cstdio>
#include <cmath>
#include <fstream>

View File

@ -1,2 +1,2 @@
#include "handler.h"
#include "handler.hpp"

View File

@ -1,5 +1,5 @@
#ifndef XENITH_HANDLER_H
#define XENITH_HANDLER_H
#pragma once
#include <cstdint>
#include <string>
#include <vector>
@ -64,6 +64,3 @@ namespace api
models_details details;
};
}
#endif

View File

@ -1,4 +1,4 @@
#include "server.h"
#include "server.hpp"
namespace api
{

View File

@ -1,14 +0,0 @@
#ifndef XENITH_SERVER_H
#define XENITH_SERVER_H
#include "handler.h"
namespace api
{
class server
{
server();
~server();
};
}
#endif //XENITH_SERVER_H

View File

@ -0,0 +1,13 @@
#pragma once
#include "handler.hpp"
namespace api
{
class server
{
server();
~server();
};
}

View File

@ -3,7 +3,7 @@
#include <thread>
#include <vector>
#include <string>
#include "./xenith/libs/cpp-httplib-0.57.1/httplib.h"
#include "./xenith/libs/cpp-httplib-0.57.1/httplib.hpp"
#include "./xenith/libs/json-3.12.0/nlohmann/json.hpp"

View File

@ -1,4 +1,4 @@
#include "tokenizer.h"
#include "tokenizer.hpp"
#include <algorithm>
#include <cmath>

View File

@ -4,7 +4,7 @@
#include <string>
#include <iostream>
#include <unordered_map>
#include "./../converter.h"
#include "./../converter.hpp"
#include "models/test_model.h"
void proccesing_promt(const std::string& text, Model& mdl, uint32_t layer_idx = 0);

View File

@ -1,12 +1,7 @@
#ifndef XENITH_TUI_H
#define XENITH_TUI_H
#pragma once
#include <cstdint>
#include <iostream>
#include <memory>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/select.h>
#include <termios.h>
#include <vector>
#include <string>
@ -52,7 +47,6 @@ namespace ui
inline static bool running = true;
inline static int width = 80;
inline static int height = 24;
struct SplitDesc {
enum Type { VERTICAL, HORIZONTAL };
Type type;
@ -60,22 +54,17 @@ namespace ui
std::vector<std::unique_ptr<SplitDesc>> children;
SplitDesc(Type t, int pos) : type(t), position(pos) {}
};
struct border_charset {
std::string_view top_left, top_right, bottom_left, bottom_right;
std::string_view bottom, top, horizontal, vertical, bg;
std::string_view cross, tee_up, tee_down, tee_left, tee_right;
};
// Ваша структура, которая теперь будет использоваться по назначению
struct TuiCell {
std::string ch; // UTF-8 последовательность (например, "│" или "┌")
int width; // Ширина на экране (обычно 1)
std::string ch;
int width;
TuiCell() : ch(" "), width(1) {}
TuiCell(const std::string& c, int w) : ch(c), width(w) {}
};
inline static struct termios orig_termios;
inline static const border_charset border_clip {
.top_left="╭", .top_right="╮", .bottom_left="╰", .bottom_right="╯",
@ -99,7 +88,6 @@ namespace ui
.top_left="▟", .top_right="▙", .bottom_left="▜", .bottom_right="▛",
.bottom="█", .top="█", .vertical="█", .bg="█"
};
static void get_console_size();
static bool wait_for_input_or_timeout(int timeout_ms);
void apply_color() const;
@ -118,13 +106,11 @@ namespace ui
static void invert_color();
static void draw_button(int x, int y, int w, int h, std::string_view label, border_charset charset = border_solid);
static void invert_color_off();
// --- ОБНОВЛЕННЫЕ СИГНАТУРЫ ---
void draw_split_border(int w, int h, border_charset charset, int x, int y, const SplitDesc* root);
static void apply_splits_recursive(std::vector<std::vector<TuiCell>>& grid, int offset_x, int offset_y, int w, int h, border_charset charset, const SplitDesc* split);
static void apply_single_split(std::vector<std::vector<TuiCell>>& grid, int offset_x, int offset_y, int w, int h, border_charset charset, const SplitDesc* split);
static void draw_border_to_buffer(std::vector<std::vector<TuiCell>>& grid, int w, int h, border_charset charset);
};
}
#endif
Tui app = Tui();
}

View File

@ -0,0 +1,7 @@
#include "message.h"
#include "./../tui.hpp"
namespace ui
{
}

View File

@ -1,4 +1,4 @@
#include "../tui.h"
#include "../tui.hpp"
namespace ui
{

View File

@ -1,8 +1,12 @@
#include "../tui.h"
#include "../tui.hpp"
#include <chrono>
#include <csignal>
#include <cstring>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/select.h>
#include <iostream>
namespace ui