Skip to main content

query_ollama

Function query_ollama 

Source
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

§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 { .. }));