From c45abee57e9aa9aa2bff8a7ce6dd764014168a93 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Sun, 28 Apr 2024 10:58:39 +0200 Subject: [PATCH 1/5] initial add Ollama --- spacy_llm/models/rest/__init__.py | 3 +- spacy_llm/models/rest/ollama/__init__.py | 8 +++ spacy_llm/models/rest/ollama/model.py | 80 ++++++++++++++++++++++++ spacy_llm/models/rest/ollama/registry.py | 39 ++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 spacy_llm/models/rest/ollama/__init__.py create mode 100644 spacy_llm/models/rest/ollama/model.py create mode 100644 spacy_llm/models/rest/ollama/registry.py diff --git a/spacy_llm/models/rest/__init__.py b/spacy_llm/models/rest/__init__.py index 96263967..64082b5c 100644 --- a/spacy_llm/models/rest/__init__.py +++ b/spacy_llm/models/rest/__init__.py @@ -1,4 +1,4 @@ -from . import anthropic, azure, base, cohere, noop, openai +from . import anthropic, azure, base, cohere, noop, openai, ollama __all__ = [ "anthropic", @@ -7,4 +7,5 @@ "cohere", "openai", "noop", + "ollama", ] diff --git a/spacy_llm/models/rest/ollama/__init__.py b/spacy_llm/models/rest/ollama/__init__.py new file mode 100644 index 00000000..7926fff4 --- /dev/null +++ b/spacy_llm/models/rest/ollama/__init__.py @@ -0,0 +1,8 @@ +from .model import Endpoints, Ollama +from .registry import ollama_mistral + +__all__ = [ + "Ollama", + "Endpoints", + "ollama_mistral" +] diff --git a/spacy_llm/models/rest/ollama/model.py b/spacy_llm/models/rest/ollama/model.py new file mode 100644 index 00000000..b7a18543 --- /dev/null +++ b/spacy_llm/models/rest/ollama/model.py @@ -0,0 +1,80 @@ +import os +import warnings +from enum import Enum +from typing import Any, Dict, Iterable, List, Sized + +import requests # type: ignore[import] +import srsly # type: ignore[import] +from requests import HTTPError + +from ..base import REST + + +class Endpoints(str, Enum): + GENERATE = "http://localhost:11434/api/generate" + EMBEDDINGS = "http://localhost:11434/api/embeddings" + +class Ollama(REST): + @property + def credentials(self) -> Dict[str, str]: + # No credentials needed for local Ollama server + return {} + + def _verify_auth(self) -> None: + # TODO: Verify connectivity to Ollama server + pass + + def __call__(self, prompts: Iterable[Iterable[str]]) -> Iterable[Iterable[str]]: + headers = { + "Content-Type": "application/json", + } + all_api_responses: List[List[str]] = [] + + for prompts_for_doc in prompts: + api_responses: List[str] = [] + prompts_for_doc = list(prompts_for_doc) + + def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: + r = self.retry( + call_method=requests.post, + url=self._endpoint, + headers=headers, + json={**json_data, **self._config, "model": self._name, "stream": False}, + timeout=self._max_request_time, + ) + try: + r.raise_for_status() + except HTTPError as ex: + res_content = r.text + # Include specific error message in exception. + raise ValueError( + f"Request to Ollama API failed: {res_content}" + ) from ex + + response = r.json() + + if "error" in response: + if self._strict: + raise ValueError(f"API call failed: {response['error']}.") + else: + assert isinstance(prompts_for_doc, Sized) + return {"error": [response['error']] * len(prompts_for_doc)} + + return response + + for prompt in prompts_for_doc: + responses = _request({"prompt": prompt}) + if "error" in responses: + return responses["error"] + + api_responses.append(responses["response"]) + + all_api_responses.append(api_responses) + + return all_api_responses + + @staticmethod + def _get_context_lengths() -> Dict[str, int]: + return { + "mistral": 4096 + } diff --git a/spacy_llm/models/rest/ollama/registry.py b/spacy_llm/models/rest/ollama/registry.py new file mode 100644 index 00000000..89f228e8 --- /dev/null +++ b/spacy_llm/models/rest/ollama/registry.py @@ -0,0 +1,39 @@ +from typing import Any, Dict + +from confection import SimpleFrozenDict + +from ....registry import registry +from .model import Endpoints, Ollama + +@registry.llm_models("spacy.Ollama.v1") +def ollama_mistral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'mistral' model. + + config (Dict[Any, Any]): LLM config passed on to the model's initialization. + name (str): Model name to use. Defaults to 'mistral'. + strict (bool): Whether to raise exception on API errors. Defaults to Ollama.DEFAULT_STRICT. + max_tries (int): Max number of API request retries. Defaults to Ollama.DEFAULT_MAX_TRIES. + interval (float): Retry interval in seconds. Defaults to Ollama.DEFAULT_INTERVAL. + max_request_time (float): Max API request time in seconds. Defaults to Ollama.DEFAULT_MAX_REQUEST_TIME. + context_length (int): Max context length. Defaults to 4096. + + RETURNS (Ollama): Ollama instance for 'mistral' model + """ + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) From d0043c2cc3336a49b8c36ebcc5a232a6df26dfd6 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Sun, 28 Apr 2024 11:34:47 +0200 Subject: [PATCH 2/5] add remaining models --- spacy_llm/models/rest/ollama/model.py | 93 +- spacy_llm/models/rest/ollama/registry.py | 1771 +++++++++++++++++++++- 2 files changed, 1850 insertions(+), 14 deletions(-) diff --git a/spacy_llm/models/rest/ollama/model.py b/spacy_llm/models/rest/ollama/model.py index b7a18543..c0337d42 100644 --- a/spacy_llm/models/rest/ollama/model.py +++ b/spacy_llm/models/rest/ollama/model.py @@ -13,6 +13,7 @@ class Endpoints(str, Enum): GENERATE = "http://localhost:11434/api/generate" EMBEDDINGS = "http://localhost:11434/api/embeddings" + TAGS = "http://localhost:11434/api/tags" class Ollama(REST): @property @@ -21,8 +22,14 @@ def credentials(self) -> Dict[str, str]: return {} def _verify_auth(self) -> None: - # TODO: Verify connectivity to Ollama server - pass + # Healthcheck: Verify connectivity to Ollama server + try: + r = requests.get(Endpoints.TAGS.value, timeout=5) + r.raise_for_status() + except (requests.exceptions.RequestException, HTTPError) as ex: + raise ValueError( + "Failed to connect to the Ollama server. Please ensure that the server is up and running." + ) from ex def __call__(self, prompts: Iterable[Iterable[str]]) -> Iterable[Iterable[str]]: headers = { @@ -76,5 +83,85 @@ def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: @staticmethod def _get_context_lengths() -> Dict[str, int]: return { - "mistral": 4096 + "llama3": 4096, + "phi3": 4096, + "wizardlm2": 4096, + "mistral": 4096, + "gemma": 4096, + "mixtral": 47000, + "llama2": 4096, + "codegemma": 4096, + "command-r": 35000, + "command-r-plus": 35000, + "llava": 4096, + "dbrx": 4096, + "codellama": 4096, + "qwen": 4096, + "dolphin-mixtral": 47000, + "llama2-uncensored": 4096, + "mistral-openorca": 4096, + "deepseek-coder": 4096, + "phi": 4096, + "dolphin-mistral": 47000, + "nomic-embed-text": 4096, + "nous-hermes2": 4096, + "orca-mini": 4096, + "llama2-chinese": 4096, + "zephyr": 4096, + "wizard-vicuna-uncensored": 4096, + "openhermes": 4096, + "vicuna": 4096, + "tinyllama": 4096, + "tinydolphin": 4096, + "openchat": 4096, + "starcoder2": 4096, + "wizardcoder": 4096, + "stable-code": 4096, + "starcoder": 4096, + "neural-chat": 4096, + "yi": 4096, + "phind-codellama": 4096, + "starling-lm": 4096, + "wizard-math": 4096, + "falcon": 4096, + "dolphin-phi": 4096, + "orca2": 4096, + "dolphincoder": 4096, + "mxbai-embed-large": 4096, + "nous-hermes": 4096, + "solar": 4096, + "bakllava": 4096, + "sqlcoder": 4096, + "medllama2": 4096, + "nous-hermes2-mixtral": 47000, + "wizardlm-uncensored": 4096, + "dolphin-llama3": 4096, + "codeup": 4096, + "stablelm2": 4096, + "everythinglm": 16384, + "all-minilm": 4096, + "samantha-mistral": 4096, + "yarn-mistral": 128000, + "stable-beluga": 4096, + "meditron": 4096, + "yarn-llama2": 128000, + "deepseek-llm": 4096, + "llama-pro": 4096, + "magicoder": 4096, + "stablelm-zephyr": 4096, + "codebooga": 4096, + "codeqwen": 4096, + "mistrallite": 8192, + "wizard-vicuna": 4096, + "nexusraven": 4096, + "xwinlm": 4096, + "goliath": 4096, + "open-orca-platypus2": 4096, + "wizardlm": 4096, + "notux": 4096, + "megadolphin": 4096, + "duckdb-nsql": 4096, + "alfred": 4096, + "notus": 4096, + "snowflake-arctic-embed": 4096 } diff --git a/spacy_llm/models/rest/ollama/registry.py b/spacy_llm/models/rest/ollama/registry.py index 89f228e8..c01d73ba 100644 --- a/spacy_llm/models/rest/ollama/registry.py +++ b/spacy_llm/models/rest/ollama/registry.py @@ -5,6 +5,72 @@ from ....registry import registry from .model import Endpoints, Ollama +@registry.llm_models("spacy.Ollama.v1") +def ollama_llama3( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama3", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llama3' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_phi3( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "phi3", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'phi3' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizardlm2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardlm2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizardlm2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mistral( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -15,18 +81,227 @@ def ollama_mistral( max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, context_length: int = 4096 ) -> Ollama: - """Returns Ollama instance for 'mistral' model. - - config (Dict[Any, Any]): LLM config passed on to the model's initialization. - name (str): Model name to use. Defaults to 'mistral'. - strict (bool): Whether to raise exception on API errors. Defaults to Ollama.DEFAULT_STRICT. - max_tries (int): Max number of API request retries. Defaults to Ollama.DEFAULT_MAX_TRIES. - interval (float): Retry interval in seconds. Defaults to Ollama.DEFAULT_INTERVAL. - max_request_time (float): Max API request time in seconds. Defaults to Ollama.DEFAULT_MAX_REQUEST_TIME. - context_length (int): Max context length. Defaults to 4096. + """Returns Ollama instance for 'mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_gemma( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "gemma", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'gemma' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_mixtral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mixtral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 47000 +) -> Ollama: + """Returns Ollama instance for 'mixtral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_llama2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llama2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_codegemma( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codegemma", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'codegemma' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_command_r( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "command-r", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 35000 +) -> Ollama: + """Returns Ollama instance for 'command-r' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_command_r_plus( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "command-r-plus", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 35000 +) -> Ollama: + """Returns Ollama instance for 'command-r-plus' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_llava( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llava", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llava' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dbrx( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dbrx", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'dbrx' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_codellama( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codellama", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'codellama' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) - RETURNS (Ollama): Ollama instance for 'mistral' model - """ +@registry.llm_models("spacy.Ollama.v1") +def ollama_qwen( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "qwen", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'qwen' model.""" return Ollama( name=name, endpoint=Endpoints.GENERATE.value, @@ -37,3 +312,1477 @@ def ollama_mistral( max_request_time=max_request_time, context_length=context_length ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dolphin_mixtral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-mixtral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 47000 +) -> Ollama: + """Returns Ollama instance for 'dolphin-mixtral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_llama2_uncensored( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama2-uncensored", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llama2-uncensored' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_mistral_openorca( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mistral-openorca", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'mistral-openorca' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_deepseek_coder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "deepseek-coder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'deepseek-coder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_phi( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "phi", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'phi' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dolphin_mistral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 47000 +) -> Ollama: + """Returns Ollama instance for 'dolphin-mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_nomic_embed_text( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nomic-embed-text", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'nomic-embed-text' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length +) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_nous_hermes2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'nous-hermes2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_orca_mini( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "orca-mini", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'orca-mini' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_llama2_chinese( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama2-chinese", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llama2-chinese' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_zephyr( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "zephyr", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'zephyr' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizard_vicuna_uncensored( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-vicuna-uncensored", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizard-vicuna-uncensored' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_openhermes( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "openhermes", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'openhermes' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_vicuna( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "vicuna", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'vicuna' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_tinyllama( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "tinyllama", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'tinyllama' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_tinydolphin( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "tinydolphin", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'tinydolphin' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_openchat( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "openchat", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'openchat' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_starcoder2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starcoder2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'starcoder2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizardcoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizardcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_stable_code( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stable-code", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'stable-code' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_starcoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'starcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_neural_chat( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "neural-chat", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'neural-chat' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_yi( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yi", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'yi' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_phind_codellama( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "phind-codellama", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'phind-codellama' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_starling_lm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starling-lm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'starling-lm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizard_math( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-math", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizard-math' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_falcon( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "falcon", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'falcon' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dolphin_phi( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-phi", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'dolphin-phi' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_orca2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "orca2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'orca2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dolphincoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphincoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'dolphincoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_mxbai_embed_large( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mxbai-embed-large", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'mxbai-embed-large' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_nous_hermes( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'nous-hermes' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_solar( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "solar", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'solar' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_bakllava( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "bakllava", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'bakllava' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_sqlcoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "sqlcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'sqlcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_medllama2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "medllama2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'medllama2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_nous_hermes2_mixtral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes2-mixtral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 47000 +) -> Ollama: + """Returns Ollama instance for 'nous-hermes2-mixtral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizardlm_uncensored( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardlm-uncensored", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizardlm-uncensored' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_dolphin_llama3( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-llama3", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'dolphin-llama3' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_codeup( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codeup", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'codeup' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_stablelm2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stablelm2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'stablelm2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_everythinglm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "everythinglm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 16384 +) -> Ollama: + """Returns Ollama instance for 'everythinglm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_all_minilm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "all-minilm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'all-minilm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_samantha_mistral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "samantha-mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'samantha-mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_yarn_mistral( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yarn-mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 128000 +) -> Ollama: + """Returns Ollama instance for 'yarn-mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_stable_beluga( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stable-beluga", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'stable-beluga' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_meditron( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "meditron", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'meditron' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_yarn_llama2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yarn-llama2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 128000 +) -> Ollama: + """Returns Ollama instance for 'yarn-llama2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_deepseek_llm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "deepseek-llm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'deepseek-llm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_llama_pro( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama-pro", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'llama-pro' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_magicoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "magicoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'magicoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_stablelm_zephyr( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stablelm-zephyr", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'stablelm-zephyr' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_codebooga( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codebooga", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'codebooga' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_codeqwen( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codeqwen", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'codeqwen' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_mistrallite( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mistrallite", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 8192 +) -> Ollama: + """Returns Ollama instance for 'mistrallite' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizard_vicuna( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-vicuna", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizard-vicuna' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_nexusraven( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nexusraven", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'nexusraven' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_xwinlm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "xwinlm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'xwinlm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_goliath( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "goliath", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'goliath' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_open_orca_platypus2( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "open-orca-platypus2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'open-orca-platypus2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_wizardlm( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardlm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'wizardlm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_notux( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "notux", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'notux' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_megadolphin( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "megadolphin", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'megadolphin' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_duckdb_nsql( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "duckdb-nsql", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'duckdb-nsql' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_alfred( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "alfred", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'alfred' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_notus( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "notus", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'notus' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) + +@registry.llm_models("spacy.Ollama.v1") +def ollama_snowflake_arctic_embed( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "snowflake-arctic-embed", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096 +) -> Ollama: + """Returns Ollama instance for 'snowflake-arctic-embed' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length + ) From 8436574353960a6dd2b195b2c51b24a1b03a4cef Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Sun, 28 Apr 2024 11:39:45 +0200 Subject: [PATCH 3/5] alphabetical is nicer --- spacy_llm/models/rest/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/models/rest/__init__.py b/spacy_llm/models/rest/__init__.py index 64082b5c..cf430bec 100644 --- a/spacy_llm/models/rest/__init__.py +++ b/spacy_llm/models/rest/__init__.py @@ -5,7 +5,7 @@ "azure", "base", "cohere", + "ollama", "openai", "noop", - "ollama", ] From 8893541b3c95e0e4b636624ca327a97d99d02940 Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Sun, 28 Apr 2024 11:54:15 +0200 Subject: [PATCH 4/5] update init file with all models --- spacy_llm/models/rest/ollama/__init__.py | 168 ++++++++++++++++++++++- 1 file changed, 165 insertions(+), 3 deletions(-) diff --git a/spacy_llm/models/rest/ollama/__init__.py b/spacy_llm/models/rest/ollama/__init__.py index 7926fff4..18aa3fc4 100644 --- a/spacy_llm/models/rest/ollama/__init__.py +++ b/spacy_llm/models/rest/ollama/__init__.py @@ -1,8 +1,170 @@ from .model import Endpoints, Ollama -from .registry import ollama_mistral +from .registry import ( + ollama_llama3, + ollama_phi3, + ollama_wizardlm2, + ollama_mistral, + ollama_gemma, + ollama_mixtral, + ollama_llama2, + ollama_codegemma, + ollama_command_r, + ollama_command_r_plus, + ollama_llava, + ollama_dbrx, + ollama_codellama, + ollama_qwen, + ollama_dolphin_mixtral, + ollama_llama2_uncensored, + ollama_mistral_openorca, + ollama_deepseek_coder, + ollama_phi, + ollama_dolphin_mistral, + ollama_nomic_embed_text, + ollama_nous_hermes2, + ollama_orca_mini, + ollama_llama2_chinese, + ollama_zephyr, + ollama_wizard_vicuna_uncensored, + ollama_openhermes, + ollama_vicuna, + ollama_tinyllama, + ollama_tinydolphin, + ollama_openchat, + ollama_starcoder2, + ollama_wizardcoder, + ollama_stable_code, + ollama_starcoder, + ollama_neural_chat, + ollama_yi, + ollama_phind_codellama, + ollama_starling_lm, + ollama_wizard_math, + ollama_falcon, + ollama_dolphin_phi, + ollama_orca2, + ollama_dolphincoder, + ollama_mxbai_embed_large, + ollama_nous_hermes, + ollama_solar, + ollama_bakllava, + ollama_sqlcoder, + ollama_medllama2, + ollama_nous_hermes2_mixtral, + ollama_wizardlm_uncensored, + ollama_dolphin_llama3, + ollama_codeup, + ollama_stablelm2, + ollama_everythinglm, + ollama_all_minilm, + ollama_samantha_mistral, + ollama_yarn_mistral, + ollama_stable_beluga, + ollama_meditron, + ollama_yarn_llama2, + ollama_deepseek_llm, + ollama_llama_pro, + ollama_magicoder, + ollama_stablelm_zephyr, + ollama_codebooga, + ollama_codeqwen, + ollama_mistrallite, + ollama_wizard_vicuna, + ollama_nexusraven, + ollama_xwinlm, + ollama_goliath, + ollama_open_orca_platypus2, + ollama_wizardlm, + ollama_notux, + ollama_megadolphin, + ollama_duckdb_nsql, + ollama_alfred, + ollama_notus, + ollama_snowflake_arctic_embed, +) __all__ = [ "Ollama", - "Endpoints", - "ollama_mistral" + "Endpoints", + "ollama_llama3", + "ollama_phi3", + "ollama_wizardlm2", + "ollama_mistral", + "ollama_gemma", + "ollama_mixtral", + "ollama_llama2", + "ollama_codegemma", + "ollama_command_r", + "ollama_command_r_plus", + "ollama_llava", + "ollama_dbrx", + "ollama_codellama", + "ollama_qwen", + "ollama_dolphin_mixtral", + "ollama_llama2_uncensored", + "ollama_mistral_openorca", + "ollama_deepseek_coder", + "ollama_phi", + "ollama_dolphin_mistral", + "ollama_nomic_embed_text", + "ollama_nous_hermes2", + "ollama_orca_mini", + "ollama_llama2_chinese", + "ollama_zephyr", + "ollama_wizard_vicuna_uncensored", + "ollama_openhermes", + "ollama_vicuna", + "ollama_tinyllama", + "ollama_tinydolphin", + "ollama_openchat", + "ollama_starcoder2", + "ollama_wizardcoder", + "ollama_stable_code", + "ollama_starcoder", + "ollama_neural_chat", + "ollama_yi", + "ollama_phind_codellama", + "ollama_starling_lm", + "ollama_wizard_math", + "ollama_falcon", + "ollama_dolphin_phi", + "ollama_orca2", + "ollama_dolphincoder", + "ollama_mxbai_embed_large", + "ollama_nous_hermes", + "ollama_solar", + "ollama_bakllava", + "ollama_sqlcoder", + "ollama_medllama2", + "ollama_nous_hermes2_mixtral", + "ollama_wizardlm_uncensored", + "ollama_dolphin_llama3", + "ollama_codeup", + "ollama_stablelm2", + "ollama_everythinglm", + "ollama_all_minilm", + "ollama_samantha_mistral", + "ollama_yarn_mistral", + "ollama_stable_beluga", + "ollama_meditron", + "ollama_yarn_llama2", + "ollama_deepseek_llm", + "ollama_llama_pro", + "ollama_magicoder", + "ollama_stablelm_zephyr", + "ollama_codebooga", + "ollama_codeqwen", + "ollama_mistrallite", + "ollama_wizard_vicuna", + "ollama_nexusraven", + "ollama_xwinlm", + "ollama_goliath", + "ollama_open_orca_platypus2", + "ollama_wizardlm", + "ollama_notux", + "ollama_megadolphin", + "ollama_duckdb_nsql", + "ollama_alfred", + "ollama_notus", + "ollama_snowflake_arctic_embed", ] From 3be142fa8df3ddbd57fbf8d065584653e60a395e Mon Sep 17 00:00:00 2001 From: Alex Strick van Linschoten Date: Thu, 2 May 2024 15:09:45 +0200 Subject: [PATCH 5/5] ruff and black fixes --- spacy_llm/models/langchain/model.py | 10 +- spacy_llm/models/rest/ollama/model.py | 19 +- spacy_llm/models/rest/ollama/registry.py | 2531 +++++++++++----------- spacy_llm/models/rest/openai/registry.py | 27 +- spacy_llm/models/rest/palm/model.py | 8 +- spacy_llm/models/rest/palm/registry.py | 6 +- 6 files changed, 1347 insertions(+), 1254 deletions(-) diff --git a/spacy_llm/models/langchain/model.py b/spacy_llm/models/langchain/model.py index c940da6a..3a0606c2 100644 --- a/spacy_llm/models/langchain/model.py +++ b/spacy_llm/models/langchain/model.py @@ -172,12 +172,10 @@ def register_models() -> None: @registry.llm_queries("spacy.CallLangChain.v1") -def query_langchain() -> ( - Callable[ - ["langchain_community.llms.BaseLLM", Iterable[Iterable[Any]]], - Iterable[Iterable[Any]], - ] -): +def query_langchain() -> Callable[ + ["langchain_community.llms.BaseLLM", Iterable[Iterable[Any]]], + Iterable[Iterable[Any]], +]: """Returns query Callable for LangChain. RETURNS (Callable[["langchain_community.llms.BaseLLM", Iterable[Iterable[Any]]], Iterable[Iterable[Any]]]): Callable executing simple prompts on the specified LangChain model. diff --git a/spacy_llm/models/rest/ollama/model.py b/spacy_llm/models/rest/ollama/model.py index c0337d42..06e19813 100644 --- a/spacy_llm/models/rest/ollama/model.py +++ b/spacy_llm/models/rest/ollama/model.py @@ -1,10 +1,7 @@ -import os -import warnings from enum import Enum from typing import Any, Dict, Iterable, List, Sized import requests # type: ignore[import] -import srsly # type: ignore[import] from requests import HTTPError from ..base import REST @@ -15,12 +12,13 @@ class Endpoints(str, Enum): EMBEDDINGS = "http://localhost:11434/api/embeddings" TAGS = "http://localhost:11434/api/tags" + class Ollama(REST): @property def credentials(self) -> Dict[str, str]: # No credentials needed for local Ollama server return {} - + def _verify_auth(self) -> None: # Healthcheck: Verify connectivity to Ollama server try: @@ -46,7 +44,12 @@ def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: call_method=requests.post, url=self._endpoint, headers=headers, - json={**json_data, **self._config, "model": self._name, "stream": False}, + json={ + **json_data, + **self._config, + "model": self._name, + "stream": False, + }, timeout=self._max_request_time, ) try: @@ -57,7 +60,7 @@ def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: raise ValueError( f"Request to Ollama API failed: {res_content}" ) from ex - + response = r.json() if "error" in response: @@ -65,7 +68,7 @@ def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: raise ValueError(f"API call failed: {response['error']}.") else: assert isinstance(prompts_for_doc, Sized) - return {"error": [response['error']] * len(prompts_for_doc)} + return {"error": [response["error"]] * len(prompts_for_doc)} return response @@ -163,5 +166,5 @@ def _get_context_lengths() -> Dict[str, int]: "duckdb-nsql": 4096, "alfred": 4096, "notus": 4096, - "snowflake-arctic-embed": 4096 + "snowflake-arctic-embed": 4096, } diff --git a/spacy_llm/models/rest/ollama/registry.py b/spacy_llm/models/rest/ollama/registry.py index c01d73ba..2c52da66 100644 --- a/spacy_llm/models/rest/ollama/registry.py +++ b/spacy_llm/models/rest/ollama/registry.py @@ -5,6 +5,7 @@ from ....registry import registry from .model import Endpoints, Ollama + @registry.llm_models("spacy.Ollama.v1") def ollama_llama3( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -13,7 +14,7 @@ def ollama_llama3( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'llama3' model.""" return Ollama( @@ -24,9 +25,10 @@ def ollama_llama3( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_phi3( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -35,7 +37,7 @@ def ollama_phi3( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'phi3' model.""" return Ollama( @@ -46,9 +48,10 @@ def ollama_phi3( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizardlm2( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -57,7 +60,7 @@ def ollama_wizardlm2( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'wizardlm2' model.""" return Ollama( @@ -68,9 +71,10 @@ def ollama_wizardlm2( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mistral( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -79,7 +83,7 @@ def ollama_mistral( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'mistral' model.""" return Ollama( @@ -90,9 +94,10 @@ def ollama_mistral( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_gemma( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -101,7 +106,7 @@ def ollama_gemma( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'gemma' model.""" return Ollama( @@ -112,9 +117,10 @@ def ollama_gemma( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mixtral( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -123,7 +129,7 @@ def ollama_mixtral( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 47000 + context_length: int = 47000, ) -> Ollama: """Returns Ollama instance for 'mixtral' model.""" return Ollama( @@ -134,9 +140,10 @@ def ollama_mixtral( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_llama2( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -145,7 +152,7 @@ def ollama_llama2( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'llama2' model.""" return Ollama( @@ -156,9 +163,10 @@ def ollama_llama2( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_codegemma( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -167,7 +175,7 @@ def ollama_codegemma( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'codegemma' model.""" return Ollama( @@ -178,9 +186,10 @@ def ollama_codegemma( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_command_r( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -189,7 +198,7 @@ def ollama_command_r( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 35000 + context_length: int = 35000, ) -> Ollama: """Returns Ollama instance for 'command-r' model.""" return Ollama( @@ -200,9 +209,10 @@ def ollama_command_r( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_command_r_plus( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -211,7 +221,7 @@ def ollama_command_r_plus( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 35000 + context_length: int = 35000, ) -> Ollama: """Returns Ollama instance for 'command-r-plus' model.""" return Ollama( @@ -222,9 +232,10 @@ def ollama_command_r_plus( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_llava( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -233,7 +244,7 @@ def ollama_llava( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'llava' model.""" return Ollama( @@ -244,9 +255,10 @@ def ollama_llava( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dbrx( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -255,7 +267,7 @@ def ollama_dbrx( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'dbrx' model.""" return Ollama( @@ -266,9 +278,10 @@ def ollama_dbrx( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_codellama( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -277,7 +290,7 @@ def ollama_codellama( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'codellama' model.""" return Ollama( @@ -288,9 +301,10 @@ def ollama_codellama( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_qwen( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -299,7 +313,7 @@ def ollama_qwen( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'qwen' model.""" return Ollama( @@ -310,9 +324,10 @@ def ollama_qwen( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dolphin_mixtral( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -321,7 +336,7 @@ def ollama_dolphin_mixtral( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 47000 + context_length: int = 47000, ) -> Ollama: """Returns Ollama instance for 'dolphin-mixtral' model.""" return Ollama( @@ -332,9 +347,10 @@ def ollama_dolphin_mixtral( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_llama2_uncensored( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -343,7 +359,7 @@ def ollama_llama2_uncensored( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'llama2-uncensored' model.""" return Ollama( @@ -354,9 +370,10 @@ def ollama_llama2_uncensored( max_tries=max_tries, interval=interval, max_request_time=max_request_time, - context_length=context_length + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mistral_openorca( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -365,20 +382,21 @@ def ollama_mistral_openorca( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'mistral-openorca' model.""" return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_deepseek_coder( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -387,20 +405,21 @@ def ollama_deepseek_coder( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'deepseek-coder' model.""" return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_phi( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -409,20 +428,21 @@ def ollama_phi( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'phi' model.""" return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dolphin_mistral( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -431,20 +451,21 @@ def ollama_dolphin_mistral( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 47000 + context_length: int = 47000, ) -> Ollama: """Returns Ollama instance for 'dolphin-mistral' model.""" return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, ) + @registry.llm_models("spacy.Ollama.v1") def ollama_nomic_embed_text( config: Dict[Any, Any] = SimpleFrozenDict(), @@ -453,1336 +474,1396 @@ def ollama_nomic_embed_text( max_tries: int = Ollama.DEFAULT_MAX_TRIES, interval: float = Ollama.DEFAULT_INTERVAL, max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 + context_length: int = 4096, ) -> Ollama: """Returns Ollama instance for 'nomic-embed-text' model.""" return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length -) + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_nous_hermes2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "nous-hermes2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'nous-hermes2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'nous-hermes2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_orca_mini( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "orca-mini", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'orca-mini' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "orca-mini", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'orca-mini' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_llama2_chinese( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "llama2-chinese", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'llama2-chinese' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama2-chinese", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'llama2-chinese' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_zephyr( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "zephyr", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'zephyr' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "zephyr", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'zephyr' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizard_vicuna_uncensored( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizard-vicuna-uncensored", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizard-vicuna-uncensored' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-vicuna-uncensored", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizard-vicuna-uncensored' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_openhermes( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "openhermes", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'openhermes' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "openhermes", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'openhermes' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_vicuna( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "vicuna", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'vicuna' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "vicuna", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'vicuna' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_tinyllama( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "tinyllama", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'tinyllama' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "tinyllama", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'tinyllama' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_tinydolphin( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "tinydolphin", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'tinydolphin' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "tinydolphin", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'tinydolphin' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_openchat( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "openchat", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'openchat' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "openchat", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'openchat' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_starcoder2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "starcoder2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'starcoder2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starcoder2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'starcoder2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) -@registry.llm_models("spacy.Ollama.v1") -def ollama_wizardcoder( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizardcoder", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizardcoder' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) @registry.llm_models("spacy.Ollama.v1") -def ollama_stable_code( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "stable-code", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'stable-code' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) +def ollama_wizardcoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizardcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) -@registry.llm_models("spacy.Ollama.v1") -def ollama_starcoder( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "starcoder", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'starcoder' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) @registry.llm_models("spacy.Ollama.v1") -def ollama_neural_chat( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "neural-chat", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'neural-chat' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) - +def ollama_stable_code( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stable-code", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'stable-code' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + + +@registry.llm_models("spacy.Ollama.v1") +def ollama_starcoder( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'starcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + + +@registry.llm_models("spacy.Ollama.v1") +def ollama_neural_chat( + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "neural-chat", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'neural-chat' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + + @registry.llm_models("spacy.Ollama.v1") def ollama_yi( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "yi", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'yi' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yi", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'yi' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_phind_codellama( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "phind-codellama", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'phind-codellama' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "phind-codellama", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'phind-codellama' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_starling_lm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "starling-lm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'starling-lm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "starling-lm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'starling-lm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizard_math( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizard-math", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizard-math' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-math", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizard-math' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_falcon( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "falcon", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'falcon' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "falcon", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'falcon' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dolphin_phi( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "dolphin-phi", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'dolphin-phi' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-phi", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'dolphin-phi' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_orca2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "orca2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'orca2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "orca2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'orca2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dolphincoder( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "dolphincoder", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'dolphincoder' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphincoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'dolphincoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mxbai_embed_large( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "mxbai-embed-large", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'mxbai-embed-large' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mxbai-embed-large", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'mxbai-embed-large' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_nous_hermes( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "nous-hermes", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'nous-hermes' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'nous-hermes' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_solar( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "solar", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'solar' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "solar", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'solar' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_bakllava( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "bakllava", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'bakllava' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "bakllava", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'bakllava' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_sqlcoder( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "sqlcoder", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'sqlcoder' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "sqlcoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'sqlcoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_medllama2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "medllama2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'medllama2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "medllama2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'medllama2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_nous_hermes2_mixtral( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "nous-hermes2-mixtral", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 47000 -) -> Ollama: - """Returns Ollama instance for 'nous-hermes2-mixtral' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nous-hermes2-mixtral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 47000, +) -> Ollama: + """Returns Ollama instance for 'nous-hermes2-mixtral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizardlm_uncensored( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizardlm-uncensored", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizardlm-uncensored' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardlm-uncensored", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizardlm-uncensored' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_dolphin_llama3( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "dolphin-llama3", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'dolphin-llama3' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "dolphin-llama3", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'dolphin-llama3' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_codeup( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "codeup", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'codeup' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codeup", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'codeup' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_stablelm2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "stablelm2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'stablelm2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stablelm2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'stablelm2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_everythinglm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "everythinglm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 16384 -) -> Ollama: - """Returns Ollama instance for 'everythinglm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "everythinglm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 16384, +) -> Ollama: + """Returns Ollama instance for 'everythinglm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_all_minilm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "all-minilm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'all-minilm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "all-minilm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'all-minilm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_samantha_mistral( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "samantha-mistral", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'samantha-mistral' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "samantha-mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'samantha-mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_yarn_mistral( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "yarn-mistral", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 128000 -) -> Ollama: - """Returns Ollama instance for 'yarn-mistral' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yarn-mistral", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 128000, +) -> Ollama: + """Returns Ollama instance for 'yarn-mistral' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_stable_beluga( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "stable-beluga", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'stable-beluga' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stable-beluga", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'stable-beluga' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_meditron( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "meditron", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'meditron' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "meditron", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'meditron' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_yarn_llama2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "yarn-llama2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 128000 -) -> Ollama: - """Returns Ollama instance for 'yarn-llama2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "yarn-llama2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 128000, +) -> Ollama: + """Returns Ollama instance for 'yarn-llama2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_deepseek_llm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "deepseek-llm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'deepseek-llm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "deepseek-llm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'deepseek-llm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_llama_pro( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "llama-pro", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'llama-pro' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "llama-pro", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'llama-pro' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_magicoder( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "magicoder", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'magicoder' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "magicoder", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'magicoder' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_stablelm_zephyr( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "stablelm-zephyr", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'stablelm-zephyr' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "stablelm-zephyr", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'stablelm-zephyr' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_codebooga( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "codebooga", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'codebooga' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codebooga", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'codebooga' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_codeqwen( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "codeqwen", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'codeqwen' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "codeqwen", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'codeqwen' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_mistrallite( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "mistrallite", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 8192 -) -> Ollama: - """Returns Ollama instance for 'mistrallite' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "mistrallite", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 8192, +) -> Ollama: + """Returns Ollama instance for 'mistrallite' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizard_vicuna( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizard-vicuna", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizard-vicuna' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizard-vicuna", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizard-vicuna' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_nexusraven( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "nexusraven", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'nexusraven' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "nexusraven", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'nexusraven' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_xwinlm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "xwinlm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'xwinlm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "xwinlm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'xwinlm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_goliath( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "goliath", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'goliath' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "goliath", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'goliath' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_open_orca_platypus2( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "open-orca-platypus2", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'open-orca-platypus2' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "open-orca-platypus2", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'open-orca-platypus2' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_wizardlm( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "wizardlm", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'wizardlm' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "wizardlm", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'wizardlm' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_notux( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "notux", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'notux' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "notux", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'notux' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_megadolphin( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "megadolphin", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'megadolphin' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "megadolphin", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'megadolphin' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_duckdb_nsql( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "duckdb-nsql", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'duckdb-nsql' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "duckdb-nsql", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'duckdb-nsql' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_alfred( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "alfred", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'alfred' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "alfred", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'alfred' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_notus( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "notus", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'notus' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "notus", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'notus' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) + @registry.llm_models("spacy.Ollama.v1") def ollama_snowflake_arctic_embed( - config: Dict[Any, Any] = SimpleFrozenDict(), - name: str = "snowflake-arctic-embed", - strict: bool = Ollama.DEFAULT_STRICT, - max_tries: int = Ollama.DEFAULT_MAX_TRIES, - interval: float = Ollama.DEFAULT_INTERVAL, - max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, - context_length: int = 4096 -) -> Ollama: - """Returns Ollama instance for 'snowflake-arctic-embed' model.""" - return Ollama( - name=name, - endpoint=Endpoints.GENERATE.value, - config=config, - strict=strict, - max_tries=max_tries, - interval=interval, - max_request_time=max_request_time, - context_length=context_length - ) + config: Dict[Any, Any] = SimpleFrozenDict(), + name: str = "snowflake-arctic-embed", + strict: bool = Ollama.DEFAULT_STRICT, + max_tries: int = Ollama.DEFAULT_MAX_TRIES, + interval: float = Ollama.DEFAULT_INTERVAL, + max_request_time: float = Ollama.DEFAULT_MAX_REQUEST_TIME, + context_length: int = 4096, +) -> Ollama: + """Returns Ollama instance for 'snowflake-arctic-embed' model.""" + return Ollama( + name=name, + endpoint=Endpoints.GENERATE.value, + config=config, + strict=strict, + max_tries=max_tries, + interval=interval, + max_request_time=max_request_time, + context_length=context_length, + ) diff --git a/spacy_llm/models/rest/openai/registry.py b/spacy_llm/models/rest/openai/registry.py index 767c9d39..472a1c70 100644 --- a/spacy_llm/models/rest/openai/registry.py +++ b/spacy_llm/models/rest/openai/registry.py @@ -186,9 +186,12 @@ def openai_gpt_3_5_v3( """ return OpenAI( name=name, - endpoint=endpoint or Endpoints.CHAT.value - # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. - if name != "gpt-3.5-turbo-instruct" else Endpoints.NON_CHAT.value, + endpoint=( + endpoint or Endpoints.CHAT.value + # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. + if name != "gpt-3.5-turbo-instruct" + else Endpoints.NON_CHAT.value + ), config=config, strict=strict, max_tries=max_tries, @@ -226,9 +229,12 @@ def openai_gpt_3_5_v2( """ return OpenAI( name=name, - endpoint=endpoint or Endpoints.CHAT.value - # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. - if name != "gpt-3.5-turbo-instruct" else Endpoints.NON_CHAT.value, + endpoint=( + endpoint or Endpoints.CHAT.value + # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. + if name != "gpt-3.5-turbo-instruct" + else Endpoints.NON_CHAT.value + ), config=config, strict=strict, max_tries=max_tries, @@ -266,9 +272,12 @@ def openai_gpt_3_5( """ return OpenAI( name=name, - endpoint=endpoint or Endpoints.CHAT.value - # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. - if name != "gpt-3.5-turbo-instruct" else Endpoints.NON_CHAT.value, + endpoint=( + endpoint or Endpoints.CHAT.value + # gpt-3.5-turbo-instruct runs on the non-chat endpoint, so we use that one by default to allow batching. + if name != "gpt-3.5-turbo-instruct" + else Endpoints.NON_CHAT.value + ), config=config, strict=strict, max_tries=max_tries, diff --git a/spacy_llm/models/rest/palm/model.py b/spacy_llm/models/rest/palm/model.py index b1a2657d..3bed215f 100644 --- a/spacy_llm/models/rest/palm/model.py +++ b/spacy_llm/models/rest/palm/model.py @@ -95,9 +95,11 @@ def _request(json_data: Dict[str, Any]) -> Dict[str, Any]: responses = [ _request( { - "prompt": {"text": prompt} - if not uses_chat - else {"messages": [{"content": prompt}]} + "prompt": ( + {"text": prompt} + if not uses_chat + else {"messages": [{"content": prompt}]} + ) } ) for prompt in prompts_for_doc diff --git a/spacy_llm/models/rest/palm/registry.py b/spacy_llm/models/rest/palm/registry.py index 506e6d4b..7a6985f5 100644 --- a/spacy_llm/models/rest/palm/registry.py +++ b/spacy_llm/models/rest/palm/registry.py @@ -76,9 +76,9 @@ def palm_bison_v2( """ return PaLM( name=name, - endpoint=Endpoints.TEXT.value - if name in {"text-bison-001"} - else Endpoints.MSG.value, + endpoint=( + Endpoints.TEXT.value if name in {"text-bison-001"} else Endpoints.MSG.value + ), config=config, strict=strict, max_tries=max_tries,