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':
|
||||
blocks = extract_code_block(history[-1]['content'])
|
||||
if len(blocks):
|
||||
copy_string_to_clipboard(blocks[0])
|
||||
copy_string_to_clipboard(blocks[0][1:-1])
|
||||
return True
|
||||
case '/exit':
|
||||
exit()
|
||||
|
|
@ -139,10 +139,10 @@ def extract_code_block(markdown_text):
|
|||
for match in matches:
|
||||
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
|
||||
code_blocks.append(highlighted_code)
|
||||
code_blocks.append(code_block)
|
||||
|
||||
|
||||
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')
|
||||
# Add the --new argument
|
||||
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
|
||||
return parser.parse_args()
|
||||
|
||||
|
|
@ -376,9 +378,6 @@ def handle_non_piped_input(args):
|
|||
result = chat2(args, user_input)
|
||||
exit()
|
||||
|
||||
global history
|
||||
history = load_history(history_path)
|
||||
|
||||
print("\033[91massistant\033[0m: Type your message (press Ctrl+D to send):")
|
||||
while True:
|
||||
try:
|
||||
|
|
@ -415,10 +414,14 @@ def main():
|
|||
if args.context:
|
||||
global num_ctx
|
||||
num_ctx = int(args.context)
|
||||
global history
|
||||
if args.new:
|
||||
global history
|
||||
history = [system_prompt]
|
||||
save_history(history, history_path)
|
||||
elif args.temporary:
|
||||
history = [system_prompt]
|
||||
else:
|
||||
history = load_history(history_path)
|
||||
if not sys.stdin.isatty():
|
||||
handle_piped_input(args)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue