removed sysprompt emdashes

This commit is contained in:
Luxferre
2026-08-09 10:37:07 +00:00
parent 49a3576f49
commit c0d7573d70
5 changed files with 9 additions and 7 deletions
+5 -3
View File
@@ -14,6 +14,7 @@ $SIG{__WARN__} = sub {
# results) prints cleanly instead of triggering "Wide character in print"
binmode(STDOUT, ':encoding(UTF-8)');
binmode(STDERR, ':encoding(UTF-8)');
binmode(STDIN, ':encoding(UTF-8)');
$| = 1; # unbuffered output: live spinner, responsive prompt
@@ -21,12 +22,12 @@ my $DEF_SP = "You are Bantam, a tiny, powerful AI agent. Solve the user's task u
my $SDIR = ($ENV{HOME} || $ENV{USERPROFILE} || '.') . '/.bantam/sessions';
sub cfg { my %d = (endpoint=>'https://opencode.ai/zen/v1', model=>'big-pickle', temperature=>0.7, api_key=>'-', timeout=>300, shell_timeout=>120, max_al_iterations=>1000);
if (open my $f, '<', 'model.cfg') { while (<$f>) { /^(\w+)\s*=\s*(.+)$/ and $d{$1} = $2; } }
if (open my $f, '<:encoding(UTF-8)', 'model.cfg') { while (<$f>) { /^(\w+)\s*=\s*(.+)$/ and $d{$1} = $2; } }
$d{api_key} = $ENV{OPENAI_API_KEY} if $d{api_key} eq q{-} && $ENV{OPENAI_API_KEY};
\%d; }
sub sp { my $p = '';
if (open my $f, '<', 'system.txt') { local $/; $p = <$f>; }
if (open my $f, '<:encoding(UTF-8)', 'system.txt') { local $/; $p = <$f>; }
$p =~ s/^\s+|\s+$//g;
length($p) ? $p : $DEF_SP; }
@@ -51,6 +52,7 @@ sub shell_exec { my ($cmd, $t) = @_; # run a command under a hard timeout
my $out = '';
eval { local $SIG{ALRM} = sub { alarm 0; die "timeout\n" }; alarm $t; $out = `$cmd 2>&1`; alarm 0; };
$out =~ s/\s+$//;
utf8::decode($out);
$@ ? "$out\n[timeout after ${t}s]\nexit: -1" : "$out\nexit: " . ($? >> 8); }
sub last_assistant { for my $m (reverse @{$_[0]}) { return $m->{content} if $m->{role} eq 'assistant' && defined $m->{content} && length $m->{content}; } '' }
@@ -96,7 +98,7 @@ sub list_sessions { map { [$_->{id}, scalar @{$_->{messages} // []}] } sessions(
sub main {
my ($c, $sp) = (cfg(), sp());
my $msgs = [{role=>'system', content=>$sp}];
if (@ARGV) { open my $f, '<', $ARGV[0] or die "cannot open $ARGV[0]: $!"; # file mode
if (@ARGV) { open my $f, '<:encoding(UTF-8)', $ARGV[0] or die "cannot open $ARGV[0]: $!"; # file mode
local $/; push @$msgs, {role=>'user', content=><$f>};
AL($c, $msgs, $sp); autosave($msgs); return; }
print "MicroBantam ready ($c->{model}). Commands: /quit /clear /save /list /load <id> /help\n";