Skip to content

feat(sdk/cpp): Add vision sample, auto-download NuGet deps, and SDK README#697

Merged
apsonawane merged 19 commits intomainfrom
asonawane/cpp-sample
May 8, 2026
Merged

feat(sdk/cpp): Add vision sample, auto-download NuGet deps, and SDK README#697
apsonawane merged 19 commits intomainfrom
asonawane/cpp-sample

Conversation

@apsonawane
Copy link
Copy Markdown
Contributor

@apsonawane apsonawane commented May 7, 2026

feat(sdk/cpp): Add Responses API vision sample with auto-download build system

Adds a C++ vision sample, NuGet auto-download build infrastructure, SDK README, and find_package(FoundryLocal) support

What's included

Vision sample (sdk/cpp/sample/web-server-responses-vision/)

  • Demonstrates vision (image understanding) using the Foundry Local web service and the OpenAI Responses API
  • Loads, resizes (max 512px), and base64-encodes images using stb
  • Streams model response token-by-token via SSE using libcurl
  • Robust SSE parsing with persistent buffer across cURL callbacks
  • Mirrors the structure of samples/python/web-server-responses-vision

SDK build improvements (sdk/cpp/CMakeLists.txt)

  • Auto-downloads NuGet runtime DLLs (Core, OnnxRuntime, OnnxRuntimeGenAI) at configure time via fl_ensure_nuget_package()
  • Exposes fl_copy_runtime_dlls(TARGET) — copies all runtime DLLs next to any executable
  • Vision sample built as optional target WebServerResponsesVision (requires curl)
  • CMake install rules for producing a redistributable SDK layout

find_package(FoundryLocal) support (sdk/cpp/cmake/FoundryLocalConfig.cmake)

  • Consumers can use the prebuilt SDK via find_package(FoundryLocal REQUIRED)
  • Provides imported target FoundryLocal::FoundryLocal and fl_copy_runtime_dlls() helper

SDK README (sdk/cpp/README.md)

  • Full documentation: features, prerequisites, build steps, quick start, API usage examples
  • Vision sample build instructions (from SDK root and standalone)
  • Prebuilt SDK zip creation and consumer workflow
  • Configuration reference, API reference, troubleshooting

Files changed (13 files, +1129 lines)

File Change
sdk/cpp/CMakeLists.txt NuGet auto-download, fl_copy_runtime_dlls(), vision sample target, install rules
sdk/cpp/README.md Full SDK documentation (new)
sdk/cpp/cmake/FoundryLocalConfig.cmake find_package(FoundryLocal) support (new)
sdk/cpp/vcpkg.json Added curl, stb dependencies
sdk/cpp/test/model_variant_test.cpp Fixed test: Download callback returns bool not void
sdk/cpp/sample/web-server-responses-vision/main.cpp Vision sample implementation (new)
sdk/cpp/sample/web-server-responses-vision/stb_impl.cpp stb library implementation (new)
sdk/cpp/sample/web-server-responses-vision/CMakeLists.txt Sample build config (new)
sdk/cpp/sample/web-server-responses-vision/CMakePresets.json Standalone build presets (new)
sdk/cpp/sample/web-server-responses-vision/README.md Sample documentation (new)
sdk/cpp/sample/web-server-responses-vision/test_image.jpg Default test image (new)
sdk/cpp/sample/web-server-responses-vision/vcpkg.json Sample vcpkg manifest (new)
sdk/cpp/sample/web-server-responses-vision/vcpkg-configuration.json vcpkg baseline (new)

Build & run

# From sdk/cpp (builds everything)
cmake --preset x64-debug
cmake --build --preset x64-debug --target WebServerResponsesVision
.\out\build\x64-debug\WebServerResponsesVision.exe qwen3.5-0.8b

# Or standalone from the sample directory
cd sample/web-server-responses-vision
cmake --preset x64-debug
cmake --build --preset x64-debug
.\out\build\x64-debug\web-server-responses-vision.exe qwen3.5-0.8b

@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment May 7, 2026 10:58pm

Request Review

@apsonawane apsonawane requested a review from Copilot May 7, 2026 05:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Windows-focused C++ sample that calls a local Foundry web service using the /v1/responses endpoint for vision + SSE streaming, including build plumbing via CMake/vcpkg and stb-based image preprocessing.

Changes:

  • Introduces a C++ vision streaming sample using libcurl (SSE) and stb (load/resize/JPEG/base64).
  • Adds vcpkg manifest + baseline configuration for sample dependencies.
  • Adds CMake project wiring that builds the Foundry Local C++ SDK as a subdirectory and links WinML EP Catalog libs.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
samples/cpp/web-server-responses-vision/main.cpp Implements image preprocessing, SSE parsing/streaming via libcurl, and Foundry Local web service orchestration.
samples/cpp/web-server-responses-vision/stb_impl.cpp Provides single TU stb implementations for image load/resize/write used by the sample.
samples/cpp/web-server-responses-vision/CMakeLists.txt Adds a standalone build for the sample and links to the Foundry SDK, curl, and WinML deps.
samples/cpp/web-server-responses-vision/vcpkg.json Declares vcpkg dependencies needed by the sample.
samples/cpp/web-server-responses-vision/vcpkg-configuration.json Pins a vcpkg builtin registry baseline for reproducible builds.
samples/cpp/web-server-responses-vision/README.md Documents prerequisites, build/run steps, and a high-level flow explanation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp
Comment thread samples/cpp/web-server-responses-vision/main.cpp Outdated
Comment thread samples/cpp/web-server-responses-vision/main.cpp Outdated
Comment thread samples/cpp/web-server-responses-vision/main.cpp Outdated
Comment thread samples/cpp/web-server-responses-vision/main.cpp Outdated
Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp
Comment thread samples/cpp/web-server-responses-vision/README.md Outdated
Comment thread samples/cpp/web-server-responses-vision/CMakeLists.txt Outdated
Comment thread samples/cpp/web-server-responses-vision/main.cpp Fixed
@apsonawane apsonawane changed the title Add C++ Vision Sample (Responses API) feat(sdk/cpp): Add vision sample, auto-download NuGet deps, and SDK README May 7, 2026
@apsonawane apsonawane requested a review from Copilot May 7, 2026 07:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 10 comments.

Comment thread sdk/cpp/CMakeLists.txt
Comment thread sdk/cpp/CMakeLists.txt Outdated
Comment thread sdk/cpp/CMakeLists.txt
Comment thread sdk/cpp/cmake/FoundryLocalConfig.cmake Outdated
Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp
Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp Outdated
Comment thread sdk/cpp/sample/web-server-responses-vision/README.md
Comment thread sdk/cpp/sample/web-server-responses-vision/README.md Outdated
Comment thread sdk/cpp/README.md
Comment thread sdk/cpp/cmake/FoundryLocalConfig.cmake Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp
Comment thread sdk/cpp/sample/web-server-responses-vision/main.cpp
Comment thread sdk/cpp/cmake/FoundryLocalConfig.cmake
@apsonawane apsonawane merged commit 0554832 into main May 8, 2026
52 checks passed
@apsonawane apsonawane deleted the asonawane/cpp-sample branch May 8, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants