MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / read_file

Function read_file

smallthinker/tests/test-chat.cpp:89–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static std::string read_file(const std::string & path) {
90 std::cerr << "# Reading: " << path << '\n' << std::flush;
91 std::ifstream fs(path, std::ios_base::binary);
92 if (!fs.is_open()) {
93 fs = std::ifstream("../" + path, std::ios_base::binary);
94 if (!fs.is_open()) {
95 throw std::runtime_error("Failed to open file: " + path);
96 }
97 }
98 fs.seekg(0, std::ios_base::end);
99 auto size = fs.tellg();
100 fs.seekg(0);
101 std::string out;
102 out.resize(static_cast<size_t>(size));
103 fs.read(out.data(), static_cast<std::streamsize>(size));
104 return out;
105}
106
107static common_chat_templates_ptr read_templates(const std::string & path) {
108 return common_chat_templates_ptr(common_chat_templates_init(/* model= */ nullptr, read_file(path)));

Callers 1

read_templatesFunction · 0.70

Calls 4

is_openMethod · 0.80
resizeMethod · 0.45
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected