Spaces:
Sleeping
Sleeping
Download src/llms/base_llm.py from TalatMasud/chatbot-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/TalatMasud/chatbot-backend/resolve/main/src/llms/base_llm.py
- Command line
-
hf download hf://spaces/TalatMasud/chatbot-backend/src/llms/base_llm.py
-
curl -L -o base_llm.py https://huggingface.co/spaces/TalatMasud/chatbot-backend/resolve/main/src/llms/base_llm.py
1.24 kB
| # src/llms/base_llm.py | |
| from abc import ABC, abstractmethod | |
| from typing import List, Optional, Dict, Any | |
| class BaseLLM(ABC): | |
| def generate( | |
| self, | |
| prompt: str, | |
| max_tokens: Optional[int] = None, | |
| temperature: float = 0.7, | |
| **kwargs | |
| ) -> str: | |
| """ | |
| Generate a response based on the given prompt | |
| Args: | |
| prompt (str): Input prompt for the model | |
| max_tokens (Optional[int]): Maximum number of tokens to generate | |
| temperature (float): Sampling temperature for randomness | |
| Returns: | |
| str: Generated response | |
| """ | |
| pass | |
| def tokenize(self, text: str) -> List[str]: | |
| """ | |
| Tokenize the input text | |
| Args: | |
| text (str): Input text to tokenize | |
| Returns: | |
| List[str]: List of tokens | |
| """ | |
| pass | |
| def count_tokens(self, text: str) -> int: | |
| """ | |
| Count tokens in the input text | |
| Args: | |
| text (str): Input text to count tokens | |
| Returns: | |
| int: Number of tokens | |
| """ | |
| pass |