Merge branch 'main' of forgejo.zaydenlab.com:Chewt/ai-assistant
This commit is contained in:
commit
4b38d5cb6a
17
assistant.py
17
assistant.py
|
|
@ -76,7 +76,7 @@ def parse_commands(text):
|
||||||
case '/copy':
|
case '/copy':
|
||||||
blocks = extract_code_block(history[-1]['content'])
|
blocks = extract_code_block(history[-1]['content'])
|
||||||
if len(blocks):
|
if len(blocks):
|
||||||
copy_string_to_clipboard(blocks[0])
|
copy_string_to_clipboard(blocks[0][1:-1])
|
||||||
return True
|
return True
|
||||||
case '/exit':
|
case '/exit':
|
||||||
exit()
|
exit()
|
||||||
|
|
@ -139,10 +139,10 @@ def extract_code_block(markdown_text):
|
||||||
for match in matches:
|
for match in matches:
|
||||||
code_block = match.group(0)
|
code_block = match.group(0)
|
||||||
|
|
||||||
highlighted_code = highlight_code(None, code_block)
|
#highlighted_code = highlight_code(None, code_block)
|
||||||
|
|
||||||
# Add the highlighted code block to the list of code blocks
|
# Add the highlighted code block to the list of code blocks
|
||||||
code_blocks.append(highlighted_code)
|
code_blocks.append(code_block)
|
||||||
|
|
||||||
|
|
||||||
if len(code_blocks) == 0:
|
if len(code_blocks) == 0:
|
||||||
|
|
@ -280,6 +280,8 @@ def parse_args():
|
||||||
parser.add_argument('--reasoning', '-r', action='store_true', help='Use the default reasoning model deepseek-r1:14b')
|
parser.add_argument('--reasoning', '-r', action='store_true', help='Use the default reasoning model deepseek-r1:14b')
|
||||||
# Add the --new argument
|
# Add the --new argument
|
||||||
parser.add_argument('--new', '-n', action='store_true', help='Start a chat with a fresh history')
|
parser.add_argument('--new', '-n', action='store_true', help='Start a chat with a fresh history')
|
||||||
|
# Add the --temporary argument
|
||||||
|
parser.add_argument('--temporary', action='store_true', help='Start a chat with a fresh history, without deleting old history')
|
||||||
# Parse the arguments
|
# Parse the arguments
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -376,9 +378,6 @@ def handle_non_piped_input(args):
|
||||||
result = chat2(args, user_input)
|
result = chat2(args, user_input)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
global history
|
|
||||||
history = load_history(history_path)
|
|
||||||
|
|
||||||
print("\033[91massistant\033[0m: Type your message (press Ctrl+D to send):")
|
print("\033[91massistant\033[0m: Type your message (press Ctrl+D to send):")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
@ -415,10 +414,14 @@ def main():
|
||||||
if args.context:
|
if args.context:
|
||||||
global num_ctx
|
global num_ctx
|
||||||
num_ctx = int(args.context)
|
num_ctx = int(args.context)
|
||||||
if args.new:
|
|
||||||
global history
|
global history
|
||||||
|
if args.new:
|
||||||
history = [system_prompt]
|
history = [system_prompt]
|
||||||
save_history(history, history_path)
|
save_history(history, history_path)
|
||||||
|
elif args.temporary:
|
||||||
|
history = [system_prompt]
|
||||||
|
else:
|
||||||
|
history = load_history(history_path)
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
handle_piped_input(args)
|
handle_piped_input(args)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue