ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::vision::detail Namespace Reference

Functions

std::string strip_json_fence (std::string s)
 Strip a leading/trailing markdown json ... fence if present, and trim surrounding whitespace.
bool is_chat_envelope (const nlohmann::json &body)
 Whether a parsed body is an OpenAI-/Ollama-style chat envelope, i.e.
std::string extract_message_content (const nlohmann::json &body)
 Pull the assistant message text out of an OpenAI-style chat response.
std::optional< std::string > scalar_to_string (const nlohmann::json &v)
 Stringify a JSON scalar (string / number / bool).
bool is_description_key (const std::string &k)
 True for any of the keys treated as the free-text description slot.

Function Documentation

◆ extract_message_content()

std::string reusex::vision::detail::extract_message_content ( const nlohmann::json & body)
inline

Pull the assistant message text out of an OpenAI-style chat response.

Returns an empty string when no string content is present; callers must distinguish "no envelope" from "envelope with empty content" via is_chat_envelope() rather than treating an empty return as "fall back to the whole body" (an empty assistant reply means the model returned nothing usable, STANDARDS §5).

Definition at line 131 of file vlm_protocol.hpp.

References extract_message_content().

Referenced by extract_message_content(), and reusex::vision::parse_vlm_response().

◆ is_chat_envelope()

bool reusex::vision::detail::is_chat_envelope ( const nlohmann::json & body)
inline

Whether a parsed body is an OpenAI-/Ollama-style chat envelope, i.e.

it carries an assistant message under choices[0].message.content or message.content (regardless of whether that content is empty).

Definition at line 108 of file vlm_protocol.hpp.

References is_chat_envelope().

Referenced by is_chat_envelope(), and reusex::vision::parse_vlm_response().

◆ is_description_key()

bool reusex::vision::detail::is_description_key ( const std::string & k)
inline

True for any of the keys treated as the free-text description slot.

Definition at line 164 of file vlm_protocol.hpp.

References is_description_key().

Referenced by is_description_key(), and reusex::vision::parse_vlm_response().

◆ scalar_to_string()

std::optional< std::string > reusex::vision::detail::scalar_to_string ( const nlohmann::json & v)
inline

Stringify a JSON scalar (string / number / bool).

Returns nullopt for a container (object/array) or null — those are not attribute values.

Definition at line 149 of file vlm_protocol.hpp.

References scalar_to_string().

Referenced by reusex::vision::parse_vlm_response(), and scalar_to_string().

◆ strip_json_fence()

std::string reusex::vision::detail::strip_json_fence ( std::string s)
inline

Strip a leading/trailing markdown json ... fence if present, and trim surrounding whitespace.

Returns the inner text (which may still not be JSON).

Definition at line 82 of file vlm_protocol.hpp.

References strip_json_fence().

Referenced by reusex::vision::parse_vlm_response(), and strip_json_fence().