Skip to content

Commit 53f9250

Browse files
authored
sync : vendor (#13901)
* sync : vendor ggml-ci * cont : fix httplib version ggml-ci * cont : fix lint * cont : fix lint * vendor : move to common folder /vendor ggml-ci * cont : fix lint * cont : move httplib to /vendor + use json_fwd.hpp ggml-ci * cont : fix server build ggml-ci * cont : add missing headers ggml-ci * cont : header clean-up ggml-ci
1 parent db38704 commit 53f9250

27 files changed

+3313
-2325
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ charset = unset
4949
trim_trailing_whitespace = unset
5050
insert_final_newline = unset
5151

52-
[tools/mtmd/vendor/miniaudio.h]
52+
[vendor/miniaudio/miniaudio.h]
5353
trim_trailing_whitespace = unset
5454
insert_final_newline = unset

common/CMakeLists.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,20 @@ add_library(${TARGET} STATIC
5858
arg.cpp
5959
arg.h
6060
base64.hpp
61-
chat.cpp
62-
chat.h
6361
chat-parser.cpp
6462
chat-parser.h
63+
chat.cpp
64+
chat.h
6565
common.cpp
6666
common.h
6767
console.cpp
6868
console.h
69-
json-schema-to-grammar.cpp
70-
json.hpp
71-
json-partial.h
7269
json-partial.cpp
70+
json-partial.h
71+
json-schema-to-grammar.cpp
7372
llguidance.cpp
7473
log.cpp
7574
log.h
76-
minja/chat-template.hpp
77-
minja/minja.hpp
7875
ngram-cache.cpp
7976
ngram-cache.h
8077
regex-partial.cpp
@@ -147,7 +144,7 @@ if (LLAMA_LLGUIDANCE)
147144
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} llguidance ${LLGUIDANCE_PLATFORM_LIBS})
148145
endif ()
149146

150-
target_include_directories(${TARGET} PUBLIC .)
147+
target_include_directories(${TARGET} PUBLIC . ../vendor)
151148
target_compile_features (${TARGET} PUBLIC cxx_std_17)
152149
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
153150

common/arg.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#include "gguf.h" // for reading GGUF splits
21
#include "arg.h"
32

3+
#include "chat.h"
44
#include "common.h"
5+
#include "gguf.h" // for reading GGUF splits
6+
#include "json-schema-to-grammar.h"
57
#include "log.h"
68
#include "sampling.h"
7-
#include "chat.h"
89

910
// fix problem with std::min and std::max
1011
#if defined(_WIN32)
@@ -15,6 +16,9 @@
1516
#include <windows.h>
1617
#endif
1718

19+
#define JSON_ASSERT GGML_ASSERT
20+
#include <nlohmann/json.hpp>
21+
1822
#include <algorithm>
1923
#include <climits>
2024
#include <cstdarg>
@@ -34,8 +38,6 @@
3438
#include <future>
3539
#endif
3640

37-
#include "json-schema-to-grammar.h"
38-
3941
using json = nlohmann::ordered_json;
4042

4143
std::initializer_list<enum llama_example> mmproj_examples = {

common/chat-parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
#include "chat.h"
44
#include "json-partial.h"
5-
#include "json.hpp"
65
#include "regex-partial.h"
76

7+
#include <nlohmann/json.hpp>
8+
89
#include <optional>
910
#include <string>
1011
#include <vector>

common/chat.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#include "chat.h"
22
#include "chat-parser.h"
33
#include "common.h"
4+
#include "json-partial.h"
45
#include "json-schema-to-grammar.h"
56
#include "log.h"
6-
#include "json-partial.h"
7-
#include "minja/chat-template.hpp"
8-
#include "minja/minja.hpp"
97
#include "regex-partial.h"
108

9+
#include <minja/chat-template.hpp>
10+
#include <minja/minja.hpp>
11+
1112
#include <cstdio>
1213
#include <exception>
1314
#include <iostream>
@@ -16,7 +17,6 @@
1617
#include <string>
1718
#include <vector>
1819

19-
2020
static std::string format_time(const std::chrono::system_clock::time_point & now, const std::string & format) {
2121
auto time = std::chrono::system_clock::to_time_t(now);
2222
auto local_time = *std::localtime(&time);

common/json-partial.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
#include <json-partial.h>
2-
#include "ggml.h"
1+
#include "json-partial.h"
2+
33
#include "log.h"
4-
#include <string>
54

6-
#include <json.hpp>
5+
#include <nlohmann/json.hpp>
6+
7+
#include <string>
78

89
using json = nlohmann::ordered_json;
910

common/json-partial.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
2-
#include <json.hpp>
2+
3+
#include <nlohmann/json.hpp>
34

45
// Healing marker (empty if the JSON was fully parsed / wasn't healed).
56
struct common_healing_marker {

common/json-schema-to-grammar.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "json-schema-to-grammar.h"
22
#include "common.h"
33

4+
#include <nlohmann/json.hpp>
5+
46
#include <algorithm>
5-
#include <fstream>
67
#include <map>
78
#include <regex>
89
#include <sstream>

common/json-schema-to-grammar.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#pragma once
22

3-
#include "ggml.h"
4-
// Change JSON_ASSERT from assert() to GGML_ASSERT:
5-
#define JSON_ASSERT GGML_ASSERT
6-
#include "json.hpp"
3+
#include <nlohmann/json_fwd.hpp>
4+
5+
#include <functional>
6+
#include <string>
77

88
std::string json_schema_to_grammar(const nlohmann::ordered_json & schema,
99
bool force_gbnf = false);

scripts/sync_vendor.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
import urllib.request
4+
5+
vendor = {
6+
"https://github.com/nlohmann/json/releases/latest/download/json.hpp": "vendor/nlohmann/json.hpp",
7+
"https://github.com/nlohmann/json/releases/latest/download/json_fwd.hpp": "vendor/nlohmann/json_fwd.hpp",
8+
9+
# sync manually
10+
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/minja.hpp": "vendor/minja/minja.hpp",
11+
# "https://raw.githubusercontent.com/ochafik/minja/refs/heads/main/include/minja/chat-template.hpp": "vendor/minja/chat-template.hpp",
12+
13+
"https://raw.githubusercontent.com/nothings/stb/refs/heads/master/stb_image.h": "vendor/stb/stb_image.h",
14+
15+
"https://github.com/mackron/miniaudio/raw/refs/tags/0.11.22/miniaudio.h": "vendor/miniaudio/miniaudio.h",
16+
17+
"https://raw.githubusercontent.com/yhirose/cpp-httplib/refs/tags/v0.20.1/httplib.h": "vendor/cpp-httplib/httplib.h",
18+
}
19+
20+
for url, filename in vendor.items():
21+
print(f"downloading {url} to {filename}") # noqa: NP100
22+
urllib.request.urlretrieve(url, filename)

0 commit comments

Comments
 (0)