diff --git a/src/clients/ollama_client.py b/src/clients/ollama_client.py index b5169aa..aaa4457 100644 --- a/src/clients/ollama_client.py +++ b/src/clients/ollama_client.py @@ -249,7 +249,8 @@ class OllamaClient: self, prompt: str, model: Optional[str] = None, - stream: bool = False + stream: bool = False, + temperature: Optional[float] = None ) -> Optional[str]: """ Generate text completion (for non-embedding use cases). @@ -258,12 +259,15 @@ class OllamaClient: prompt: Input prompt model: Model name (defaults to self.model) stream: Enable streaming response + temperature: Sampling temperature (0.0 = deterministic, higher = more creative) + None uses model default (~0.7 for mistral-nemo) Returns: Generated text or None on failure - Note: This is primarily for debugging/testing. Use specialized - LLM services for production text generation. + Note: Use temperature=0.0 for deterministic outputs like JSON parsing, + ranking, and factual extraction. Use higher values (0.3-0.7) for + creative content generation. """ try: payload = { @@ -272,6 +276,10 @@ class OllamaClient: "stream": stream } + # Add temperature to options if specified + if temperature is not None: + payload["options"] = {"temperature": temperature} + response = await self.client.post( self.generate_url, json=payload