pub fn query_ollama(
endpoint: &str,
model: &str,
prompt: &str,
timeout_secs: u64,
) -> Result<String, SsgError>Expand description
Typed Ollama generation call backed by ureq (issue #520).
All HTTP traffic flows through ureq::post(...).send_json(...)
— no subprocess is spawned, so prompts containing shell
metacharacters ($(, backticks, ;, &, |) traverse the
transport as a JSON body byte-for-byte unchanged (AC3).
§Errors
SsgError::LlmTimeoutwhen the call exceedstimeout_secs.SsgError::LlmEndpointUnreachablewhen the TCP connection is refused, the host is unresolvable, or any other transport failure occurs before a response is received.SsgError::LlmInvalidResponsewhen the server returns a non-2xx status, the body is not valid JSON, or the JSON does not carry a non-emptyresponsefield.
§Examples
use ssg::llm::query_ollama;
use ssg::SsgError;
// No Ollama running on port 1 ⇒ deterministic transport failure.
let err = query_ollama("http://127.0.0.1:1", "llama2", "hi", 1).unwrap_err();
assert!(matches!(err, SsgError::LlmEndpointUnreachable { .. } | SsgError::LlmTimeout { .. }));