Skip to content

ollama_factory

Module for creating an Ollama factory.

OllamaFactory

Bases: OpenAIFactory

An Ollama factory.

Source code in spark_instructor/factory/ollama_factory.py
class OllamaFactory(OpenAIFactory):
    """An Ollama factory."""

    @classmethod
    def from_config(
        cls,
        mode: Optional[instructor.Mode] = None,
        base_url: Optional[str] = None,
        api_key: Optional[str] = None,
        **kwargs
    ) -> "OllamaFactory":
        """Create an Ollama factory from custom entries."""
        return cls(get_ollama_aclient(mode or instructor.Mode.JSON, base_url, api_key))

from_config(mode=None, base_url=None, api_key=None, **kwargs) classmethod

Create an Ollama factory from custom entries.

Source code in spark_instructor/factory/ollama_factory.py
@classmethod
def from_config(
    cls,
    mode: Optional[instructor.Mode] = None,
    base_url: Optional[str] = None,
    api_key: Optional[str] = None,
    **kwargs
) -> "OllamaFactory":
    """Create an Ollama factory from custom entries."""
    return cls(get_ollama_aclient(mode or instructor.Mode.JSON, base_url, api_key))