Instructions to use realitisoft/ai-bot-test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use realitisoft/ai-bot-test with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="realitisoft/ai-bot-test")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq processor = AutoProcessor.from_pretrained("realitisoft/ai-bot-test") model = AutoModelForSpeechSeq2Seq.from_pretrained("realitisoft/ai-bot-test", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download venv/lib/python3.11/site-packages/prompt_toolkit/lexers/base.py from realitisoft/ai-bot-test: direct link, hf CLI and curl.
- Browser
- Download file 2.35 kB
-
https://huggingface.co/realitisoft/ai-bot-test/resolve/main/venv/lib/python3.11/site-packages/prompt_toolkit/lexers/base.py
- Command line
-
hf download hf://realitisoft/ai-bot-test/venv/lib/python3.11/site-packages/prompt_toolkit/lexers/base.py
-
curl -L -o base.py https://huggingface.co/realitisoft/ai-bot-test/resolve/main/venv/lib/python3.11/site-packages/prompt_toolkit/lexers/base.py
2.35 kB
| """ | |
| Base classes for prompt_toolkit lexers. | |
| """ | |
| from __future__ import annotations | |
| from abc import ABCMeta, abstractmethod | |
| from typing import Callable, Hashable | |
| from prompt_toolkit.document import Document | |
| from prompt_toolkit.formatted_text.base import StyleAndTextTuples | |
| __all__ = [ | |
| "Lexer", | |
| "SimpleLexer", | |
| "DynamicLexer", | |
| ] | |
| class Lexer(metaclass=ABCMeta): | |
| """ | |
| Base class for all lexers. | |
| """ | |
| def lex_document(self, document: Document) -> Callable[[int], StyleAndTextTuples]: | |
| """ | |
| Takes a :class:`~prompt_toolkit.document.Document` and returns a | |
| callable that takes a line number and returns a list of | |
| ``(style_str, text)`` tuples for that line. | |
| XXX: Note that in the past, this was supposed to return a list | |
| of ``(Token, text)`` tuples, just like a Pygments lexer. | |
| """ | |
| def invalidation_hash(self) -> Hashable: | |
| """ | |
| When this changes, `lex_document` could give a different output. | |
| (Only used for `DynamicLexer`.) | |
| """ | |
| return id(self) | |
| class SimpleLexer(Lexer): | |
| """ | |
| Lexer that doesn't do any tokenizing and returns the whole input as one | |
| token. | |
| :param style: The style string for this lexer. | |
| """ | |
| def __init__(self, style: str = "") -> None: | |
| self.style = style | |
| def lex_document(self, document: Document) -> Callable[[int], StyleAndTextTuples]: | |
| lines = document.lines | |
| def get_line(lineno: int) -> StyleAndTextTuples: | |
| "Return the tokens for the given line." | |
| try: | |
| return [(self.style, lines[lineno])] | |
| except IndexError: | |
| return [] | |
| return get_line | |
| class DynamicLexer(Lexer): | |
| """ | |
| Lexer class that can dynamically returns any Lexer. | |
| :param get_lexer: Callable that returns a :class:`.Lexer` instance. | |
| """ | |
| def __init__(self, get_lexer: Callable[[], Lexer | None]) -> None: | |
| self.get_lexer = get_lexer | |
| self._dummy = SimpleLexer() | |
| def lex_document(self, document: Document) -> Callable[[int], StyleAndTextTuples]: | |
| lexer = self.get_lexer() or self._dummy | |
| return lexer.lex_document(document) | |
| def invalidation_hash(self) -> Hashable: | |
| lexer = self.get_lexer() or self._dummy | |
| return id(lexer) | |