finished initial impl of /show and tested -> hangs!

This commit is contained in:
Jared Van Bortel 2025-02-26 20:01:58 -05:00
parent 7ce2ea57e0
commit d4e9a6177b
4 changed files with 33 additions and 10 deletions

View File

@ -36,7 +36,15 @@ static void run()
for (const auto & model : modelsResponse->models)
fmt::print("{}\n", model.model);
} else {
fmt::print("Error retrieving version: {}\n", modelsResponse.error().errorString);
fmt::print("Error retrieving available models: {}\n", modelsResponse.error().errorString);
return QCoreApplication::exit(1);
}
auto showResponse = QCoro::waitFor(provider.showModelInfo({ .model = "DeepSeek-R1-Distill-Llama-70B-Q4_K_S" }));
if (showResponse) {
fmt::print("Model family: {}\n", showResponse->details.family);
} else {
fmt::print("Error retrieving model info: {}\n", showResponse.error().errorString);
return QCoreApplication::exit(1);
}

View File

@ -92,4 +92,7 @@ private:
extern template auto OllamaClient::get(const QString &) -> QCoro::Task<DataOrRespErr<ollama::VersionResponse>>;
extern template auto OllamaClient::get(const QString &) -> QCoro::Task<DataOrRespErr<ollama::ModelsResponse>>;
extern template auto OllamaClient::post(const QString &, const ollama::ModelInfoRequest &)
-> QCoro::Task<DataOrRespErr<ollama::ModelInfo>>;
} // namespace gpt4all::backend

View File

@ -14,6 +14,10 @@
namespace gpt4all::backend::ollama {
//
// basic types
//
/// Details about a model.
struct ModelDetails {
QString parent_model; /// The parent of the model.
@ -39,15 +43,6 @@ struct Model {
BOOST_DESCRIBE_STRUCT(Model, (), (model, modified_at, size, digest, details))
#endif
/// Request class for the show model info endpoint.
struct ModelInfoRequest {
QString model; /// The model name.
};
#ifdef G4A_BACKEND_IMPL
BOOST_DESCRIBE_STRUCT(ModelInfoRequest, (), (model))
#endif
enum MessageRole {
system,
user,
@ -84,6 +79,21 @@ struct Message {
BOOST_DESCRIBE_STRUCT(Message, (), (role, content, images, tool_calls))
#endif
//
// request types
//
/// Request class for the show model info endpoint.
struct ModelInfoRequest {
QString model; /// The model name.
};
#ifdef G4A_BACKEND_IMPL
BOOST_DESCRIBE_STRUCT(ModelInfoRequest, (), (model))
#endif
//
// response types
//
/// The response class for the version endpoint.
struct VersionResponse {

View File

@ -74,6 +74,8 @@ auto OllamaClient::post(const QString &path, const Req &req) -> QCoro::Task<Data
co_return std::unexpected(value.error());
}
template auto OllamaClient::post(const QString &, const ModelInfoRequest &) -> QCoro::Task<DataOrRespErr<ModelInfo>>;
auto OllamaClient::getJson(const QString &path) -> QCoro::Task<DataOrRespErr<json::value>>
{
std::unique_ptr<QNetworkReply> reply(m_nam.get(makeRequest(path)));