DocWire SDK
DocWire SDK: Deterministic, auditable, and secure data processing in C++20. On-premise by default. No compromises on computational speed.
Toggle main menu visibility
Loading...
Searching...
No Matches
openai_find_image.cpp
This example shows how to find objects within an image using the OpenAI API.
#include "docwire.h"
#include "environment.h"
#include <sstream>
int
main(
int
argc,
char
* argv[])
{
using namespace
docwire
;
std::stringstream out_stream;
try
{
std::filesystem::path(
"scene_1.png"
) |
content_type::detector
{} |
openai::find
(
"tree"
, environment::get(
"OPENAI_API_KEY"
).value(), openai::model::gpt_4o) | out_stream;
ensure
(fuzzy_match::ratio(out_stream.str(),
"2\n- A tree is located on the left side of the image near the people.\n- Another tree is in the background near the center of the image.\n"
)) > 80;
}
catch
(
const
std::exception& e)
{
std::cerr <<
errors::diagnostic_message
(e) << std::endl;
return
1;
}
return
0;
}
docwire::content_type::detector
Content type detection chain element.
Definition
content_type.h:107
docwire::ensure
A utility for creating expressive, exception-throwing assertions in a fluent style.
Definition
ensure.h:56
docwire::openai::find
Definition
find.h:25
docwire::errors::diagnostic_message
std::string diagnostic_message(const std::exception &e)
Generates a diagnostic message for the given nested exceptions chain.
Definition
diagnostic_message.h:27
docwire
The main namespace for the DocWire SDK.
Definition
ai_elements.h:19
Generated by
1.18.0