Source code for langchain.llms.bittensor
import http.client
import json
import ssl
from typing import Any, List, Mapping, Optional
from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain.llms.base import LLM
[docs]class NIBittensorLLM(LLM):
    """
    NIBittensorLLM is created by Neural Internet (https://neuralinternet.ai/),
    powered by Bittensor, a decentralized network full of different AI models.
    To analyze API_KEYS and logs of your usage visit
        https://api.neuralinternet.ai/api-keys
        https://api.neuralinternet.ai/logs
    Example:
        .. code-block:: python
            from langchain.llms import NIBittensorLLM
            llm = NIBittensorLLM()
    """
    system_prompt: Optional[str]
    """Provide system prompt that you want to supply it to model before every prompt"""
    top_responses: Optional[int] = 0
    """Provide top_responses to get Top N miner responses on one request.May get delayed
        Don't use in Production"""
    @property
    def _llm_type(self) -> str:
        return "NIBittensorLLM"
    def _call(
        self,
        prompt: str,
        stop: Optional[List[str]] = None,
        run_manager: Optional[CallbackManagerForLLMRun] = None,
        **kwargs: Any,
    ) -> str:
        """
        Wrapper around the bittensor top miner models. Its built by Neural Internet.
        Call the Neural Internet's BTVEP Server and return the output.
        Parameters (optional):
            system_prompt(str): A system prompt defining how your model should respond.