question_cmd: added message filtering by tags
This commit is contained in:
parent
b937ad45d4
commit
18feb50d7f
@ -3,7 +3,7 @@ from pathlib import Path
|
|||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from ..configuration import Config
|
from ..configuration import Config
|
||||||
from ..chat import ChatDB
|
from ..chat import ChatDB
|
||||||
from ..message import Message, Question, source_code
|
from ..message import Message, MessageFilter, Question, source_code
|
||||||
from ..ai_factory import create_ai
|
from ..ai_factory import create_ai
|
||||||
from ..ai import AI, AIResponse
|
from ..ai import AI, AIResponse
|
||||||
|
|
||||||
@ -52,8 +52,12 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
|
|||||||
"""
|
"""
|
||||||
Handler for the 'question' command.
|
Handler for the 'question' command.
|
||||||
"""
|
"""
|
||||||
|
mfilter = MessageFilter(tags_or=args.or_tags,
|
||||||
|
tags_and=args.and_tags,
|
||||||
|
tags_not=args.exclude_tags)
|
||||||
chat = ChatDB.from_dir(cache_path=Path('.'),
|
chat = ChatDB.from_dir(cache_path=Path('.'),
|
||||||
db_path=Path(config.db))
|
db_path=Path(config.db),
|
||||||
|
mfilter=mfilter)
|
||||||
# if it's a new question, create and store it immediately
|
# if it's a new question, create and store it immediately
|
||||||
if args.ask or args.create:
|
if args.ask or args.create:
|
||||||
message = create_message(chat, args)
|
message = create_message(chat, args)
|
||||||
@ -77,14 +81,14 @@ def question_cmd(args: argparse.Namespace, config: Config) -> None:
|
|||||||
if response.tokens:
|
if response.tokens:
|
||||||
print("===============")
|
print("===============")
|
||||||
print(response.tokens)
|
print(response.tokens)
|
||||||
elif args.repeat:
|
elif args.repeat is not None:
|
||||||
lmessage = chat.latest_message()
|
lmessage = chat.latest_message()
|
||||||
assert lmessage
|
assert lmessage
|
||||||
# TODO: repeat either the last question or the
|
# TODO: repeat either the last question or the
|
||||||
# one(s) given in 'args.repeat' (overwrite
|
# one(s) given in 'args.repeat' (overwrite
|
||||||
# existing ones if 'args.overwrite' is True)
|
# existing ones if 'args.overwrite' is True)
|
||||||
pass
|
pass
|
||||||
elif args.process:
|
elif args.process is not None:
|
||||||
# TODO: process either all questions without an
|
# TODO: process either all questions without an
|
||||||
# answer or the one(s) given in 'args.process'
|
# answer or the one(s) given in 'args.process'
|
||||||
pass
|
pass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user