Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
da4fbee
align SDK public APIs to Swift source of truth; add per-SDK usage docs
Siddhesh2377 Jul 17, 2026
e27ffa8
Merge remote-tracking branch 'origin/main' into siddhesh/sdk-cross-fi…
Siddhesh2377 Jul 18, 2026
bc60e73
Fill missing telemetry fields (prompt_eval, embeddings tokens, lora) …
Siddhesh2377 Jul 18, 2026
0e168f8
Fill RAG query_token_count and context_tokens telemetry fields at eng…
Siddhesh2377 Jul 19, 2026
4ff510a
Add rcli bench command auto-benchmarking installed LLM/STT/TTS/VLM mo…
Siddhesh2377 Jul 19, 2026
77f518c
Fix LLM token undercount: use decode-loop count, not streaming-callba…
Siddhesh2377 Jul 19, 2026
607cb63
Fix LLM streaming token undercount: thread authoritative decode count…
Siddhesh2377 Jul 19, 2026
408a034
Chat composer redesign: two-row layout with thinking toggle (from #560)
Siddhesh2377 Jul 19, 2026
69df785
Merge remote-tracking branch 'origin/main' into siddhesh/sdk-cross-fi…
Siddhesh2377 Jul 19, 2026
34e146c
Add telemetry extraction unit tests (per-modality routing + field reg…
Siddhesh2377 Jul 19, 2026
125203e
Add live telemetry integration test (--live): authenticated per-modal…
Siddhesh2377 Jul 19, 2026
b6a0714
Allowlist Kotlin web-search tool JSON surface (external DuckDuckGo re…
Siddhesh2377 Jul 19, 2026
4383a4b
Revert "Fix LLM streaming token undercount: thread authoritative deco…
Siddhesh2377 Jul 19, 2026
0b1bc05
Fix PR CI: rebuild proto-ts dist for IDL drift; test C++20
Siddhesh2377 Jul 19, 2026
0ffe108
Fix PR CI: gate rcli rag command on RAC_BACKEND_RAG (Windows); ktlint…
Siddhesh2377 Jul 19, 2026
ed244b1
Merge branch 'main' into siddhesh/sdk-cross-fit-work-v1
shubhammalhotra28 Jul 21, 2026
111ad36
staging: keyless environment with baked backend URL — staging overrid…
Siddhesh2377 Jul 21, 2026
e097cd5
tests: live keyless-staging E2E — env-only init resolves baked URL, o…
Siddhesh2377 Jul 21, 2026
010c043
build: --env-staging flag for rcli and android commons builds; STAGIN…
Siddhesh2377 Jul 21, 2026
15a6e14
sdks: platform HTTP adapters use commons-effective base URL and send …
Siddhesh2377 Jul 21, 2026
125956a
rcli: keyless staging boots telemetry (RUNANYWHERE_ENVIRONMENT=stagin…
Siddhesh2377 Jul 21, 2026
ec472f2
examples: android/flutter/rn apps default to keyless staging for devi…
Siddhesh2377 Jul 21, 2026
1d842b2
telemetry: per-event sdk_binding + live device state (battery/RAM/CPU…
Siddhesh2377 Jul 21, 2026
d16b7e9
sdks: real device info across kotlin/swift/flutter/rn/web (battery, S…
Siddhesh2377 Jul 21, 2026
58f6141
examples: flutter/rn use production env with build-time dev credentia…
Siddhesh2377 Jul 21, 2026
283629f
sdks: drop baked Supabase creds + build-token from commons & iOS (kee…
shubhammalhotra28 Jul 21, 2026
abbd335
react-native: drop baked Supabase creds + build-token reads (mirror c…
shubhammalhotra28 Jul 21, 2026
7a903c2
web: drop baked Supabase creds + build-token wasm exports (mirror com…
shubhammalhotra28 Jul 21, 2026
7589c99
kotlin: drop baked Supabase creds + build-token bridge (mirror common…
shubhammalhotra28 Jul 21, 2026
b20d3f1
flutter: drop baked Supabase creds + build-token bridge (mirror commo…
shubhammalhotra28 Jul 21, 2026
6d8e385
commons+ios: remove dead Supabase upsert HTTP plumbing (keep HuggingF…
shubhammalhotra28 Jul 21, 2026
c806719
react-native: remove dead Supabase upsert plumbing (mirror commons/iOS)
shubhammalhotra28 Jul 21, 2026
83c802c
flutter: remove dead Supabase upsert plumbing (mirror commons/iOS)
shubhammalhotra28 Jul 21, 2026
37e09cb
web: remove dead Supabase upsert plumbing (mirror commons/iOS)
shubhammalhotra28 Jul 21, 2026
0593475
kotlin: remove dead Supabase upsert plumbing (mirror commons/iOS)
shubhammalhotra28 Jul 21, 2026
ac36cee
ios: drop residual Supabase Prefer header for cross-SDK parity
shubhammalhotra28 Jul 21, 2026
c2fa28a
web: drop dead /sdk_devices exclusion from smoke-test error filter
shubhammalhotra28 Jul 21, 2026
97f0f69
merge: incorporate base (device-info/telemetry/retry); keep full Supa…
shubhammalhotra28 Jul 22, 2026
dea5e70
Merge pull request #580 from RunanywhereAI/shubham/telemetry-endpoint…
shubhammalhotra28 Jul 22, 2026
beaf52d
feat(rcli): control-plane network driver — connection flags, auth, te…
sanchitmonga22 Jul 19, 2026
ee90038
examples: align all five apps to brand orange #FF6900 + design guideline
sanchitmonga22 Jul 19, 2026
cbf23dd
fix(spm): compile the new rcli net + auth/telemetry sources in the Sw…
sanchitmonga22 Jul 19, 2026
aa0b93a
fix(rcli): finish rebase onto sdk-cross-fit — restore commons symbol,…
shubhammalhotra28 Jul 22, 2026
30a4611
fix(rcli): use RUNANYWHERE_ENVIRONMENT as the only env name
shubhammalhotra28 Jul 22, 2026
3ae1933
Merge pull request #570 from RunanywhereAI/feat/example-apps-brand-al…
shubhammalhotra28 Jul 22, 2026
cf6afeb
updates
shubhammalhotra28 Jul 23, 2026
7ebe4d9
ci: path-filter OSS keyless telemetry on relevant PRs
shubhammalhotra28 Jul 23, 2026
4eecce3
changes
shubhammalhotra28 Jul 23, 2026
a727bbc
fix(ci): repair staging-removal breakages that reddened PR checks
shubhammalhotra28 Jul 23, 2026
6c4b5af
minor changes
shubhammalhotra28 Jul 23, 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
60 changes: 60 additions & 0 deletions .github/workflows/oss-keyless-telemetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# =============================================================================
# OSS keyless telemetry gate — rcli development → public staging backend
# =============================================================================
# Primary CI for the open-source contract: build rcli in this public repo and
# keyless-blast all 12 modalities at the staging backend (PUBLIC org). No API
# key. Staging origin comes from repo secrets/vars — not hardcoded hosts.
# =============================================================================

name: OSS keyless telemetry

on:
pull_request:
paths:
- ".github/workflows/oss-keyless-telemetry.yml"
- "scripts/ci/oss_keyless_telemetry_blast.sh"
- "sdk/runanywhere-cli/**"
- "sdk/runanywhere-commons/src/infrastructure/network/**"
- "sdk/runanywhere-commons/src/lifecycle/**"
- "sdk/runanywhere-commons/src/core/sdk_state.cpp"
schedule:
# Daily 08:00 UTC — light cadence for Staging drift.
- cron: "0 8 * * *"
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
keyless-staging-blast:
name: rcli keyless → staging backend
runs-on: macos-14
timeout-minutes: 60
steps:
- uses: actions/checkout@v7
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false

- name: Install ninja + protobuf
run: brew install ninja protobuf

- name: Require staging backend origin
env:
STAGING_BASE_URL: ${{ secrets.STAGING_BASE_URL }}
RA_OSS_BASE_URL: ${{ vars.RA_OSS_BASE_URL }}
run: |
set -euo pipefail
if [[ -z "${STAGING_BASE_URL:-}" && -z "${RA_OSS_BASE_URL:-}" ]]; then
echo "::error::Set repository secret STAGING_BASE_URL (or variable RA_OSS_BASE_URL) to the public staging backend origin."
exit 1
fi

- name: Build rcli + keyless blast (12 modalities)
env:
STAGING_BASE_URL: ${{ secrets.STAGING_BASE_URL }}
RA_OSS_BASE_URL: ${{ vars.RA_OSS_BASE_URL || secrets.STAGING_BASE_URL }}
run: bash scripts/ci/oss_keyless_telemetry_blast.sh
38 changes: 31 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ permissions:

env:
RELEASE_VERSION: ${{ github.event.inputs.version || github.ref_name }}
# Development-analytics config baked into rac_commons at build time. Kept in CI
# secrets (never in the public source tree); the commons CMake substitutes them
# into the generated development_config.cpp when present (else a credential-free
# stub). See sdk/runanywhere-commons/CMakeLists.txt (DEVELOPMENT CONFIG SOURCE).
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
# Neutral public staging backend base URL baked into rac_commons at build time
# — lets environment=development run keyless with no explicit URL (see
# rac_dev_config_get_staging_base_url). Kept in a CI secret (never in the public
# source tree); the commons CMake substitutes it into the generated
# development_config.cpp. validate fails closed if the secret is missing /
# unusable so release artifacts never ship the placeholder stub. No
# credentials, project refs, or tokens are ever embedded.
STAGING_BASE_URL: ${{ secrets.STAGING_BASE_URL }}

jobs:

Expand All @@ -57,6 +58,29 @@ jobs:
version: ${{ steps.parse.outputs.version }}
steps:
- uses: actions/checkout@v7
- name: Require usable STAGING_BASE_URL for release bake
env:
STAGING_BASE_URL: ${{ secrets.STAGING_BASE_URL }}
run: |
set -euo pipefail
# Fail closed: empty/placeholder secrets bake YOUR_STAGING_BASE_URL into
# development_config.cpp, which rac_dev_config_is_usable_http_url rejects —
# released binaries then cannot keyless-resolve a development backend.
if [[ -z "${STAGING_BASE_URL:-}" ]]; then
echo "::error::Repository secret STAGING_BASE_URL is unset or empty. Set it to the public staging backend origin (https://…) before running the release train."
exit 1
fi
case "${STAGING_BASE_URL}" in
YOUR_STAGING_BASE_URL|http://YOUR_*|https://YOUR_*|placeholder*|PLACEHOLDER*)
echo "::error::STAGING_BASE_URL looks like a placeholder ('${STAGING_BASE_URL}'). Set the real public staging backend origin."
exit 1
;;
esac
if [[ ! "${STAGING_BASE_URL}" =~ ^https?://[^[:space:]]+$ ]]; then
echo "::error::STAGING_BASE_URL must be an http(s) origin without whitespace (got '${STAGING_BASE_URL}')."
exit 1
fi
echo "STAGING_BASE_URL is set and looks usable for release bake."
- name: Parse and validate version
id: parse
run: |
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ Cross-platform on-device AI SDK monorepo. A single C/C++ core (`runanywhere-comm
| React Native | `examples/react-native/RunAnywhereAI/` | RN 0.85 + NitroModules |
| Web | `examples/web/RunAnywhereAI/` | Vanilla TS + Vite |

All example apps share one visual identity — brand orange `#FF6900` (the logo primary, **not** the legacy `#FF5500`), documented in `examples/DESIGN_GUIDELINE.md`. Each app hand-maintains a small theme file that mirrors that doc; see the "Design System" section in each app's `AGENTS.md`.

### Playground
`Playground/` contains 6 standalone demo projects (not part of any build system): YapRun (iOS dictation app), swift-starter-app, on-device-browser-agent, android-use-agent, linux-voice-assistant, openclaw-hybrid-assistant.

Expand Down
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"RAC_BACKEND_COREML": "ON",
"RAC_RUNTIME_ONNXRT": "ON",
"RAC_RUNTIME_COREML": "ON",
"RAC_BACKEND_RAG": "OFF",
"RAC_BACKEND_RAG": "ON",
"RAC_BUILD_SERVER": "ON",
"RAC_STATIC_PLUGINS": "ON",
"RAC_BUILD_SHARED": "OFF",
Expand All @@ -127,7 +127,7 @@
"RAC_BACKEND_SHERPA": "ON",
"RAC_BACKEND_ONNX": "ON",
"RAC_RUNTIME_ONNXRT": "ON",
"RAC_BACKEND_RAG": "OFF",
"RAC_BACKEND_RAG": "ON",
"RAC_BUILD_SERVER": "ON",
"RAC_STATIC_PLUGINS": "ON",
"RAC_BUILD_SHARED": "OFF",
Expand Down
6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ let package = Package(
sources: [
"src/app.cpp",
"src/bootstrap.cpp",
"src/net/control_plane.cpp",
"src/catalog/catalog.cpp",
"src/catalog/model_ref.cpp",
"src/commands/cmd_version.cpp",
Expand All @@ -452,9 +453,14 @@ let package = Package(
"src/commands/cmd_vad.cpp",
"src/commands/cmd_voice.cpp",
"src/commands/cmd_image.cpp",
"src/commands/cmd_rag.cpp",
"src/commands/cmd_bench.cpp",
"src/commands/cmd_auth.cpp",
"src/commands/cmd_telemetry.cpp",
"src/commands/engine_options.cpp",
"src/commands/model_setup.cpp",
"src/config/cli_paths.cpp",
"src/device_info.cpp",
"src/io/wav_io.cpp",
"src/io/image_io.cpp",
"src/io/output.cpp",
Expand Down
25 changes: 21 additions & 4 deletions engines/llamacpp/llamacpp_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,10 @@ TextGenerationResult LlamaCppTextGeneration::generate(const TextGenerationReques
result.finish_reason = "error";

std::string generated_text;
int tokens_generated = 0;
int callback_pieces = 0;
int decoded_tokens = 0;
int prompt_tokens = 0;
double prompt_eval_ms = 0.0;

auto start_time = std::chrono::high_resolution_clock::now();

Expand All @@ -830,10 +832,14 @@ TextGenerationResult LlamaCppTextGeneration::generate(const TextGenerationReques
request,
[&](const std::string& token) -> bool {
generated_text += token;
tokens_generated++;
callback_pieces++;
return !cancel_requested_.load();
},
&prompt_tokens);
&prompt_tokens, &prompt_eval_ms, &decoded_tokens);
// The streaming callback flushes buffered chunks, not one call per token, so
// callback_pieces under-counts. Use the decode loop's authoritative count;
// fall back to the piece count only if the out-param wasn't populated.
const int tokens_generated = decoded_tokens > 0 ? decoded_tokens : callback_pieces;
RAC_LOG_INFO("LLM.LlamaCpp", "generate(): generate_stream returned success=%d, tokens=%d",
success, tokens_generated);

Expand All @@ -844,6 +850,7 @@ TextGenerationResult LlamaCppTextGeneration::generate(const TextGenerationReques
result.tokens_generated = tokens_generated;
result.prompt_tokens = prompt_tokens;
result.inference_time_ms = duration.count();
result.prompt_eval_time_ms = prompt_eval_ms;

if (decode_failed_) {
result.finish_reason = "error";
Expand Down Expand Up @@ -988,7 +995,8 @@ int LlamaCppTextGeneration::run_decode_loop(llama_sampler* sampler, llama_batch&
}

bool LlamaCppTextGeneration::generate_stream(const TextGenerationRequest& request,
TextStreamCallback callback, int* out_prompt_tokens) {
TextStreamCallback callback, int* out_prompt_tokens,
double* out_prompt_eval_ms, int* out_tokens_generated) {
std::lock_guard<std::mutex> lock(mutex_);

if (!is_ready_locked()) {
Expand Down Expand Up @@ -1099,6 +1107,7 @@ bool LlamaCppTextGeneration::generate_stream(const TextGenerationRequest& reques
prompt_tokens, n_batch);
llama_batch batch = llama_batch_init(n_batch, 0, 1);

const auto prefill_start = std::chrono::steady_clock::now();
for (int chunk_start = 0; chunk_start < prompt_tokens; chunk_start += n_batch) {
batch.n_tokens = 0;
int chunk_end = std::min(chunk_start + n_batch, prompt_tokens);
Expand All @@ -1116,6 +1125,11 @@ bool LlamaCppTextGeneration::generate_stream(const TextGenerationRequest& reques
return false;
}
}
if (out_prompt_eval_ms) {
*out_prompt_eval_ms = std::chrono::duration<double, std::milli>(
std::chrono::steady_clock::now() - prefill_start)
.count();
}
RAC_LOG_INFO("LLM.LlamaCpp", "generate_stream: prompt decoded successfully");

// Configure sampler with request parameters — skip rebuild if params
Expand Down Expand Up @@ -1165,6 +1179,9 @@ bool LlamaCppTextGeneration::generate_stream(const TextGenerationRequest& reques
// generate_from_context() via run_decode_loop().
const int tokens_generated =
run_decode_loop(sampler_, batch, batch.n_tokens, effective_max_tokens, callback);
if (out_tokens_generated != nullptr) {
*out_tokens_generated = tokens_generated;
}

// TODO(streaming-tools): Emit tool_call_delta events during stream.
// To support generateWithToolsStream for Web and RN, the generate_stream
Expand Down
9 changes: 8 additions & 1 deletion engines/llamacpp/llamacpp_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct TextGenerationResult {
int tokens_generated = 0;
int prompt_tokens = 0;
double inference_time_ms = 0.0;
double prompt_eval_time_ms = 0.0; // prefill (prompt decode) wall-clock
std::string finish_reason; // "stop", "length", "cancelled"
};

Expand Down Expand Up @@ -152,9 +153,15 @@ class LlamaCppTextGeneration {
* @param request Generation request.
* @param callback Streaming callback; return false to cancel.
* @param out_prompt_tokens Optional: tokenized prompt length (may be NULL).
* @param out_prompt_eval_ms Optional: prefill (prompt decode) time in ms (may be NULL).
* @param out_tokens_generated Optional: authoritative decoded-token count from
* the decode loop (may be NULL). Prefer this over counting streaming
* callback invocations — the callback flushes buffered chunks, not one
* call per token, so callback counts under-report generated tokens.
*/
bool generate_stream(const TextGenerationRequest& request, TextStreamCallback callback,
int* out_prompt_tokens = nullptr);
int* out_prompt_tokens = nullptr, double* out_prompt_eval_ms = nullptr,
int* out_tokens_generated = nullptr);

void cancel();

Expand Down
1 change: 1 addition & 0 deletions engines/llamacpp/rac_llm_llamacpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ rac_result_t rac_llm_llamacpp_generate(rac_handle_t handle, const char* prompt,
out_result->prompt_tokens = result.prompt_tokens;
out_result->total_tokens = result.prompt_tokens + result.tokens_generated;
out_result->time_to_first_token_ms = 0;
out_result->prompt_eval_time_ms = static_cast<int64_t>(result.prompt_eval_time_ms);
out_result->total_time_ms = result.inference_time_ms;
out_result->tokens_per_second =
result.tokens_generated > 0 && result.inference_time_ms > 0
Expand Down
1 change: 1 addition & 0 deletions engines/llamacpp/rac_vlm_llamacpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ rac_result_t rac_vlm_llamacpp_process(rac_handle_t handle, const rac_vlm_image_t
const double decode_ms = ms(t_end - t_after_prep).count();
out_result->total_time_ms = static_cast<int64_t>(total_ms);
out_result->image_encode_time_ms = static_cast<int64_t>(ms(t_after_prep - t_start).count());
out_result->prompt_eval_time_ms = static_cast<int64_t>(ms(t_after_prep - t_start).count());
out_result->time_to_first_token_ms = static_cast<int64_t>(ms(t_first_token - t_start).count());
out_result->tokens_per_second =
decode_ms > 0.0 ? static_cast<float>(tokens_generated / (decode_ms / 1000.0)) : 0.0f;
Expand Down
39 changes: 30 additions & 9 deletions engines/onnx/onnx_embedding_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class ONNXEmbeddingProvider::Impl {

~Impl() = default;

std::vector<float> embed(const std::string& text) {
std::vector<float> embed(const std::string& text, size_t* out_total_tokens = nullptr) {
if (!ready_) {
LOGE("Embedding provider not ready");
return {};
Expand All @@ -560,6 +560,10 @@ class ONNXEmbeddingProvider::Impl {

try {
auto token_ids = tokenizer_.encode_unpadded(text, max_seq_length_);
const size_t real_tokens = token_ids.size();
if (out_total_tokens) {
*out_total_tokens = real_tokens;
}
const size_t pad_length = align_up(token_ids.size(), 8);
tokenizer_.pad_to(token_ids, pad_length);

Expand Down Expand Up @@ -630,14 +634,18 @@ class ONNXEmbeddingProvider::Impl {
}
}

std::vector<std::vector<float>> embed_batch(const std::vector<std::string>& texts) {
std::vector<std::vector<float>> embed_batch(const std::vector<std::string>& texts,
size_t* out_total_tokens = nullptr) {
if (out_total_tokens) {
*out_total_tokens = 0;
}
if (texts.empty()) {
return {};
}

// Delegate to single embed for batch_size == 1
if (texts.size() == 1) {
return {embed(texts[0])};
return {embed(texts[0], out_total_tokens)};
}

if (!ready_) {
Expand All @@ -649,24 +657,31 @@ class ONNXEmbeddingProvider::Impl {

std::vector<std::vector<float>> all_results;
all_results.reserve(texts.size());
size_t total_tokens = 0;

for (size_t offset = 0; offset < texts.size(); offset += kMaxSubBatchSize) {
size_t sub_batch_size = std::min(kMaxSubBatchSize, texts.size() - offset);

LOGI("Embedding sub-batch %zu/%zu (size=%zu)", offset / kMaxSubBatchSize + 1,
(texts.size() + kMaxSubBatchSize - 1) / kMaxSubBatchSize, sub_batch_size);

auto sub_results = embed_sub_batch(texts, offset, sub_batch_size);
size_t sub_tokens = 0;
auto sub_results = embed_sub_batch(texts, offset, sub_batch_size, &sub_tokens);
if (sub_results.empty()) {
LOGE("Sub-batch embedding failed at offset %zu", offset);
return {};
}
total_tokens += sub_tokens;

for (auto& r : sub_results) {
all_results.push_back(std::move(r));
}
}

if (out_total_tokens) {
*out_total_tokens = total_tokens;
}

LOGI("Generated batch embeddings: count=%zu, dim=%zu", all_results.size(), embedding_dim_);
return all_results;
}
Expand All @@ -684,14 +699,20 @@ class ONNXEmbeddingProvider::Impl {
}

std::vector<std::vector<float>> embed_sub_batch(const std::vector<std::string>& texts,
size_t offset, size_t count) {
size_t offset, size_t count,
size_t* out_total_tokens = nullptr) {
try {
std::vector<std::vector<int64_t>> all_token_ids(count);
size_t max_actual_len = 0;
size_t total_tokens = 0;

for (size_t i = 0; i < count; ++i) {
all_token_ids[i] = tokenizer_.encode_unpadded(texts[offset + i], max_seq_length_);
max_actual_len = std::max(max_actual_len, all_token_ids[i].size());
total_tokens += all_token_ids[i].size();
}
if (out_total_tokens) {
*out_total_tokens = total_tokens;
}

const size_t pad_length = align_up(max_actual_len, 8);
Expand Down Expand Up @@ -863,13 +884,13 @@ ONNXEmbeddingProvider::~ONNXEmbeddingProvider() = default;
ONNXEmbeddingProvider::ONNXEmbeddingProvider(ONNXEmbeddingProvider&&) noexcept = default;
ONNXEmbeddingProvider& ONNXEmbeddingProvider::operator=(ONNXEmbeddingProvider&&) noexcept = default;

std::vector<float> ONNXEmbeddingProvider::embed(const std::string& text) {
return impl_->embed(text);
std::vector<float> ONNXEmbeddingProvider::embed(const std::string& text, size_t* out_total_tokens) {
return impl_->embed(text, out_total_tokens);
}

std::vector<std::vector<float>>
ONNXEmbeddingProvider::embed_batch(const std::vector<std::string>& texts) {
return impl_->embed_batch(texts);
ONNXEmbeddingProvider::embed_batch(const std::vector<std::string>& texts, size_t* out_total_tokens) {
return impl_->embed_batch(texts, out_total_tokens);
}

size_t ONNXEmbeddingProvider::dimension() const noexcept {
Expand Down
Loading
Loading