Skip to content
Open
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
e011555
workflow fix
CompromisedKiwi Jan 20, 2026
bfb16fa
coarce migration
CompromisedKiwi Jan 21, 2026
54e43c1
underline
CompromisedKiwi Jan 21, 2026
894bb73
c++17
CompromisedKiwi Jan 22, 2026
b0a1ca0
rename
CompromisedKiwi Jan 22, 2026
8e7e017
save
CompromisedKiwi Jan 23, 2026
fa1d7d2
Merge branch 'main' into yzh/migrate_doc_node
CompromisedKiwi Jan 28, 2026
7ea108e
undo workflow fix
CompromisedKiwi Jan 28, 2026
f0f6657
refactor
CompromisedKiwi Jan 30, 2026
1854448
adaptor
CompromisedKiwi Jan 30, 2026
1484fc7
finish doc_node init
CompromisedKiwi Feb 2, 2026
a69f82f
children
CompromisedKiwi Feb 3, 2026
a6cfceb
doc_node hpp
CompromisedKiwi Feb 4, 2026
0170a0e
DocNode done
CompromisedKiwi Feb 4, 2026
459cfd4
pending review
CompromisedKiwi Feb 5, 2026
5ea167c
NodeTransform done
CompromisedKiwi Feb 6, 2026
e4070f8
rename
CompromisedKiwi Feb 6, 2026
6017ffa
save
CompromisedKiwi Feb 7, 2026
cc7ab7e
Merge branch 'main' into yzh/migrate_doc_node
CompromisedKiwi Feb 7, 2026
615b7b0
Module
CompromisedKiwi Feb 7, 2026
0b193c8
map_params
CompromisedKiwi Feb 10, 2026
0d88ea6
save
CompromisedKiwi Feb 10, 2026
02cbec4
Integrate utf8proc to split text to readable chars.
CompromisedKiwi Feb 10, 2026
af7e617
UnicodeProcessor
CompromisedKiwi Feb 12, 2026
1c7ee82
text splitter base cpp finish
CompromisedKiwi Feb 13, 2026
9ef9bd8
keys
CompromisedKiwi Feb 13, 2026
068ca98
export
CompromisedKiwi Feb 13, 2026
19e00dd
sentence_splitter
CompromisedKiwi Feb 13, 2026
e0c3acc
compile_options
CompromisedKiwi Feb 24, 2026
06aa586
tests in cpp side
CompromisedKiwi Feb 24, 2026
a214e35
libstdc++.so.6
CompromisedKiwi Feb 27, 2026
e865ab6
DocNode manage itself.
CompromisedKiwi Feb 27, 2026
2fd8583
finish cpp side tests
CompromisedKiwi Mar 2, 2026
ac9dad3
cpp env switch
CompromisedKiwi Mar 4, 2026
4ab5a93
no need to test cpp override
CompromisedKiwi Mar 4, 2026
b38affc
cpp tests passed.
CompromisedKiwi Mar 5, 2026
79218fb
merge
CompromisedKiwi Mar 5, 2026
ee3ecbc
install and third parties so.
CompromisedKiwi Mar 5, 2026
42252a7
Reuse python side tests.
CompromisedKiwi Mar 6, 2026
06eabd4
LD_PRELOAD
CompromisedKiwi Mar 11, 2026
fa73e50
feat: add cpp_class decorator for C++ class replacement
CompromisedKiwi Mar 12, 2026
08f3333
docnode cpp ext repaired
CompromisedKiwi Mar 12, 2026
2c893df
save
CompromisedKiwi Mar 13, 2026
f850d15
RegisterMap
CompromisedKiwi Mar 17, 2026
9e709da
NodeTransform refactor
CompromisedKiwi Mar 17, 2026
1024d0e
no node_transform
CompromisedKiwi Mar 17, 2026
81c9aaa
simplify
CompromisedKiwi Mar 18, 2026
25d0c83
new TextSplitterBaseCPPImpl
CompromisedKiwi Mar 18, 2026
7680fff
cpp tests passed
CompromisedKiwi Mar 18, 2026
980d0ad
python tests passed
CompromisedKiwi Mar 19, 2026
0dec57a
change tiktoken cache dir outside
CompromisedKiwi Mar 19, 2026
b5c4ba3
Merge branch 'main' into yzh/migrate_doc_node
CompromisedKiwi Mar 20, 2026
1e1087a
GIL
CompromisedKiwi Mar 20, 2026
13a167d
linting
CompromisedKiwi Mar 23, 2026
043fd1b
cpp_build_and_python_regression
CompromisedKiwi Mar 23, 2026
5ccc9a7
fatal: could not read Username for
CompromisedKiwi Mar 23, 2026
a9417f3
no LAZYLLM_DATA
CompromisedKiwi Mar 23, 2026
c1d03cd
add lazyllm_data
CompromisedKiwi Mar 23, 2026
2b5393e
no rerun
CompromisedKiwi Mar 23, 2026
3fbe4b0
basic tests regression
CompromisedKiwi Mar 23, 2026
787cddd
basic tests regression done
CompromisedKiwi Mar 23, 2026
ed4c5d5
purify cpp_proxy
CompromisedKiwi Apr 7, 2026
8ae6609
no adaptor
CompromisedKiwi Apr 8, 2026
f25a1d4
docnode simplification
CompromisedKiwi Apr 8, 2026
9e2cb42
UUID
CompromisedKiwi Apr 8, 2026
6e32f84
fix
CompromisedKiwi Apr 8, 2026
369eada
fix
CompromisedKiwi Apr 8, 2026
326c068
cpp_proxy simplification
CompromisedKiwi Apr 9, 2026
5a9d1b7
no view
CompromisedKiwi Apr 9, 2026
1b74fa4
save
CompromisedKiwi Apr 9, 2026
4600b72
save
CompromisedKiwi Apr 10, 2026
a105fc1
dynamic cpp member signature checking
CompromisedKiwi Apr 10, 2026
62f2793
save
CompromisedKiwi Apr 11, 2026
d82edc8
cpp proxy class name could be specified.
CompromisedKiwi Apr 11, 2026
20b3eb5
include(FetchContent)
CompromisedKiwi Apr 11, 2026
7608a63
Forbiden R value
CompromisedKiwi Apr 11, 2026
47a2680
else if
CompromisedKiwi Apr 11, 2026
754388e
inline is implicitly specified
CompromisedKiwi Apr 11, 2026
7e895b7
new tests
CompromisedKiwi Apr 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 81 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -748,30 +748,103 @@ jobs:
export LAZYLLM_K8S_CONFIG_PATH="/mnt/nfs_share/k8s_config.yaml"
export LAZYLLM_HOME="${{ env.K8S_CI_PATH }}/${{ github.run_id }}-${{ github.job }}"
mkdir -p $LAZYLLM_HOME
source /mnt/nfs_share/env.sh
source /mnt/nfs_share/env.sh
pytest --lf --last-failed-no-failures=all --durations=0 --reruns=2 -v tests/k8s_tests

cpp_ext_test:
name: C++ Extension Test (${{ matrix.os }})
name: C++ Build + Python Regression (${{ matrix.os }})
needs: [ clone ]
if: always()
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI-generated suggestion; please verify before applying.

[critical] [logic] if: always() 使得 cpp_ext_test 作业在 needs: [clone] 失败时仍会运行,可能导致在没有正确 clone 的情况下执行后续步骤并产生不可预测的失败。

Suggestion: 如果意图是即使其他作业失败也运行,但前提是 clone 成功,应改为:


auto reviewed by BOT (claude-opus-4-6)

matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
timeout-minutes: 120
defaults:
run:
shell: bash
env:
PYTHONNOUSERSITE: "1"
PYTHONPATH: ${{ github.workspace }}
LAZYLLM_ENABLE_CPP_OVERRIDE: "1"
LAZYLLM_EXPECTED_LOG_MODULES: "all"
LAZYLLM_DEFAULT_LAUNCHER: "empty"
LAZYLLM_OPENAI_API_KEY: ${{ secrets.LAZYLLM_OPENAI_API_KEY }}
LAZYLLM_KIMI_API_KEY: ${{ secrets.LAZYLLM_KIMI_API_KEY }}
LAZYLLM_AIPING_API_KEY: ${{ secrets.LAZYLLM_AIPING_API_KEY }}
LAZYLLM_GLM_API_KEY: ${{ secrets.LAZYLLM_GLM_API_KEY }}
LAZYLLM_GLM_MODEL_NAME: ${{ secrets.LAZYLLM_GLM_MODEL_NAME }}
LAZYLLM_QWEN_API_KEY: ${{ secrets.LAZYLLM_QWEN_API_KEY }}
LAZYLLM_QWEN_MODEL_NAME: ${{ secrets.LAZYLLM_QWEN_MODEL_NAME }}
LAZYLLM_QWEN_TEXT2IMAGE_MODEL_NAME: ${{ secrets.LAZYLLM_QWEN_TEXT2IMAGE_MODEL_NAME }}
LAZYLLM_SENSENOVA_API_KEY: ${{ secrets.LAZYLLM_SENSENOVA_API_KEY }}
LAZYLLM_SENSENOVA_SECRET_KEY: ${{ secrets.LAZYLLM_SENSENOVA_SECRET_KEY }}
LAZYLLM_DOUBAO_API_KEY: ${{ secrets.LAZYLLM_DOUBAO_API_KEY }}
LAZYLLM_DOUBAO_MODEL_NAME: ${{ secrets.LAZYLLM_DOUBAO_MODEL_NAME }}
LAZYLLM_SILICONFLOW_API_KEY: ${{ secrets.LAZYLLM_SILICONFLOW_API_KEY }}
LAZYLLM_SILICONFLOW_MODEL_NAME: ${{ secrets.LAZYLLM_SILICONFLOW_MODEL_NAME }}
LAZYLLM_MINIMAX_API_KEY: ${{ secrets.LAZYLLM_MINIMAX_API_KEY }}
LAZYLLM_MINIMAX_MODEL_NAME: ${{ secrets.LAZYLLM_MINIMAX_MODEL_NAME }}
LAZYLLM_PPOP_API_KEY: ${{ secrets.LAZYLLM_PPOP_API_KEY }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
submodules: false

- name: Set up python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup
uses: ./.github/actions/setup

- name: Install test requirements
run: |
pip install -r tests/requirements.txt
if [[ "${{ runner.os }}" == "Linux" ]]; then
pip install -r tests/requirements_linux.txt
elif [[ "${{ runner.os }}" == "macOS" ]]; then
pip install -r tests/requirements_mac.txt
fi

- name: Download test dataset
run: |
set -euo pipefail
DATA_DIR="$GITHUB_WORKSPACE/.ci_data"
rm -rf "$DATA_DIR"
export GIT_TERMINAL_PROMPT=0
git clone --depth 1 https://[email protected]/LazyAGI/LazyLLM-Data.git "$DATA_DIR"
echo "LAZYLLM_DATA_PATH=$DATA_DIR" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN || github.token }}

- name: Test
- name: Build and run C++ tests
run: |
pip install pybind11
bash csrc/scripts/build_test.sh

- name: Install C++ extension artifacts into workspace
run: |
cmake --install build --prefix . --component lazyllm_cpp
ls -al lazyllm | rg "lazyllm_cpp|cpp_lib" || true

- name: Run basic tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI-generated suggestion; please verify before applying.

[medium] [maintainability] basic_tests 和 advanced_tests 的 marker 计算逻辑完全重复,违反 DRY 原则,后续修改容易遗漏。

Suggestion: 将 marker 计算提取到一个独立的前置步骤中,通过环境变量传递给后续步骤:


auto reviewed by BOT (claude-opus-4-6)

run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
MARKER="not skip_on_linux"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
MARKER="not skip_on_mac"
else
MARKER="not skip_on_win"
fi
pytest -v --order-scope=class -m "$MARKER" tests/basic_tests

- name: Run advanced tests
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
MARKER="not skip_on_linux"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
MARKER="not skip_on_mac"
else
MARKER="not skip_on_win"
fi
pytest -v --order-scope=class -m "$MARKER" tests/advanced_tests
6 changes: 0 additions & 6 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ jobs:
name: repo-with-docs
path: ./repo_artifact

- name: Install Python dev headers (Ubuntu only)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y python3-dev

- name: Extract repo-with-docs
run: |
set -ex
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test/
dist/
tmp/
build
.cache/
*.lock
*.db
mkdocs.yml
Expand Down Expand Up @@ -64,3 +65,4 @@ docs/zh/assets
build*
lazyllm_cpp.egg-info/
!build*.sh
lazyllm/cpp_lib/
79 changes: 72 additions & 7 deletions csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,81 @@
cmake_minimum_required(VERSION 3.16)
project(LazyLLMCPP LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
function(lazyllm_enable_strict_warnings target_name)
if (MSVC)
target_compile_options(${target_name} PRIVATE /W4 /WX)
else ()
target_compile_options(${target_name} PRIVATE -Werror -Wshadow)
endif ()
endfunction()

# Third party libs
include(cmake/third_party.cmake)

# Config lazyllm_core lib with pure cpp code.
file(GLOB_RECURSE LAZYLLM_CORE_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE LAZYLLM_CORE_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/core/src/*.cpp")
add_library(lazyllm_core STATIC ${LAZYLLM_CORE_SOURCES})
target_include_directories(lazyllm_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(lazyllm_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/core/include)
target_link_libraries(lazyllm_core PUBLIC xxhash)
target_link_libraries(lazyllm_core PUBLIC tiktoken)
target_link_libraries(lazyllm_core PUBLIC utf8proc)
lazyllm_enable_strict_warnings(lazyllm_core)

# Config lazyllm_cpp lib with binding infomations.
set(LAZYLLM_BINDING_SOURCES binding/lazyllm.cpp binding/doc.cpp)
file(GLOB_RECURSE LAZYLLM_BINDING_SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/binding/*.cpp")
set(INTERFACE_TARGET_NAME lazyllm_cpp)
pybind11_add_module(${INTERFACE_TARGET_NAME} ${LAZYLLM_BINDING_SOURCES})
target_include_directories(${INTERFACE_TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/binding
${CMAKE_CURRENT_SOURCE_DIR}/core/include
)
target_link_libraries(${INTERFACE_TARGET_NAME} PRIVATE lazyllm_core)
lazyllm_enable_strict_warnings(${INTERFACE_TARGET_NAME})

# Runtime loader configuration per platform.
set(_lazyllm_cpp_rpath "")
set(LAZYLLM_TEST_RUNTIME_ENV "" CACHE INTERNAL "Runtime env for LazyLLM C++ tests" FORCE)
if (WIN32)
# Windows has no ELF rpath; loader resolution is driven by PATH and DLL search order.
# Keep test runtime env empty by default.
elseif (APPLE)
# Ensure lazyllm_cpp can find third-party dylibs under lazyllm/cpp_lib.
list(APPEND _lazyllm_cpp_rpath "@loader_path/cpp_lib")
else ()
# Ensure lazyllm_cpp can find third-party shared libraries under lazyllm/cpp_lib.
list(APPEND _lazyllm_cpp_rpath "$ORIGIN/cpp_lib")
# Use DT_RPATH (instead of DT_RUNPATH) so the extension's own runtime
# search path can take precedence over host interpreter bundled libs.
target_link_options(${INTERFACE_TARGET_NAME} PRIVATE -Wl,--disable-new-dtags)

# Resolve libstdc++ from the active C++ compiler and include it in rpath.
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libstdc++.so.6
OUTPUT_VARIABLE LIBSTDCPP_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (LIBSTDCPP_PATH AND NOT LIBSTDCPP_PATH STREQUAL "libstdc++.so.6")
get_filename_component(LIBSTDCPP_DIR "${LIBSTDCPP_PATH}" DIRECTORY)
if (LIBSTDCPP_DIR)
list(APPEND _lazyllm_cpp_rpath "${LIBSTDCPP_DIR}")
set(LAZYLLM_TEST_RUNTIME_ENV "LD_LIBRARY_PATH=${LIBSTDCPP_DIR}:$ENV{LD_LIBRARY_PATH}"
CACHE INTERNAL "Runtime env for LazyLLM C++ tests" FORCE)
endif ()
endif ()
endif ()

if (_lazyllm_cpp_rpath)
set_target_properties(${INTERFACE_TARGET_NAME} PROPERTIES
BUILD_RPATH "${_lazyllm_cpp_rpath}"
INSTALL_RPATH "${_lazyllm_cpp_rpath}"
)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# SHOW_SYMBOL
Expand All @@ -26,7 +84,14 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()

# Install
install(TARGETS ${INTERFACE_TARGET_NAME} LIBRARY DESTINATION lazyllm)
install(TARGETS ${INTERFACE_TARGET_NAME}
LIBRARY DESTINATION lazyllm COMPONENT lazyllm_cpp
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI-generated suggestion; please verify before applying.

[medium] [logic] Install rules for shared libraries omit ARCHIVE destination, so Windows import libraries (.lib) won't be installed correctly.

Suggestion: Add ARCHIVE DESTINATION clauses to both install commands to ensure import libraries are correctly placed.


auto reviewed by BOT (claude-opus-4-6)

RUNTIME DESTINATION lazyllm COMPONENT lazyllm_cpp
)
install(TARGETS tiktoken utf8proc
LIBRARY DESTINATION lazyllm/cpp_lib COMPONENT lazyllm_cpp
RUNTIME DESTINATION lazyllm/cpp_lib COMPONENT lazyllm_cpp
)


# TESTS
Expand Down
File renamed without changes.
131 changes: 131 additions & 0 deletions csrc/binding/binding_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include "binding_utils.hpp"

#include <type_traits>

namespace lazyllm::pybind_utils {

std::string DumpJson(const py::object& obj) {
py::object json = py::module_::import("json");
py::object dumps = json.attr("dumps");
py::object dumped = dumps(obj, py::arg("ensure_ascii") = false);
return dumped.cast<std::string>();
}

py::object LoadJson(const std::string& text) {
py::object json = py::module_::import("json");
py::object loads = json.attr("loads");
return loads(py::str(text));
}

bool ExtractStringSequence(const py::object& obj, std::vector<std::string>* out) {
if (!py::isinstance<py::sequence>(obj) || py::isinstance<py::str>(obj)) return false;
py::sequence seq = obj.cast<py::sequence>();
out->clear();
out->reserve(seq.size());
for (py::handle item : seq) {
if (!py::isinstance<py::str>(item)) {
out->clear();
return false;
}
out->push_back(py::cast<std::string>(item));
}
return true;
}

lazyllm::MetadataMode ParseMetadataMode(const py::object& mode) {
if (mode.is_none()) return lazyllm::MetadataMode::NONE;
try {
if (py::hasattr(mode, "name")) {
const auto name = py::cast<std::string>(mode.attr("name"));
if (name == "ALL") return lazyllm::MetadataMode::ALL;
if (name == "EMBED") return lazyllm::MetadataMode::EMBED;
if (name == "LLM") return lazyllm::MetadataMode::LLM;
if (name == "NONE") return lazyllm::MetadataMode::NONE;
}
} catch (const py::error_already_set&) {
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an AI-generated suggestion; please verify before applying.

[medium] [exception] Silently swallowing py::error_already_set without logging or re-raising makes Python-side errors during metadata parsing impossible to debug.

Suggestion: At minimum, log or clear the Python error state explicitly. Consider narrowing the catch scope or adding a comment explaining why the exception is intentionally ignored.


auto reviewed by BOT (claude-opus-4-6)

if (py::isinstance<py::str>(mode)) {
const auto name = mode.cast<std::string>();
if (name == "ALL") return lazyllm::MetadataMode::ALL;
if (name == "EMBED") return lazyllm::MetadataMode::EMBED;
if (name == "LLM") return lazyllm::MetadataMode::LLM;
if (name == "NONE") return lazyllm::MetadataMode::NONE;
}
if (py::isinstance<py::int_>(mode)) {
const auto value = mode.cast<int>();
switch (value) {
case 0: return lazyllm::MetadataMode::ALL;
case 1: return lazyllm::MetadataMode::EMBED;
case 2: return lazyllm::MetadataMode::LLM;
case 3: return lazyllm::MetadataMode::NONE;
default: break;
}
}
return lazyllm::MetadataMode::NONE;
}

lazyllm::MetadataVType PyToMetadataValue(const py::handle& value) {
if (value.is_none()) return std::string("None");
if (py::isinstance<py::bool_>(value)) return static_cast<int>(value.cast<bool>());
if (py::isinstance<py::int_>(value)) return value.cast<int>();
if (py::isinstance<py::float_>(value)) return value.cast<double>();
if (py::isinstance<py::str>(value)) return value.cast<std::string>();

if (py::isinstance<py::sequence>(value) && !py::isinstance<py::str>(value)) {
py::sequence seq = value.cast<py::sequence>();
if (seq.empty()) return std::vector<std::string>{};

bool all_str = true;
bool all_int = true;
bool all_numeric = true;

for (py::handle item : seq) {
const bool is_str = py::isinstance<py::str>(item);
const bool is_int = py::isinstance<py::int_>(item) && !py::isinstance<py::bool_>(item);
const bool is_numeric = is_int || py::isinstance<py::float_>(item) || py::isinstance<py::bool_>(item);
all_str = all_str && is_str;
all_int = all_int && is_int;
all_numeric = all_numeric && is_numeric;
}

if (all_str) {
std::vector<std::string> out;
out.reserve(seq.size());
for (py::handle item : seq) out.push_back(py::cast<std::string>(item));
return out;
}
if (all_int) {
std::vector<int> out;
out.reserve(seq.size());
for (py::handle item : seq) out.push_back(py::cast<int>(item));
return out;
}
if (all_numeric) {
std::vector<double> out;
out.reserve(seq.size());
for (py::handle item : seq) out.push_back(py::cast<double>(item));
return out;
}

std::vector<std::string> out;
out.reserve(seq.size());
for (py::handle item : seq) out.push_back(py::str(item).cast<std::string>());
return out;
}
return py::str(value).cast<std::string>();
}

py::object MetadataValueToPy(const lazyllm::MetadataVType& value) {
return std::visit([](const auto& v) -> py::object {
using T = std::decay_t<decltype(v)>;
if constexpr (std::is_same_v<T, std::string>) return py::str(v);
if constexpr (std::is_same_v<T, int>) return py::int_(v);
if constexpr (std::is_same_v<T, double>) return py::float_(v);
if constexpr (std::is_same_v<T, std::vector<std::string>>) return py::cast(v);
if constexpr (std::is_same_v<T, std::vector<int>>) return py::cast(v);
if constexpr (std::is_same_v<T, std::vector<double>>) return py::cast(v);
return py::none();
}, value);
}

} // namespace lazyllm::pybind_utils
Loading
Loading