download.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <string>
  3. struct common_params_model;
  4. //
  5. // download functionalities
  6. //
  7. struct common_hf_file_res {
  8. std::string repo; // repo name with ":tag" removed
  9. std::string ggufFile;
  10. std::string mmprojFile;
  11. };
  12. // resolve and download model from Docker registry
  13. // return local path to downloaded model file
  14. std::string common_docker_resolve_model(const std::string & docker);
  15. /**
  16. * Allow getting the HF file from the HF repo with tag (like ollama), for example:
  17. * - bartowski/Llama-3.2-3B-Instruct-GGUF:q4
  18. * - bartowski/Llama-3.2-3B-Instruct-GGUF:Q4_K_M
  19. * - bartowski/Llama-3.2-3B-Instruct-GGUF:q5_k_s
  20. * Tag is optional, default to "latest" (meaning it checks for Q4_K_M first, then Q4, then if not found, return the first GGUF file in repo)
  21. *
  22. * Return pair of <repo, file> (with "repo" already having tag removed)
  23. *
  24. * Note: we use the Ollama-compatible HF API, but not using the blobId. Instead, we use the special "ggufFile" field which returns the value for "hf_file". This is done to be backward-compatible with existing cache files.
  25. */
  26. common_hf_file_res common_get_hf_file(
  27. const std::string & hf_repo_with_tag,
  28. const std::string & bearer_token,
  29. bool offline);
  30. // returns true if download succeeded
  31. bool common_download_model(
  32. const common_params_model & model,
  33. const std::string & bearer_token,
  34. bool offline);