Skip to content

Commit

Permalink
Merge pull request #86 from pkeir/warn-pr
Browse files Browse the repository at this point in the history
Avoid GCC warnings about missing declarations of operator<< in namespace liboai
  • Loading branch information
D7EAD authored Dec 20, 2024
2 parents b008194 + aa8568b commit 92127a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions liboai/components/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,16 @@ liboai::FutureResponse liboai::ChatCompletion::create_async(const std::string& m
return std::async(std::launch::async, &liboai::ChatCompletion::create, this, model, std::ref(conversation), function_call, temperature, top_p, n, stream, stop, max_tokens, presence_penalty, frequency_penalty, logit_bias, user);
}

std::ostream& liboai::operator<<(std::ostream& os, const Conversation& conv) {
namespace liboai {

std::ostream& operator<<(std::ostream& os, const Conversation& conv) {
os << conv.GetRawConversation() << std::endl << (conv.HasFunctions() ? conv.GetRawFunctions() : "");

return os;
}

}

liboai::Functions::Functions() {
this->_functions["functions"] = nlohmann::json::array();
}
Expand Down Expand Up @@ -1125,4 +1129,4 @@ liboai::Functions::index liboai::Functions::GetFunctionIndex(std::string_view fu
}

return -1;
}
}
8 changes: 6 additions & 2 deletions liboai/core/response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ liboai::Response& liboai::Response::operator=(liboai::Response&& other) noexcept
return *this;
}

std::ostream& liboai::operator<<(std::ostream& os, const Response& r) {
namespace liboai {

std::ostream& operator<<(std::ostream& os, const Response& r) {
!r.raw_json.empty() ? os << r.raw_json.dump(4) : os << "null";
return os;
}

}

void liboai::Response::CheckResponse() const noexcept(false) {
if (this->status_code == 429) {
throw liboai::exception::OpenAIRateLimited(
Expand Down Expand Up @@ -106,4 +110,4 @@ void liboai::Response::CheckResponse() const noexcept(false) {
);
}
}
}
}

0 comments on commit 92127a0

Please sign in to comment.