Implement the config -l and config -m commands.
This commit is contained in:
parent
2b62cb8c4b
commit
f96e82bdd7
@ -59,6 +59,12 @@ class AI(Protocol):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def print_models(self) -> None:
|
||||||
|
"""
|
||||||
|
Print all models supported by this AI.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def tokens(self, data: Union[Message, Chat]) -> int:
|
def tokens(self, data: Union[Message, Chat]) -> int:
|
||||||
"""
|
"""
|
||||||
Computes the nr. of AI language tokens for the given message
|
Computes the nr. of AI language tokens for the given message
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ..configuration import Config
|
from ..configuration import Config
|
||||||
|
from ..ai import AI
|
||||||
|
from ..ai_factory import create_ai
|
||||||
|
|
||||||
|
|
||||||
def config_cmd(args: argparse.Namespace) -> None:
|
def config_cmd(args: argparse.Namespace) -> None:
|
||||||
@ -9,3 +11,10 @@ def config_cmd(args: argparse.Namespace) -> None:
|
|||||||
"""
|
"""
|
||||||
if args.create:
|
if args.create:
|
||||||
Config.create_default(Path(args.create))
|
Config.create_default(Path(args.create))
|
||||||
|
elif args.list_models or args.print_model:
|
||||||
|
config: Config = Config.from_file(args.config)
|
||||||
|
ai: AI = create_ai(args, config)
|
||||||
|
if args.list_models:
|
||||||
|
ai.print_models()
|
||||||
|
else:
|
||||||
|
print(ai.config.model)
|
||||||
|
|||||||
@ -39,6 +39,7 @@ class AIConfig:
|
|||||||
name: ClassVar[str]
|
name: ClassVar[str]
|
||||||
# a user-defined ID for an AI configuration entry
|
# a user-defined ID for an AI configuration entry
|
||||||
ID: str
|
ID: str
|
||||||
|
model: str = 'n/a'
|
||||||
|
|
||||||
# the name must not be changed
|
# the name must not be changed
|
||||||
def __setattr__(self, name: str, value: Any) -> None:
|
def __setattr__(self, name: str, value: Any) -> None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user