Coverage for promplate/llm/base.py: 69%
22 statements
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-09 22:54 +0800
« prev ^ index » next coverage.py v7.6.2, created at 2024-10-09 22:54 +0800
1from functools import partial
2from typing import AsyncIterable, Awaitable, Iterable, Protocol, cast
5class Configurable:
6 def __init__(self, **config):
7 for key, val in config.items():
8 setattr(self, key, val)
10 @property
11 def _config(self):
12 return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
15class Complete(Protocol):
16 def __call__(self, prompt, /, **config) -> str: ... 16 ↛ exitline 16 didn't return from function '__call__' because
19class Generate(Protocol):
20 def __call__(self, prompt, /, **config) -> Iterable[str]: ... 20 ↛ exitline 20 didn't return from function '__call__' because
23class AsyncComplete(Protocol):
24 def __call__(self, prompt, /, **config) -> Awaitable[str]: ... 24 ↛ exitline 24 didn't return from function '__call__' because
27class AsyncGenerate(Protocol):
28 def __call__(self, prompt, /, **config) -> AsyncIterable[str]: ... 28 ↛ exitline 28 didn't return from function '__call__' because
31class LLM(Protocol):
32 @partial(cast, Complete | AsyncComplete)
33 def complete(self, prompt, /, **config) -> str | Awaitable[str]: ... 33 ↛ exitline 33 didn't return from function 'complete' because
35 @partial(cast, Generate | AsyncGenerate)
36 def generate(self, prompt, /, **config) -> Iterable[str] | AsyncIterable[str]: ... 36 ↛ exitline 36 didn't return from function 'generate' because