Skip to content

Completions

AzureOpenAI

Bases: LCCompletionMixin, LLM

Wrapper around Langchain's AzureOpenAI class, focusing on key parameters

Source code in libs/kotaemon/kotaemon/llms/completions/langchain_based.py
class AzureOpenAI(LCCompletionMixin, LLM):
    """Wrapper around Langchain's AzureOpenAI class, focusing on key parameters"""

    def __init__(
        self,
        azure_endpoint: Optional[str] = None,
        deployment_name: Optional[str] = None,
        openai_api_version: str = "",
        openai_api_key: Optional[str] = None,
        model_name: str = "text-davinci-003",
        temperature: float = 0.7,
        max_tokens: int = 256,
        top_p: float = 1,
        frequency_penalty: float = 0,
        n: int = 1,
        best_of: int = 1,
        request_timeout: Optional[float] = None,
        max_retries: int = 2,
        streaming: bool = False,
        **params,
    ):
        super().__init__(
            azure_endpoint=azure_endpoint,
            deployment_name=deployment_name,
            openai_api_version=openai_api_version,
            openai_api_key=openai_api_key,
            model_name=model_name,
            temperature=temperature,
            max_tokens=max_tokens,
            top_p=top_p,
            frequency_penalty=frequency_penalty,
            n=n,
            best_of=best_of,
            request_timeout=request_timeout,
            max_retries=max_retries,
            streaming=streaming,
            **params,
        )

    def _get_lc_class(self):
        try:
            from langchain_openai import AzureOpenAI
        except ImportError:
            from langchain.llms import AzureOpenAI

        return AzureOpenAI

LlamaCpp

Bases: LCCompletionMixin, LLM

Wrapper around Langchain's LlamaCpp class, focusing on key parameters

Source code in libs/kotaemon/kotaemon/llms/completions/langchain_based.py
class LlamaCpp(LCCompletionMixin, LLM):
    """Wrapper around Langchain's LlamaCpp class, focusing on key parameters"""

    def __init__(
        self,
        model_path: str,
        lora_base: Optional[str] = None,
        n_ctx: int = 512,
        n_gpu_layers: Optional[int] = None,
        use_mmap: bool = True,
        **params,
    ):
        super().__init__(
            model_path=model_path,
            lora_base=lora_base,
            n_ctx=n_ctx,
            n_gpu_layers=n_gpu_layers,
            use_mmap=use_mmap,
            **params,
        )

    def _get_lc_class(self):
        try:
            from langchain_community.llms import LlamaCpp
        except ImportError:
            from langchain.llms import LlamaCpp

        return LlamaCpp

OpenAI

Bases: LCCompletionMixin, LLM

Wrapper around Langchain's OpenAI class, focusing on key parameters

Source code in libs/kotaemon/kotaemon/llms/completions/langchain_based.py
class OpenAI(LCCompletionMixin, LLM):
    """Wrapper around Langchain's OpenAI class, focusing on key parameters"""

    def __init__(
        self,
        openai_api_key: Optional[str] = None,
        openai_api_base: Optional[str] = None,
        model_name: str = "text-davinci-003",
        temperature: float = 0.7,
        max_tokens: int = 256,
        top_p: float = 1,
        frequency_penalty: float = 0,
        n: int = 1,
        best_of: int = 1,
        request_timeout: Optional[float] = None,
        max_retries: int = 2,
        streaming: bool = False,
        **params,
    ):
        super().__init__(
            openai_api_key=openai_api_key,
            openai_api_base=openai_api_base,
            model_name=model_name,
            temperature=temperature,
            max_tokens=max_tokens,
            top_p=top_p,
            frequency_penalty=frequency_penalty,
            n=n,
            best_of=best_of,
            request_timeout=request_timeout,
            max_retries=max_retries,
            streaming=streaming,
            **params,
        )

    def _get_lc_class(self):
        try:
            from langchain_openai import OpenAI
        except ImportError:
            from langchain.llms import OpenAI

        return OpenAI